@callidescope/configuration 0.0.0-stage → 0.0.4
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.
- package/LICENSE +21 -0
- package/README.md +1068 -2
- package/dist/src/index.d.ts +1755 -0
- package/dist/src/index.js +900 -0
- package/package.json +63 -3
|
@@ -0,0 +1,1755 @@
|
|
|
1
|
+
import { CallGraphResult } from '@callidescope/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Options `depth` and `breadth` accept, scoping a lookup to one workspace.
|
|
6
|
+
*
|
|
7
|
+
* Every override that shapes the graph is here, and no other kind is. A lookup
|
|
8
|
+
* gates nothing and writes nothing, so a limit or a destination has nothing to
|
|
9
|
+
* act on — overriding one would change a number this command never reads.
|
|
10
|
+
*/
|
|
11
|
+
export declare interface AddressCommandOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Callable addresses to report on, each `<file>#<qualified-name>`.
|
|
14
|
+
*
|
|
15
|
+
* Prompted for when empty. Required in the sense that a run cannot proceed
|
|
16
|
+
* without one — but asked for rather than refused, so the flag is only
|
|
17
|
+
* mandatory on a command line nobody is watching.
|
|
18
|
+
*/
|
|
19
|
+
readonly addresses?: string[] | undefined;
|
|
20
|
+
readonly config?: string | undefined;
|
|
21
|
+
/** Project directories to trace. Every project in the workspace when omitted. */
|
|
22
|
+
readonly directories?: string[] | undefined;
|
|
23
|
+
/** Overrides `entryPoints.addresses` for this lookup. */
|
|
24
|
+
readonly entryPointAddresses?: string[] | undefined;
|
|
25
|
+
/** Overrides `entryPoints.decorators` for this lookup. */
|
|
26
|
+
readonly entryPointDecorators?: string[] | undefined;
|
|
27
|
+
/** Overrides `exclude` for this lookup. */
|
|
28
|
+
readonly exclude?: string[] | undefined;
|
|
29
|
+
/** Overrides `excludeCallees` for this lookup. */
|
|
30
|
+
readonly excludeCallees?: string[] | undefined;
|
|
31
|
+
/** `--format`, exactly as it was typed, for the resolver to judge. */
|
|
32
|
+
readonly format?: string | undefined;
|
|
33
|
+
/** Overrides `entryPoints.includeExportedFunctions`, as it was typed. */
|
|
34
|
+
readonly includeExportedFunctions?: string | true | undefined;
|
|
35
|
+
/** Overrides `entryPoints.includeOrphans`, as it was typed. */
|
|
36
|
+
readonly includeOrphans?: string | true | undefined;
|
|
37
|
+
/** Overrides `entryPoints.includeTests`, as it was typed. */
|
|
38
|
+
readonly includeTests?: string | true | undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Every format a run may print, in the order a prompt offers them. */
|
|
42
|
+
export declare const CALLIDESCOPE_OUTPUT_FORMATS: readonly ["markdown", "mermaid", "json"];
|
|
43
|
+
|
|
44
|
+
/** Options the CLI accepts. */
|
|
45
|
+
export declare interface CallidescopeCommandOptions {
|
|
46
|
+
/**
|
|
47
|
+
* The written `--check` set, or `true` for the flag passed without one.
|
|
48
|
+
*
|
|
49
|
+
* Kept as written rather than read into booleans here, so the one place that
|
|
50
|
+
* knows which names exist is the only place that decides what they mean.
|
|
51
|
+
*/
|
|
52
|
+
readonly check?: string | true | undefined;
|
|
53
|
+
readonly config?: string | undefined;
|
|
54
|
+
/** Project directories to trace. Every project in the workspace when omitted. */
|
|
55
|
+
readonly directories?: string[] | undefined;
|
|
56
|
+
/** Overrides `entryPoints.addresses` for this run. */
|
|
57
|
+
readonly entryPointAddresses?: string[] | undefined;
|
|
58
|
+
/** Overrides `entryPoints.decorators` for this run. */
|
|
59
|
+
readonly entryPointDecorators?: string[] | undefined;
|
|
60
|
+
/** Overrides `exclude` for this run. */
|
|
61
|
+
readonly exclude?: string[] | undefined;
|
|
62
|
+
/** Overrides `excludeCallees` for this run. */
|
|
63
|
+
readonly excludeCallees?: string[] | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* `--format`, exactly as it was typed.
|
|
66
|
+
*
|
|
67
|
+
* Left wide on purpose: a value nobody recognizes is refused by the one
|
|
68
|
+
* resolver that knows which formats exist, rather than rewritten to
|
|
69
|
+
* markdown before it ever gets there.
|
|
70
|
+
*/
|
|
71
|
+
readonly format?: string | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Overrides `entryPoints.includeExportedFunctions`, exactly as it was typed.
|
|
74
|
+
*
|
|
75
|
+
* `true` is the flag written with no value at all, which is how commander
|
|
76
|
+
* reports its presence — not a value anybody typed.
|
|
77
|
+
*/
|
|
78
|
+
readonly includeExportedFunctions?: string | true | undefined;
|
|
79
|
+
/** Overrides `entryPoints.includeOrphans`, exactly as it was typed. */
|
|
80
|
+
readonly includeOrphans?: string | true | undefined;
|
|
81
|
+
/** Overrides `entryPoints.includeTests`, exactly as it was typed. */
|
|
82
|
+
readonly includeTests?: string | true | undefined;
|
|
83
|
+
readonly json?: string | undefined;
|
|
84
|
+
readonly markdown?: string | undefined;
|
|
85
|
+
/** Overrides `limits.maximumBreadth`, exactly as it was typed. */
|
|
86
|
+
readonly maximumBreadth?: string | undefined;
|
|
87
|
+
/** Overrides `limits.maximumDepth`, exactly as it was typed. */
|
|
88
|
+
readonly maximumDepth?: string | undefined;
|
|
89
|
+
readonly mermaid?: string | undefined;
|
|
90
|
+
readonly write?: boolean | undefined;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** The shape of a `callidescope.config.ts` default export. */
|
|
94
|
+
export declare interface CallidescopeConfiguration {
|
|
95
|
+
/**
|
|
96
|
+
* Project directories to trace. Every directory holding its own
|
|
97
|
+
* `tsconfig.json`, found by walking the workspace, when omitted.
|
|
98
|
+
*
|
|
99
|
+
* Narrowing this is the difference between a one-second pre-commit check and
|
|
100
|
+
* a whole-workspace analysis, because each directory needs its own program.
|
|
101
|
+
*/
|
|
102
|
+
directories?: string[] | undefined;
|
|
103
|
+
entryPoints?: CallidescopeEntryPoints | undefined;
|
|
104
|
+
exclude?: string[] | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* Globs matched against a callable's display name (`Type.member`):
|
|
107
|
+
* calls landing on a match are dropped from the graph entirely, counting
|
|
108
|
+
* toward neither the caller's depth nor its breadth.
|
|
109
|
+
*
|
|
110
|
+
* For a cross-cutting callable like a logger, every call site is a fact
|
|
111
|
+
* about instrumentation, not about how deep or wide the code around it
|
|
112
|
+
* is — counting it would move every other callable's numbers on a change
|
|
113
|
+
* that has nothing to do with them.
|
|
114
|
+
*/
|
|
115
|
+
excludeCallees?: string[] | undefined;
|
|
116
|
+
/** Gitignore-syntax files listing paths to leave untraced. */
|
|
117
|
+
excludeFrom?: string[] | undefined;
|
|
118
|
+
limits?: CallidescopeLimits | undefined;
|
|
119
|
+
write?: CallidescopeWriteConfiguration | undefined;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Validates the shape of a callidescope configuration file.
|
|
124
|
+
*
|
|
125
|
+
* Strict at every level, so a field nothing here names is refused rather than
|
|
126
|
+
* stripped. Stripping is the failure mode that leaves whoever wrote the field
|
|
127
|
+
* believing a limit, an exclusion, or a destination is in force that nothing
|
|
128
|
+
* reads — and every field this tool has ever retired arrives through that same
|
|
129
|
+
* door, along with every name somebody misspells.
|
|
130
|
+
*
|
|
131
|
+
* `ignoreCallees` and `output` are still named as `z.never()` rather than left
|
|
132
|
+
* to strictness, because a key the schema knows by name earns a message saying
|
|
133
|
+
* this field is gone rather than one saying it was never a field.
|
|
134
|
+
*/
|
|
135
|
+
export declare const callidescopeConfigurationSchema: z.ZodObject<{
|
|
136
|
+
directories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
137
|
+
entryPoints: z.ZodOptional<z.ZodObject<{
|
|
138
|
+
addresses: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
139
|
+
decorators: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
140
|
+
includeExportedFunctions: z.ZodOptional<z.ZodBoolean>;
|
|
141
|
+
includeOrphans: z.ZodOptional<z.ZodBoolean>;
|
|
142
|
+
includeTests: z.ZodOptional<z.ZodBoolean>;
|
|
143
|
+
}, z.core.$strict>>;
|
|
144
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
145
|
+
excludeCallees: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
146
|
+
excludeFrom: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
147
|
+
ignoreCallees: z.ZodOptional<z.ZodNever>;
|
|
148
|
+
limits: z.ZodOptional<z.ZodObject<{
|
|
149
|
+
maximumBreadth: z.ZodOptional<z.ZodNumber>;
|
|
150
|
+
maximumDepth: z.ZodOptional<z.ZodNumber>;
|
|
151
|
+
}, z.core.$strict>>;
|
|
152
|
+
output: z.ZodOptional<z.ZodNever>;
|
|
153
|
+
write: z.ZodOptional<z.ZodObject<{
|
|
154
|
+
json: z.ZodOptional<z.ZodObject<{
|
|
155
|
+
indentation: z.ZodOptional<z.ZodNumber>;
|
|
156
|
+
path: z.ZodString;
|
|
157
|
+
}, z.core.$strict>>;
|
|
158
|
+
markdown: z.ZodOptional<z.ZodObject<{
|
|
159
|
+
description: z.ZodOptional<z.ZodString>;
|
|
160
|
+
endMarker: z.ZodOptional<z.ZodString>;
|
|
161
|
+
heading: z.ZodOptional<z.ZodString>;
|
|
162
|
+
path: z.ZodString;
|
|
163
|
+
previewCount: z.ZodOptional<z.ZodNumber>;
|
|
164
|
+
render: z.ZodOptional<z.ZodType<RenderMarkdownOutput, unknown, z.core.$ZodTypeInternals<RenderMarkdownOutput, unknown>>>;
|
|
165
|
+
startMarker: z.ZodOptional<z.ZodString>;
|
|
166
|
+
writeBlock: z.ZodOptional<z.ZodType<WriteMarkdownOutput, unknown, z.core.$ZodTypeInternals<WriteMarkdownOutput, unknown>>>;
|
|
167
|
+
}, z.core.$strict>>;
|
|
168
|
+
mermaid: z.ZodOptional<z.ZodObject<{
|
|
169
|
+
description: z.ZodOptional<z.ZodString>;
|
|
170
|
+
endMarker: z.ZodOptional<z.ZodString>;
|
|
171
|
+
heading: z.ZodOptional<z.ZodString>;
|
|
172
|
+
path: z.ZodString;
|
|
173
|
+
previewCount: z.ZodOptional<z.ZodNumber>;
|
|
174
|
+
render: z.ZodOptional<z.ZodType<RenderMarkdownOutput, unknown, z.core.$ZodTypeInternals<RenderMarkdownOutput, unknown>>>;
|
|
175
|
+
startMarker: z.ZodOptional<z.ZodString>;
|
|
176
|
+
writeBlock: z.ZodOptional<z.ZodType<WriteMarkdownOutput, unknown, z.core.$ZodTypeInternals<WriteMarkdownOutput, unknown>>>;
|
|
177
|
+
}, z.core.$strict>>;
|
|
178
|
+
}, z.core.$strict>>;
|
|
179
|
+
}, z.core.$strict>;
|
|
180
|
+
|
|
181
|
+
/** Which callables are treated as the roots of a call stack. */
|
|
182
|
+
export declare interface CallidescopeEntryPoints {
|
|
183
|
+
/**
|
|
184
|
+
* Callables this configuration declares as roots, written as
|
|
185
|
+
* `<file>#<qualified-name>` — the same address the `depth` and `breadth`
|
|
186
|
+
* commands accept and every stack frame prints, so one can be copied out of
|
|
187
|
+
* a report straight into here. A trailing `:<line>` disambiguates a file
|
|
188
|
+
* holding two declarations under one qualified name.
|
|
189
|
+
*
|
|
190
|
+
* Declared roots are additive: the rules below keep running, and orphan
|
|
191
|
+
* promotion still catches whatever nobody named. An address naming a
|
|
192
|
+
* callable a rule already rooted is one root, not two.
|
|
193
|
+
*/
|
|
194
|
+
addresses?: string[] | undefined;
|
|
195
|
+
/**
|
|
196
|
+
* Decorators whose methods a framework invokes.
|
|
197
|
+
*
|
|
198
|
+
* Matched against the decorator's own name, then confirmed against the
|
|
199
|
+
* package that declares it, so a locally defined `Command` is not mistaken
|
|
200
|
+
* for nest-commander's.
|
|
201
|
+
*/
|
|
202
|
+
decorators?: string[] | undefined;
|
|
203
|
+
/** Treat every `src/index.ts` export as a root. Defaults to true. */
|
|
204
|
+
includeExportedFunctions?: boolean | undefined;
|
|
205
|
+
/**
|
|
206
|
+
* Promote callables nothing in the repository calls. Defaults to true.
|
|
207
|
+
*
|
|
208
|
+
* This is the safety net that makes a wrong rule set visible: without it, a
|
|
209
|
+
* missing rule silently removes whole subtrees from every measurement.
|
|
210
|
+
*/
|
|
211
|
+
includeOrphans?: boolean | undefined;
|
|
212
|
+
/** Trace test files too. Defaults to false. */
|
|
213
|
+
includeTests?: boolean | undefined;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* The `--format` option every callidescope command shares.
|
|
218
|
+
*
|
|
219
|
+
* Stated as its own interface so `resolveFormatOption` can be generic over a
|
|
220
|
+
* command's whole options object and carry its other flags through unchanged.
|
|
221
|
+
*
|
|
222
|
+
* Held as written rather than as one of the formats a run can print: which
|
|
223
|
+
* values exist is `FlagResolutionService`'s to decide, and a type that
|
|
224
|
+
* narrowed here would leave a misspelled `--format` no way to reach the one
|
|
225
|
+
* place that refuses it.
|
|
226
|
+
*/
|
|
227
|
+
export declare interface CallidescopeFormatOptions {
|
|
228
|
+
readonly format?: string | undefined;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** JSON output destination. */
|
|
232
|
+
export declare interface CallidescopeJsonOutputConfiguration {
|
|
233
|
+
indentation?: number | undefined;
|
|
234
|
+
path: string;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* The limits one command line overrode, and only those.
|
|
239
|
+
*
|
|
240
|
+
* Held apart from the resolved configuration because the two answer different
|
|
241
|
+
* questions. The configuration says what every limit is; this says which of
|
|
242
|
+
* them a flag chose, which is what lets the override reach the number each
|
|
243
|
+
* project is really gated by rather than stopping at the workspace file.
|
|
244
|
+
*
|
|
245
|
+
* A member is present only when a flag supplied it, so an override reaches a
|
|
246
|
+
* project's own declared limit without ever supplying one to a project that
|
|
247
|
+
* declared none.
|
|
248
|
+
*/
|
|
249
|
+
export declare interface CallidescopeLimitOverrides {
|
|
250
|
+
maximumBreadth?: number | undefined;
|
|
251
|
+
maximumDepth?: number | undefined;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Thresholds that decide what a run reports.
|
|
256
|
+
*
|
|
257
|
+
* Two, and both per project: how deep a stack may run, and how widely one
|
|
258
|
+
* callable may reach. Every limit this tool once had beyond these described a
|
|
259
|
+
* finding nobody acted on.
|
|
260
|
+
*/
|
|
261
|
+
export declare interface CallidescopeLimits {
|
|
262
|
+
/**
|
|
263
|
+
* Distinct callables a callable may call directly before it is reported.
|
|
264
|
+
*
|
|
265
|
+
* No default is applied: a project must configure this explicitly before
|
|
266
|
+
* `--check breadth` can run against it.
|
|
267
|
+
*/
|
|
268
|
+
maximumBreadth?: number | undefined;
|
|
269
|
+
/** Frames a call stack may hold before it is reported. */
|
|
270
|
+
maximumDepth?: number | undefined;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** Markdown output destination. */
|
|
274
|
+
export declare interface CallidescopeMarkdownOutputConfiguration {
|
|
275
|
+
description?: string | undefined;
|
|
276
|
+
endMarker?: string | undefined;
|
|
277
|
+
/**
|
|
278
|
+
* Heading the block is written under, `# 🔭 Callidescope` by default.
|
|
279
|
+
*
|
|
280
|
+
* Configurable because a block is spliced into somebody's document, and it is
|
|
281
|
+
* the level rather than the words that usually needs changing: a block
|
|
282
|
+
* spliced into a file that already has a title needs an `##` here, or the
|
|
283
|
+
* file ends up with two first-level headings and every markdown linter
|
|
284
|
+
* rejects it. The subsection levels follow whatever this is set to, so the
|
|
285
|
+
* block stays a well-formed subtree of the document it lands in.
|
|
286
|
+
*/
|
|
287
|
+
heading?: string | undefined;
|
|
288
|
+
path: string;
|
|
289
|
+
/**
|
|
290
|
+
* Stacks shown before the rest fold into a disclosure.
|
|
291
|
+
*
|
|
292
|
+
* A member of the destination rather than of the run, because it is a fact
|
|
293
|
+
* about the document the block lands in: a project's README wants three and
|
|
294
|
+
* a report file wants all of them, and one number for both could only ever
|
|
295
|
+
* be wrong for one of them.
|
|
296
|
+
*/
|
|
297
|
+
previewCount?: number | undefined;
|
|
298
|
+
render?: RenderMarkdownOutput | undefined;
|
|
299
|
+
startMarker?: string | undefined;
|
|
300
|
+
writeBlock?: undefined | WriteMarkdownOutput;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** How a run renders what it found. */
|
|
304
|
+
export declare type CallidescopeOutputFormat = "json" | "markdown" | "mermaid";
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* The complete shape of a project's own `callidescope.config.ts`.
|
|
308
|
+
*
|
|
309
|
+
* Every member is required. A project file is meant to be readable as the
|
|
310
|
+
* whole statement of how that project is traced and judged, which a shape with
|
|
311
|
+
* optional members cannot be: an absent field and a field set to the value it
|
|
312
|
+
* would have defaulted to look identical in the diff, and only one of them was
|
|
313
|
+
* a decision. A project spreads the workspace's `projectDefaults` and overrides
|
|
314
|
+
* what it means to, so completeness costs one line rather than twenty — the
|
|
315
|
+
* same arrangement this repository's codometer configuration files already run.
|
|
316
|
+
*
|
|
317
|
+
* A member is required, not non-empty: `undefined` is the value that says *no
|
|
318
|
+
* destination*, so a project with nothing worth publishing writes that rather
|
|
319
|
+
* than leaving the member out.
|
|
320
|
+
*
|
|
321
|
+
* This is enforced rather than advisory. Every traced project's file is checked
|
|
322
|
+
* against it as it is loaded, and a project leaving a field out is refused by
|
|
323
|
+
* name — as is a traced project with no file at all.
|
|
324
|
+
*/
|
|
325
|
+
export declare interface CallidescopeProjectConfiguration {
|
|
326
|
+
entryPoints: CallidescopeProjectEntryPoints;
|
|
327
|
+
/** Globs matched against paths relative to this project's own root. */
|
|
328
|
+
exclude: string[];
|
|
329
|
+
limits: CallidescopeProjectLimits;
|
|
330
|
+
write: CallidescopeProjectWriteConfiguration;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/** Which of a project's callables are treated as the roots of a call stack. */
|
|
334
|
+
export declare interface CallidescopeProjectEntryPoints {
|
|
335
|
+
addresses: string[];
|
|
336
|
+
decorators: string[];
|
|
337
|
+
includeExportedFunctions: boolean;
|
|
338
|
+
includeOrphans: boolean;
|
|
339
|
+
includeTests: boolean;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* The two limits a project is gated by.
|
|
344
|
+
*
|
|
345
|
+
* `maximumBreadth` is required and may be `undefined`, which is a project
|
|
346
|
+
* saying outright that it gates depth and not breadth — the one thing the
|
|
347
|
+
* absent field could never distinguish itself from a project that forgot.
|
|
348
|
+
*/
|
|
349
|
+
export declare interface CallidescopeProjectLimits {
|
|
350
|
+
maximumBreadth: number | undefined;
|
|
351
|
+
maximumDepth: number;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Where a project's own published section and diagram land.
|
|
356
|
+
*
|
|
357
|
+
* Both paths are read relative to the project's own root, so a project cannot
|
|
358
|
+
* write into a sibling by declaring one. The run's JSON report is absent by
|
|
359
|
+
* construction: it is the run's single output, not a project's to redirect.
|
|
360
|
+
*
|
|
361
|
+
* A destination is the shared markdown-block shape rather than a complete one
|
|
362
|
+
* of its own. What a project is *judged* by has to be written out; where the
|
|
363
|
+
* markers and the heading of its own block sit is presentation the tool has a
|
|
364
|
+
* working answer for, and requiring all seven members would make overriding a
|
|
365
|
+
* path cost six restatements of a default.
|
|
366
|
+
*/
|
|
367
|
+
export declare interface CallidescopeProjectWriteConfiguration {
|
|
368
|
+
markdown: CallidescopeMarkdownOutputConfiguration | undefined;
|
|
369
|
+
mermaid: CallidescopeMarkdownOutputConfiguration | undefined;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Every flag a callidescope command line may carry, as parsed and before any
|
|
374
|
+
* of it has met a configuration.
|
|
375
|
+
*
|
|
376
|
+
* One shape for every command rather than one per command: `depth` accepts a
|
|
377
|
+
* subset of what the workspace run accepts, and a subset is expressed by
|
|
378
|
+
* leaving fields out rather than by a second type that would have to be kept
|
|
379
|
+
* in step with this one.
|
|
380
|
+
*
|
|
381
|
+
* The mode flags are carried here even though resolution never merges them,
|
|
382
|
+
* so the rule they obey is stated where the other flags' rules are rather
|
|
383
|
+
* than left to be inferred from their absence.
|
|
384
|
+
*
|
|
385
|
+
* `--config` is deliberately absent: it chooses the file every other flag is
|
|
386
|
+
* resolved against, so by the time resolution runs it has already done its
|
|
387
|
+
* whole job.
|
|
388
|
+
*/
|
|
389
|
+
export declare interface CallidescopeRunFlags {
|
|
390
|
+
/** Mode. The written `--check` set, or `true` for the flag with no value. */
|
|
391
|
+
readonly check?: string | true | undefined;
|
|
392
|
+
/** Scope. `--directories`, already split on commas. */
|
|
393
|
+
readonly directories?: readonly string[] | undefined;
|
|
394
|
+
/** Judgement. `--entry-point-addresses`, already split on commas. */
|
|
395
|
+
readonly entryPointAddresses?: readonly string[] | undefined;
|
|
396
|
+
/** Judgement. `--entry-point-decorators`, already split on commas. */
|
|
397
|
+
readonly entryPointDecorators?: readonly string[] | undefined;
|
|
398
|
+
/** Judgement. `--exclude`, already split on commas. */
|
|
399
|
+
readonly exclude?: readonly string[] | undefined;
|
|
400
|
+
/** Judgement. `--exclude-callees`, already split on commas. */
|
|
401
|
+
readonly excludeCallees?: readonly string[] | undefined;
|
|
402
|
+
/** Presentation. `--format`, exactly as it was typed. */
|
|
403
|
+
readonly format?: string | undefined;
|
|
404
|
+
/**
|
|
405
|
+
* Judgement. `--include-exported-functions`, exactly as it was typed.
|
|
406
|
+
*
|
|
407
|
+
* A switch arrives here as written text rather than as a boolean for the
|
|
408
|
+
* same reason `--format` does: which values a switch accepts is this
|
|
409
|
+
* package's to decide, and a `--include-tests maybe` coerced to `true` on
|
|
410
|
+
* the way here could never be refused by the one place that knows better.
|
|
411
|
+
* `true` is the one exception, and it is not a coercion: a switch written
|
|
412
|
+
* with no value at all is how commander reports the flag's own presence.
|
|
413
|
+
*/
|
|
414
|
+
readonly includeExportedFunctions?: string | true | undefined;
|
|
415
|
+
/** Judgement. `--include-orphans`, exactly as it was typed. */
|
|
416
|
+
readonly includeOrphans?: string | true | undefined;
|
|
417
|
+
/** Judgement. `--include-tests`, exactly as it was typed. */
|
|
418
|
+
readonly includeTests?: string | true | undefined;
|
|
419
|
+
/** Destination. `--json`, a path and nothing else. */
|
|
420
|
+
readonly json?: string | undefined;
|
|
421
|
+
/** Destination. `--markdown`, a path and nothing else. */
|
|
422
|
+
readonly markdown?: string | undefined;
|
|
423
|
+
/** Judgement. `--maximum-breadth`, exactly as it was typed. */
|
|
424
|
+
readonly maximumBreadth?: string | undefined;
|
|
425
|
+
/** Judgement. `--maximum-depth`, exactly as it was typed. */
|
|
426
|
+
readonly maximumDepth?: string | undefined;
|
|
427
|
+
/** Destination. `--mermaid`, a path and nothing else. */
|
|
428
|
+
readonly mermaid?: string | undefined;
|
|
429
|
+
/** Mode. `--write`. */
|
|
430
|
+
readonly write?: boolean | undefined;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/** Where a run writes its findings. */
|
|
434
|
+
export declare interface CallidescopeWriteConfiguration {
|
|
435
|
+
json?: CallidescopeJsonOutputConfiguration | undefined;
|
|
436
|
+
markdown?: CallidescopeMarkdownOutputConfiguration | undefined;
|
|
437
|
+
/**
|
|
438
|
+
* A markdown block whose call stacks are drawn rather than printed.
|
|
439
|
+
*
|
|
440
|
+
* Its own destination rather than a mode on `markdown`, so a repository can
|
|
441
|
+
* publish both: the tree carries what each frame takes, returns, and
|
|
442
|
+
* documents, and the diagram carries the shape they make together. Neither
|
|
443
|
+
* one is the other with a flag flipped.
|
|
444
|
+
*/
|
|
445
|
+
mermaid?: CallidescopeMarkdownOutputConfiguration | undefined;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* What `--check breadth` asks the run to fail on: a callable calling too many
|
|
450
|
+
* other callables directly.
|
|
451
|
+
*/
|
|
452
|
+
export declare const CHECK_BREADTH = "breadth";
|
|
453
|
+
|
|
454
|
+
/** What `--check depth` asks the run to fail on: a call stack that is too deep. */
|
|
455
|
+
export declare const CHECK_DEPTH = "depth";
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Everything `--check` accepts, in the order an error message lists them.
|
|
459
|
+
*
|
|
460
|
+
* Named here rather than spelled into each message, so the list a mistake is
|
|
461
|
+
* measured against and the list it is told about can never drift apart.
|
|
462
|
+
*/
|
|
463
|
+
export declare const CHECK_NAMES: string[];
|
|
464
|
+
|
|
465
|
+
/** What `--check reports` asks the run to fail on: a stale written report. */
|
|
466
|
+
export declare const CHECK_REPORTS = "reports";
|
|
467
|
+
|
|
468
|
+
/** How a `--check` value is written: one comma-separated set, no spaces needed. */
|
|
469
|
+
export declare const CHECK_SEPARATOR = ",";
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Configuration file names, in the order they are searched for.
|
|
473
|
+
*
|
|
474
|
+
* TypeScript comes first because that is the form a repository gets type
|
|
475
|
+
* checking from, and the form every other configuration file in this workspace
|
|
476
|
+
* is written in.
|
|
477
|
+
*/
|
|
478
|
+
export declare const CONFIGURATION_FILE_NAMES: readonly ["callidescope.config.ts", "callidescope.config.mts", "callidescope.config.cts", "callidescope.config.js", "callidescope.config.mjs", "callidescope.config.cjs", "callidescope.config.json", "callidescope.config.jsonc"];
|
|
479
|
+
|
|
480
|
+
/** Raised when an explicitly named configuration file does not exist. */
|
|
481
|
+
export declare class ConfigurationFileNotFoundError extends Error {
|
|
482
|
+
constructor(filePath: string);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* The two reads the collaborators behind `ConfigurationService` need from a
|
|
487
|
+
* configuration file loader.
|
|
488
|
+
*
|
|
489
|
+
* Narrow on purpose, and passed in rather than injected: it is what leaves the
|
|
490
|
+
* whole layer replaceable by a double at its one public surface, without the
|
|
491
|
+
* classes behind that surface pointing at each other. The overload pair
|
|
492
|
+
* mirrors the loader's own — naming a path guarantees one back.
|
|
493
|
+
*
|
|
494
|
+
* `ConfigurationService` hands over itself rather than the loader it holds,
|
|
495
|
+
* and it is the only class in this package that declares `implements` on this
|
|
496
|
+
* interface — `ConfigurationFileService` merely happens to have the same two
|
|
497
|
+
* methods. Callidescope resolves a call on `reader` through the declared type,
|
|
498
|
+
* so the one nominal implementer is what a traced stack lands on either way,
|
|
499
|
+
* which is why the choice measures the same depth. What it does decide is
|
|
500
|
+
* whether a caller stubbing the one public object has stubbed what these
|
|
501
|
+
* collaborators read. It has, which is the property publishing one object
|
|
502
|
+
* exists to give.
|
|
503
|
+
*/
|
|
504
|
+
declare interface ConfigurationFileReader {
|
|
505
|
+
findConfigurationFileAt(directory: string): string | undefined;
|
|
506
|
+
loadConfigurationFile(args: LoadConfigurationArguments & {
|
|
507
|
+
configurationPath: string;
|
|
508
|
+
}): Promise<LoadedCallidescopeConfigurationFile>;
|
|
509
|
+
loadConfigurationFile(args?: LoadConfigurationArguments): Promise<LoadedCallidescopeConfiguration>;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Loads, validates, and normalizes callidescope configuration files.
|
|
514
|
+
*
|
|
515
|
+
* This service owns loading only. What the configuration means — which files an
|
|
516
|
+
* exclusion glob removes, which decorator marks a stack root — belongs to the
|
|
517
|
+
* analyzers that read it, so that reading a configuration file stays free of any
|
|
518
|
+
* knowledge of the repository being traced.
|
|
519
|
+
*/
|
|
520
|
+
declare class ConfigurationFileService {
|
|
521
|
+
constructor();
|
|
522
|
+
/**
|
|
523
|
+
* Walks upward from a directory looking for a configuration file.
|
|
524
|
+
*
|
|
525
|
+
* Returns `undefined` when the search reaches the filesystem root without
|
|
526
|
+
* finding one: a repository that never wrote a configuration file is traced
|
|
527
|
+
* with the defaults rather than told to write one.
|
|
528
|
+
*/
|
|
529
|
+
private findConfigurationFile;
|
|
530
|
+
/**
|
|
531
|
+
* Walks upward from the process cwd looking for the repository root.
|
|
532
|
+
*
|
|
533
|
+
* Used to resolve a configuration path given relative to that root even when
|
|
534
|
+
* the command was invoked from a nested directory, which is what a task runner
|
|
535
|
+
* does whenever it sets the cwd to the project rather than the workspace.
|
|
536
|
+
*/
|
|
537
|
+
private findRepositoryRoot;
|
|
538
|
+
/** Loads a configuration module, choosing the reader by extension. */
|
|
539
|
+
private loadConfigurationModule;
|
|
540
|
+
/** Reads a JSON or JSONC configuration file. */
|
|
541
|
+
private loadJsonConfiguration;
|
|
542
|
+
/** Resolves a configuration path against the cwd, then the repository root. */
|
|
543
|
+
private resolveConfigurationPath;
|
|
544
|
+
/**
|
|
545
|
+
* Applies defaults to the entry-point rules.
|
|
546
|
+
*
|
|
547
|
+
* The authored object is defaulted to an empty one up front rather than
|
|
548
|
+
* optional-chained per field, which keeps this to one branch per option
|
|
549
|
+
* instead of two.
|
|
550
|
+
*/
|
|
551
|
+
private resolveEntryPoints;
|
|
552
|
+
/**
|
|
553
|
+
* Applies the directories no repository wants traced, on top of a
|
|
554
|
+
* configuration's own.
|
|
555
|
+
*
|
|
556
|
+
* Additive rather than a replacement: the defaults are directories no
|
|
557
|
+
* repository wants traced, so a configuration naming its own noise should
|
|
558
|
+
* not have to restate them to keep them out.
|
|
559
|
+
*/
|
|
560
|
+
private resolveExclude;
|
|
561
|
+
/** Applies defaults to the JSON output destination, if one was named. */
|
|
562
|
+
private resolveJsonOutput;
|
|
563
|
+
/** Applies defaults to every threshold. */
|
|
564
|
+
private resolveLimits;
|
|
565
|
+
/**
|
|
566
|
+
* Applies defaults to one anchored markdown destination, if it was named.
|
|
567
|
+
*
|
|
568
|
+
* Shared by `markdown` and `mermaid`: the two differ in what is written
|
|
569
|
+
* between the anchors, and in nothing this resolves.
|
|
570
|
+
*/
|
|
571
|
+
private resolveMarkdownDestination;
|
|
572
|
+
/**
|
|
573
|
+
* Finds a configuration file sitting directly at one directory.
|
|
574
|
+
*
|
|
575
|
+
* No upward walk, which is what makes this the search a project root needs:
|
|
576
|
+
* walking up from one would find the workspace file and hand every project a
|
|
577
|
+
* copy of it.
|
|
578
|
+
*/
|
|
579
|
+
findConfigurationFileAt(directory: string): string | undefined;
|
|
580
|
+
/**
|
|
581
|
+
* Loads and validates a callidescope configuration file.
|
|
582
|
+
*
|
|
583
|
+
* A path that was named explicitly must exist — a typo in a task runner's
|
|
584
|
+
* arguments should fail rather than quietly trace the repository with defaults
|
|
585
|
+
* it never asked for. A path that was not named is searched for, and its
|
|
586
|
+
* absence is legal.
|
|
587
|
+
*/
|
|
588
|
+
loadConfiguration(args?: LoadConfigurationArguments): Promise<ResolvedCallidescopeConfiguration>;
|
|
589
|
+
/**
|
|
590
|
+
* Loads a configuration, and says what the file itself declared and which
|
|
591
|
+
* file answered.
|
|
592
|
+
*
|
|
593
|
+
* The same work as `loadConfiguration`, keeping two facts it throws away. The
|
|
594
|
+
* path is what tells a caller resolving a configuration beside every project
|
|
595
|
+
* which file it has already read as the run's own, so that one file is never
|
|
596
|
+
* given two roles. The authored object is what a refusal has to name fields
|
|
597
|
+
* from, since resolution manufactures the rest.
|
|
598
|
+
*
|
|
599
|
+
* Naming a path guarantees one back, which is why that case has an overload
|
|
600
|
+
* of its own: the alternative is every caller of the narrow case carrying a
|
|
601
|
+
* fallback that can never fire, and picking its own path when it does.
|
|
602
|
+
*/
|
|
603
|
+
loadConfigurationFile(args: LoadConfigurationArguments & {
|
|
604
|
+
configurationPath: string;
|
|
605
|
+
}): Promise<LoadedCallidescopeConfigurationFile>;
|
|
606
|
+
loadConfigurationFile(args?: LoadConfigurationArguments): Promise<LoadedCallidescopeConfiguration>;
|
|
607
|
+
/**
|
|
608
|
+
* Fills in every field a configuration file may leave out.
|
|
609
|
+
*
|
|
610
|
+
* Exposed so a host embedding callidescope can hand over a configuration
|
|
611
|
+
* object it assembled itself and get the same shape a configuration file
|
|
612
|
+
* produces.
|
|
613
|
+
*/
|
|
614
|
+
resolveConfiguration(configuration: CallidescopeConfiguration): ResolvedCallidescopeConfiguration;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Provides the configuration layer's one public service.
|
|
619
|
+
*
|
|
620
|
+
* `ProjectConfigurationService` is provided here, and the three modules above
|
|
621
|
+
* supply the other collaborators `ConfigurationService` is assembled from.
|
|
622
|
+
* None of them is exported: a consumer outside this package injects
|
|
623
|
+
* `ConfigurationService`, which is what makes this layer one entry point
|
|
624
|
+
* rather than four.
|
|
625
|
+
*/
|
|
626
|
+
export declare class ConfigurationModule {
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* The one answer to "what is this run actually configured to do".
|
|
631
|
+
*
|
|
632
|
+
* Every question a caller outside this package can ask about configuration is
|
|
633
|
+
* asked here: what a file declares, what a project is gated by, what a command
|
|
634
|
+
* line resolved to, and what to ask a person for when a flag was left off. A
|
|
635
|
+
* consumer therefore injects this and nothing else from this package, which is
|
|
636
|
+
* what makes the configuration layer one layer rather than a bag of
|
|
637
|
+
* collaborators a caller has to know the names of.
|
|
638
|
+
*
|
|
639
|
+
* Nearly every method here forwards and nothing more. Loading a file, judging
|
|
640
|
+
* a project's own file, planning a run from flags, and prompting are four
|
|
641
|
+
* different jobs and stay four classes in four files behind this one; what
|
|
642
|
+
* they stop being is four public entry points. A facade that implemented any
|
|
643
|
+
* of them would be a facade in name only, and the one-per-job split is what
|
|
644
|
+
* keeps each of them readable.
|
|
645
|
+
*
|
|
646
|
+
* `resolveFormatOption` is the exception, and a small one: deciding whether to
|
|
647
|
+
* offer a prompt at all is a policy over two collaborators rather than work
|
|
648
|
+
* either of them does, and it reads a constant the prompting service must not
|
|
649
|
+
* import. Its whole body is that decision.
|
|
650
|
+
*/
|
|
651
|
+
export declare class ConfigurationService implements ConfigurationFileReader {
|
|
652
|
+
private readonly configurationFileService;
|
|
653
|
+
private readonly inputService;
|
|
654
|
+
private readonly projectConfigurationService;
|
|
655
|
+
private readonly runPlanService;
|
|
656
|
+
constructor(configurationFileService: ConfigurationFileService, inputService: InputService, projectConfigurationService: ProjectConfigurationService, runPlanService: RunPlanService);
|
|
657
|
+
/** Finds a configuration file sitting directly at one directory. */
|
|
658
|
+
findConfigurationFileAt(directory: string): string | undefined;
|
|
659
|
+
/**
|
|
660
|
+
* Loads a configuration, and says what the file itself declared and which
|
|
661
|
+
* file answered.
|
|
662
|
+
*/
|
|
663
|
+
loadConfigurationFile(args: LoadConfigurationArguments & {
|
|
664
|
+
configurationPath: string;
|
|
665
|
+
}): Promise<LoadedCallidescopeConfigurationFile>;
|
|
666
|
+
loadConfigurationFile(args?: LoadConfigurationArguments): Promise<LoadedCallidescopeConfiguration>;
|
|
667
|
+
/** Loads and validates every traced project's own configuration file. */
|
|
668
|
+
loadProjectConfigurations(args: LoadProjectConfigurationsArguments): Promise<LoadedProjectConfiguration[]>;
|
|
669
|
+
/** Splits a comma-separated flag value into its parts. */
|
|
670
|
+
parseCommaDelimitedOption(value: string | undefined): string[];
|
|
671
|
+
/** Reads a flag that may have been written without a value. */
|
|
672
|
+
parseOptionalOption(value: string | undefined): string | undefined;
|
|
673
|
+
/** Reads a lookup's scoping flags into a workspace root and a configuration. */
|
|
674
|
+
prepareLookup(options: AddressCommandOptions): Promise<PreparedLookup>;
|
|
675
|
+
/** Reads a command line and its configuration into what the run will do. */
|
|
676
|
+
prepareRun(options: CallidescopeCommandOptions): Promise<RunPreparation>;
|
|
677
|
+
/** Prompts for several values at once, completing the list as it is typed. */
|
|
678
|
+
promptForAutocompleteMultiselect(args: {
|
|
679
|
+
message: string;
|
|
680
|
+
subject: string;
|
|
681
|
+
suggestions: readonly string[];
|
|
682
|
+
}): Promise<string[]>;
|
|
683
|
+
/** Prompts for one value out of a fixed set of choices. */
|
|
684
|
+
promptForSelect<Choice extends string>(args: {
|
|
685
|
+
choices: readonly Choice[];
|
|
686
|
+
message: string;
|
|
687
|
+
subject: string;
|
|
688
|
+
}): Promise<Choice>;
|
|
689
|
+
/** Fills in every field a configuration file may leave out. */
|
|
690
|
+
resolveConfiguration(configuration: CallidescopeConfiguration): ResolvedCallidescopeConfiguration;
|
|
691
|
+
/**
|
|
692
|
+
* Returns the given options with `--format` filled in where one is wanted.
|
|
693
|
+
*
|
|
694
|
+
* Offered rather than required, which is the one place this differs from
|
|
695
|
+
* every other missing value: the caller applies its own default when
|
|
696
|
+
* nobody is at a terminal to ask, so a run proceeds with nothing typed.
|
|
697
|
+
* Demanding it would fail every scripted run — this repository's own
|
|
698
|
+
* per-project `gate` among them — over a flag those runs have never needed
|
|
699
|
+
* to pass.
|
|
700
|
+
*
|
|
701
|
+
* Generic over the caller's options type, so a command carries its own
|
|
702
|
+
* other flags through unchanged.
|
|
703
|
+
*/
|
|
704
|
+
resolveFormatOption<Options extends CallidescopeFormatOptions>(options: Options): Promise<Options>;
|
|
705
|
+
/** Resolves the limits every traced project is judged against. */
|
|
706
|
+
resolveLimits(args: ResolveProjectLimitsArguments): ProjectLimitsLookup;
|
|
707
|
+
/** Whether a run reads or rewrites the files its reports live in. */
|
|
708
|
+
touchesFiles(mode: RunMode): boolean;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/** Decorators whose methods a framework invokes, making them stack roots. */
|
|
712
|
+
export declare const DEFAULT_ENTRY_POINT_DECORATORS: readonly ["Command", "Cron", "Delete", "Get", "Mutation", "OnEvent", "Option", "Patch", "Post", "Put", "Query", "ResolveField", "SubscribeMessage"];
|
|
713
|
+
|
|
714
|
+
/** Directories no repository wants traced, kept out even when unmentioned. */
|
|
715
|
+
export declare const DEFAULT_EXCLUDE_GLOBS: readonly ["**/.conformetry/**", "**/.nx/**", "**/coverage/**", "**/dist/**", "**/node_modules/**", "**/output/**"];
|
|
716
|
+
|
|
717
|
+
/** Spaces used to indent the JSON report. */
|
|
718
|
+
export declare const DEFAULT_JSON_INDENTATION = 2;
|
|
719
|
+
|
|
720
|
+
/** Closing anchor of the generated markdown block. */
|
|
721
|
+
export declare const DEFAULT_MARKDOWN_END_MARKER = "<!-- callidescope:end -->";
|
|
722
|
+
|
|
723
|
+
/** Opening anchor of the generated markdown block. */
|
|
724
|
+
export declare const DEFAULT_MARKDOWN_START_MARKER = "<!-- callidescope:start -->";
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* Frames allowed on a call stack before it is reported.
|
|
728
|
+
*
|
|
729
|
+
* Six is the issue's own example limit. It counts frames inclusive of the entry
|
|
730
|
+
* point, so a resolver calling a service calling a repository is three.
|
|
731
|
+
*/
|
|
732
|
+
export declare const DEFAULT_MAXIMUM_DEPTH = 6;
|
|
733
|
+
|
|
734
|
+
/** What a run prints to standard output when nothing says otherwise. */
|
|
735
|
+
export declare const DEFAULT_OUTPUT_FORMAT = "markdown";
|
|
736
|
+
|
|
737
|
+
/** Stacks a README section shows before the rest fold into a disclosure. */
|
|
738
|
+
export declare const DEFAULT_PREVIEW_COUNT = 3;
|
|
739
|
+
|
|
740
|
+
/** Heading the section embedded in a project README is written under. */
|
|
741
|
+
export declare const DEFAULT_PROJECT_README_HEADING = "## \uD83D\uDD2D Callidescope";
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* Heading a whole-run markdown block is written under.
|
|
745
|
+
*
|
|
746
|
+
* First level, because the historical destination for this block is a file of
|
|
747
|
+
* its own that the block is the whole of. A block spliced into a file that
|
|
748
|
+
* already has a title sets `heading` to a deeper level instead.
|
|
749
|
+
*/
|
|
750
|
+
export declare const DEFAULT_RUN_HEADING = "# \uD83D\uDD2D Callidescope";
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* The flags that name where a report goes, rather than whether one is written.
|
|
754
|
+
*
|
|
755
|
+
* Kept as a list so the refusal in `RunPlanService.selectMode` names every one
|
|
756
|
+
* the command line supplied, and so adding a destination flag without adding
|
|
757
|
+
* it here is the only way to reintroduce a flag that writes nothing silently.
|
|
758
|
+
*/
|
|
759
|
+
export declare const DESTINATION_FLAG_NAMES: readonly ["json", "markdown", "mermaid"];
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* One refusal covering every flag a command line got wrong.
|
|
763
|
+
*
|
|
764
|
+
* An `InputError` rather than a class of its own: to whoever catches it this
|
|
765
|
+
* is the same event as any other unusable command line — nothing was
|
|
766
|
+
* attempted, and the fix is to retype the flags.
|
|
767
|
+
*/
|
|
768
|
+
export declare const flagResolutionError: (reasons: readonly string[]) => InputError;
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* Combines a command line with the configuration it was resolved against,
|
|
772
|
+
* under one precedence rule.
|
|
773
|
+
*
|
|
774
|
+
* **The rule.** A flag that changes what a run judges or writes may only
|
|
775
|
+
* override a value the configuration already declares. A flag that selects
|
|
776
|
+
* mode or presentation is command-line only, because neither can make an
|
|
777
|
+
* under-configured run legal.
|
|
778
|
+
*
|
|
779
|
+
* `--check` and `--write` are the mode flags and `--format` is the
|
|
780
|
+
* presentation flag, so none of the three is merged into anything here — the
|
|
781
|
+
* format is validated and handed back beside the configuration rather than
|
|
782
|
+
* written into it. Every other flag is an override, so each replaces exactly
|
|
783
|
+
* the field it names and leaves every neighboring field as the configuration
|
|
784
|
+
* wrote it — including whatever resolution folded into that field, which is
|
|
785
|
+
* why `--exclude` keeps the default globs rather than the six of them being
|
|
786
|
+
* neighbors it discards. `--config` never reaches this call at all: it chooses
|
|
787
|
+
* the file the rest are resolved against.
|
|
788
|
+
*
|
|
789
|
+
* Every configured field has such an override, save one. `excludeFrom` names
|
|
790
|
+
* the ignore files a run reads, which is what the run *is* rather than a value
|
|
791
|
+
* it judges by, and it is workspace-only for the same reason — a project
|
|
792
|
+
* cannot redirect it either.
|
|
793
|
+
*
|
|
794
|
+
* The overrides are grouped rather than listed, one private method per nesting
|
|
795
|
+
* level of the configuration, because a single returned literal covering four
|
|
796
|
+
* levels was already the longest thing here at three fields and would not have
|
|
797
|
+
* survived thirteen.
|
|
798
|
+
*
|
|
799
|
+
* One service rather than a merge per command, because the four defects this
|
|
800
|
+
* replaced were each a different command combining one flag with one field
|
|
801
|
+
* its own way: an empty `--directories` beating the configured list, a
|
|
802
|
+
* `--markdown` path discarding the heading and markers beside it, a `--json`
|
|
803
|
+
* path discarding the configured indentation, and an unrecognized `--format`
|
|
804
|
+
* rewritten to markdown instead of refused.
|
|
805
|
+
*/
|
|
806
|
+
declare class FlagResolutionService {
|
|
807
|
+
constructor();
|
|
808
|
+
/**
|
|
809
|
+
* Reads one limit flag into the number it chose, or nothing.
|
|
810
|
+
*
|
|
811
|
+
* Nothing on every path but success — the flag left off, and both refusals —
|
|
812
|
+
* because the caller reads this as *what the command line overrode*, and a
|
|
813
|
+
* refused value reported as an override would be the typo silently winning
|
|
814
|
+
* the argument it just lost.
|
|
815
|
+
*
|
|
816
|
+
* Two refusals rather than one, because they are different mistakes: a value
|
|
817
|
+
* that is not a positive whole number is a typo, and a value with nothing to
|
|
818
|
+
* override is the precedence rule. Only `limits.maximumBreadth` can reach the
|
|
819
|
+
* second — it is the one judged value resolution supplies no default for, and
|
|
820
|
+
* a flag that could supply one would gate a workspace on a number no
|
|
821
|
+
* configuration ever chose.
|
|
822
|
+
*/
|
|
823
|
+
private resolveCount;
|
|
824
|
+
/**
|
|
825
|
+
* Applies a path flag to one configured destination, and to nothing else.
|
|
826
|
+
*
|
|
827
|
+
* Spread over the configured object rather than resolved afresh from the
|
|
828
|
+
* path: a destination carries a heading, a description, its anchors, and
|
|
829
|
+
* its render and write hooks, and re-resolving from a path alone silently
|
|
830
|
+
* replaced every one of them with a default.
|
|
831
|
+
*
|
|
832
|
+
* An undeclared destination is refused rather than invented, which is the
|
|
833
|
+
* precedence rule itself: a flag may change where a declared report goes
|
|
834
|
+
* and may not ask for a report the configuration never declared.
|
|
835
|
+
*/
|
|
836
|
+
private resolveDestination;
|
|
837
|
+
/**
|
|
838
|
+
* Applies the entry-point flags to the rules a run roots its stacks with.
|
|
839
|
+
*
|
|
840
|
+
* Grouped rather than spread into the caller, so the one returned literal
|
|
841
|
+
* there stays four fields long however many rules this level grows.
|
|
842
|
+
*/
|
|
843
|
+
private resolveEntryPoints;
|
|
844
|
+
/**
|
|
845
|
+
* Reads `--exclude` the way the configured field beside it is read: over the
|
|
846
|
+
* top of the globs no repository wants traced, never instead of them.
|
|
847
|
+
*
|
|
848
|
+
* `exclude` is the one list resolution does not hand back as written —
|
|
849
|
+
* `resolveExclude` folds `DEFAULT_EXCLUDE_GLOBS` into it, so the array
|
|
850
|
+
* arriving here is the authored globs plus six directories nobody chose.
|
|
851
|
+
* Replacing that array wholesale, as every other list flag rightly does with
|
|
852
|
+
* its own field, therefore threw away the defaults too: `--exclude src/**`
|
|
853
|
+
* traced `node_modules` and `dist`. So the flag overrides what the
|
|
854
|
+
* configuration *authored* and the same additive resolution is re-run over
|
|
855
|
+
* it, which is what makes `--exclude` and an authored `exclude` mean the
|
|
856
|
+
* same thing.
|
|
857
|
+
*/
|
|
858
|
+
private resolveExclude;
|
|
859
|
+
/**
|
|
860
|
+
* Reads `--format` into one of the formats a run can print.
|
|
861
|
+
*
|
|
862
|
+
* Anything else is refused rather than rewritten. A run that quietly
|
|
863
|
+
* printed markdown for `--format mermiad` exited 0 having taught its reader
|
|
864
|
+
* that the flag does nothing.
|
|
865
|
+
*/
|
|
866
|
+
private resolveFormat;
|
|
867
|
+
/**
|
|
868
|
+
* Reads the limit flags into the numbers they chose, and nothing else.
|
|
869
|
+
*
|
|
870
|
+
* The overrides are what a flag really said, kept apart from the merged
|
|
871
|
+
* configuration below, because a limit is enforced per project: a project's
|
|
872
|
+
* own file declares the number its gate reads, so an override that stopped
|
|
873
|
+
* at the workspace's copy would be a flag no gate ever looks at. A member is
|
|
874
|
+
* absent unless a flag supplied it, which is what lets the override be
|
|
875
|
+
* applied to a declared limit without supplying one where none was declared.
|
|
876
|
+
*/
|
|
877
|
+
private resolveLimitOverrides;
|
|
878
|
+
/**
|
|
879
|
+
* Applies the limit overrides to the numbers the run's own configuration
|
|
880
|
+
* declares.
|
|
881
|
+
*
|
|
882
|
+
* An absent breadth limit is left off the object rather than written as an
|
|
883
|
+
* explicit `undefined`: `maximumBreadth` is the one optional member here, and
|
|
884
|
+
* a key that is always present would say a configuration declared a breadth
|
|
885
|
+
* limit of nothing where resolution had simply never been given one.
|
|
886
|
+
*/
|
|
887
|
+
private resolveLimits;
|
|
888
|
+
/**
|
|
889
|
+
* Reads one list flag, preferring it over the configuration when it named
|
|
890
|
+
* anything.
|
|
891
|
+
*
|
|
892
|
+
* An empty list is absent rather than a value: `--directories ""` and a
|
|
893
|
+
* `--directories` nobody typed arrive here as the same thing, and reading
|
|
894
|
+
* either as "trace nothing" — or, as this used to, as "trace everything" in
|
|
895
|
+
* defiance of a configuration that said otherwise — silently ignores what
|
|
896
|
+
* was configured. One rule for every list flag, so `--exclude ""` cannot
|
|
897
|
+
* mean something `--directories ""` does not.
|
|
898
|
+
*/
|
|
899
|
+
private resolveList;
|
|
900
|
+
/**
|
|
901
|
+
* Reads one switch flag into the boolean it names.
|
|
902
|
+
*
|
|
903
|
+
* Anything but `true` or `false` is refused rather than coerced, for the
|
|
904
|
+
* reason `--format` is: a typo read as either answer changes what the run
|
|
905
|
+
* traces while looking like it was obeyed.
|
|
906
|
+
*/
|
|
907
|
+
private resolveSwitch;
|
|
908
|
+
/** Applies the path flags to the destinations a run writes. */
|
|
909
|
+
private resolveWrite;
|
|
910
|
+
/**
|
|
911
|
+
* Resolves a whole command line against one configuration.
|
|
912
|
+
*
|
|
913
|
+
* Every complaint is collected rather than thrown at the first one, so a
|
|
914
|
+
* command line with two mistakes in it is two mistakes to fix rather than
|
|
915
|
+
* two runs. Nothing has been traced or written by the time this returns, so
|
|
916
|
+
* a caller that finds `errors` non-empty can refuse with the checkout
|
|
917
|
+
* untouched.
|
|
918
|
+
*/
|
|
919
|
+
resolveRunFlags(args: {
|
|
920
|
+
configuration: ResolvedCallidescopeConfiguration;
|
|
921
|
+
flags: CallidescopeRunFlags;
|
|
922
|
+
}): ResolvedRunFlags;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* Thrown when a command line cannot be turned into a run.
|
|
927
|
+
*
|
|
928
|
+
* One class rather than one per cause: every cause is the same event to
|
|
929
|
+
* whoever catches it — nothing was attempted, and the fix is to retype the
|
|
930
|
+
* flags. Only the wording varies, which is what the factories below do.
|
|
931
|
+
*
|
|
932
|
+
* Sits beside the constants rather than in an `input.errors.ts`, the way
|
|
933
|
+
* `UnknownConfigurationFileTypeError` sits in `configuration.constants.ts`.
|
|
934
|
+
*/
|
|
935
|
+
export declare class InputError extends Error {
|
|
936
|
+
constructor(message: string);
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* Parses CLI option values and asks for the ones a command still needs.
|
|
941
|
+
*
|
|
942
|
+
* Shared by `callidescope`, `depth`, and `breadth` so the parsing rules for
|
|
943
|
+
* flags they hold in common — `--config`, `--directories`, `--format` — are
|
|
944
|
+
* stated once rather than duplicated per command. Mirrors
|
|
945
|
+
* `@codependix/configuration`'s `InputService`.
|
|
946
|
+
*/
|
|
947
|
+
declare class InputService {
|
|
948
|
+
constructor();
|
|
949
|
+
/** Overridable so tests never touch a real terminal. */
|
|
950
|
+
private readonly promptRunner;
|
|
951
|
+
/**
|
|
952
|
+
* Refuses to draw a prompt nobody can answer.
|
|
953
|
+
*
|
|
954
|
+
* `prompts` does not fail on a non-terminal stdin — it renders the menu,
|
|
955
|
+
* never resolves, and lets the process exit 0, so a run that did nothing
|
|
956
|
+
* reads as one that succeeded.
|
|
957
|
+
*/
|
|
958
|
+
private assertCanPrompt;
|
|
959
|
+
/**
|
|
960
|
+
* Narrows a suggestion list to what has been typed so far.
|
|
961
|
+
*
|
|
962
|
+
* A method of its own rather than a closure inside the prompt, because this
|
|
963
|
+
* is the whole of the completion rule and it is worth stating — and testing
|
|
964
|
+
* — without a terminal anywhere near it.
|
|
965
|
+
*
|
|
966
|
+
* Matches on a substring rather than a prefix: a callable is addressed
|
|
967
|
+
* `<file>#<name>`, and the name is far more often what someone remembers
|
|
968
|
+
* than the path in front of it.
|
|
969
|
+
*/
|
|
970
|
+
completeSuggestions(args: {
|
|
971
|
+
input: string;
|
|
972
|
+
suggestions: readonly string[];
|
|
973
|
+
}): string[];
|
|
974
|
+
/**
|
|
975
|
+
* Whether anybody is there to answer a question.
|
|
976
|
+
*
|
|
977
|
+
* The one place this is decided, so the value that refuses to be asked for
|
|
978
|
+
* and the value that is merely offered cannot drift apart on what counts as
|
|
979
|
+
* a terminal. `isTTY` is read as falsy rather than coerced: `@types/node`
|
|
980
|
+
* calls it a `boolean` while it is `undefined` off a terminal, so lint
|
|
981
|
+
* rejects the coercion that would say so.
|
|
982
|
+
*
|
|
983
|
+
* Public so that `ConfigurationService.resolveFormatOption` can ask it: the
|
|
984
|
+
* facade owns the policy of whether to offer a prompt, and this class owns
|
|
985
|
+
* the question it is deciding on. Package-internal all the same — nothing
|
|
986
|
+
* outside this package can reach this class at all.
|
|
987
|
+
*/
|
|
988
|
+
isAtTerminal(): boolean;
|
|
989
|
+
/**
|
|
990
|
+
* Splits `--directories`, a comma-separated list of project directories.
|
|
991
|
+
*
|
|
992
|
+
* Kept relative rather than resolved here: each entry is later resolved
|
|
993
|
+
* against the workspace root, which is always the working directory, so
|
|
994
|
+
* resolving here as well would only make a relative entry ambiguous about
|
|
995
|
+
* which root it was ever relative to.
|
|
996
|
+
*/
|
|
997
|
+
parseCommaDelimitedOption(value: string | undefined): string[];
|
|
998
|
+
/** Trims an optional string option, treating blank as absent. */
|
|
999
|
+
parseOptionalOption(value: string | undefined): string | undefined;
|
|
1000
|
+
/**
|
|
1001
|
+
* Prompts for several values at once, completing the list as it is typed.
|
|
1002
|
+
*
|
|
1003
|
+
* The multiselect sibling of `promptForAutocomplete`, and it shares that
|
|
1004
|
+
* method's completion rule so a name typed here narrows the list the same
|
|
1005
|
+
* way it would there.
|
|
1006
|
+
*
|
|
1007
|
+
* Selecting nothing is refused rather than read as an empty list: the
|
|
1008
|
+
* caller asked because it needs at least one value, and `prompts` returns
|
|
1009
|
+
* `[]` both for a deliberate empty selection and for a prompt escaped out
|
|
1010
|
+
* of, which are the same thing to whoever has to act on it.
|
|
1011
|
+
*/
|
|
1012
|
+
promptForAutocompleteMultiselect(args: {
|
|
1013
|
+
message: string;
|
|
1014
|
+
subject: string;
|
|
1015
|
+
suggestions: readonly string[];
|
|
1016
|
+
}): Promise<string[]>;
|
|
1017
|
+
/** Prompts for one value out of a fixed set of choices. */
|
|
1018
|
+
promptForSelect<Choice extends string>(args: {
|
|
1019
|
+
choices: readonly Choice[];
|
|
1020
|
+
message: string;
|
|
1021
|
+
subject: string;
|
|
1022
|
+
}): Promise<Choice>;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
/** Arguments accepted by the configuration loader. */
|
|
1026
|
+
export declare interface LoadConfigurationArguments {
|
|
1027
|
+
configurationPath?: string | undefined;
|
|
1028
|
+
searchDirectory?: string | undefined;
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
/**
|
|
1032
|
+
* A resolved configuration, what the file itself declared, and which file it
|
|
1033
|
+
* was.
|
|
1034
|
+
*
|
|
1035
|
+
* Both objects are kept because they answer different questions. A refusal has
|
|
1036
|
+
* to name the fields the file set, which resolution would otherwise
|
|
1037
|
+
* manufacture; anything judging a project reads values only resolution
|
|
1038
|
+
* supplies. The path is what nothing downstream of the search can still tell,
|
|
1039
|
+
* and what keeps one file from being given two roles in a run.
|
|
1040
|
+
*/
|
|
1041
|
+
export declare interface LoadedCallidescopeConfiguration {
|
|
1042
|
+
/** The file's own object, before a single default was applied. */
|
|
1043
|
+
authored: CallidescopeConfiguration;
|
|
1044
|
+
configuration: ResolvedCallidescopeConfiguration;
|
|
1045
|
+
/** `undefined` when no configuration file was found at all. */
|
|
1046
|
+
path: string | undefined;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* What a load reports when the caller named the file, so a path is certain.
|
|
1051
|
+
*
|
|
1052
|
+
* The search may find nothing and legally say so; a named path either resolves
|
|
1053
|
+
* or refuses, and never comes back as `undefined`.
|
|
1054
|
+
*/
|
|
1055
|
+
export declare interface LoadedCallidescopeConfigurationFile extends LoadedCallidescopeConfiguration {
|
|
1056
|
+
path: string;
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
/** One project's own configuration file, and the project it configures. */
|
|
1060
|
+
export declare interface LoadedProjectConfiguration {
|
|
1061
|
+
/** The file's own object, before a single default was applied. */
|
|
1062
|
+
authored: CallidescopeConfiguration;
|
|
1063
|
+
configuration: ResolvedCallidescopeConfiguration;
|
|
1064
|
+
path: string;
|
|
1065
|
+
/** Workspace-relative root of the project the file sits at. */
|
|
1066
|
+
project: string;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
/** Arguments accepted by the project configuration loader. */
|
|
1070
|
+
export declare interface LoadProjectConfigurationsArguments {
|
|
1071
|
+
/** Workspace-relative project roots to look beside. */
|
|
1072
|
+
projects: readonly string[];
|
|
1073
|
+
/**
|
|
1074
|
+
* The file already loaded as the run's own workspace configuration, either
|
|
1075
|
+
* absolute or relative to `workspaceRoot` — resolved against that root, the
|
|
1076
|
+
* same way every project path here is, so the two are comparable by
|
|
1077
|
+
* construction rather than by convention.
|
|
1078
|
+
*
|
|
1079
|
+
* One file, one role per run: a configuration that a run was pointed at is
|
|
1080
|
+
* not additionally read as the configuration of whichever project happens to
|
|
1081
|
+
* hold it. A package whose Nx target names its own file is exactly that case,
|
|
1082
|
+
* and treating the file as both would refuse it for the workspace-only fields
|
|
1083
|
+
* it legitimately sets.
|
|
1084
|
+
*/
|
|
1085
|
+
workspaceConfigurationPath?: string | undefined;
|
|
1086
|
+
workspaceRoot: string;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
/** Splicing helpers handed to a configured `writeBlock` function. */
|
|
1090
|
+
export declare interface MarkdownAnchorHelpers {
|
|
1091
|
+
endMarker: string;
|
|
1092
|
+
startMarker: string;
|
|
1093
|
+
/**
|
|
1094
|
+
* Splices the anchored block into a file, appending it when the markers are
|
|
1095
|
+
* absent, and creating the file when it does not exist.
|
|
1096
|
+
*
|
|
1097
|
+
* In check mode nothing is written and the return value reports whether the
|
|
1098
|
+
* file already holds the current block. Defaults to the rendered content and
|
|
1099
|
+
* the configured path; pass either to override.
|
|
1100
|
+
*/
|
|
1101
|
+
syncAnchoredBlock: (overrides?: {
|
|
1102
|
+
content?: string | undefined;
|
|
1103
|
+
path?: string | undefined;
|
|
1104
|
+
}) => boolean;
|
|
1105
|
+
/** The content wrapped in the configured markers, ready to place anywhere. */
|
|
1106
|
+
wrapInAnchors: (content?: string) => string;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
/**
|
|
1110
|
+
* A required value that cannot be asked for, because stdin is not a terminal.
|
|
1111
|
+
*
|
|
1112
|
+
* `prompts` does not fail there — it draws its menu, never resolves, and the
|
|
1113
|
+
* process exits 0 having done nothing. This refuses to become that silent
|
|
1114
|
+
* green no-op.
|
|
1115
|
+
*/
|
|
1116
|
+
export declare const missingInputError: (subject: string) => InputError;
|
|
1117
|
+
|
|
1118
|
+
/**
|
|
1119
|
+
* What a lookup command line and its configuration resolved to.
|
|
1120
|
+
*
|
|
1121
|
+
* Everything a run resolves except the mode: `depth` and `breadth` never
|
|
1122
|
+
* write or compare a destination, so they have no `--check` or `--write` set
|
|
1123
|
+
* to select and nothing about one to reject.
|
|
1124
|
+
*/
|
|
1125
|
+
export declare interface PreparedLookup {
|
|
1126
|
+
readonly authoredLimits: CallidescopeLimits | undefined;
|
|
1127
|
+
/** The configuration, with the scope a `--directories` flag named applied. */
|
|
1128
|
+
readonly configuration: ResolvedCallidescopeConfiguration;
|
|
1129
|
+
readonly configurationPath: string | undefined;
|
|
1130
|
+
readonly format: CallidescopeOutputFormat;
|
|
1131
|
+
readonly workspaceRoot: string;
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
/** What a command line and its configuration resolved to. */
|
|
1135
|
+
export declare interface PreparedRun {
|
|
1136
|
+
/**
|
|
1137
|
+
* The limits the workspace file itself wrote down, exactly as authored.
|
|
1138
|
+
*
|
|
1139
|
+
* Carried beside the resolved configuration because resolution manufactures
|
|
1140
|
+
* a default for every limit, so only this can say which numbers that file
|
|
1141
|
+
* really chose — and the workspace row names a file only when one did.
|
|
1142
|
+
*/
|
|
1143
|
+
readonly authoredLimits: CallidescopeLimits | undefined;
|
|
1144
|
+
/**
|
|
1145
|
+
* The configuration every flag override has already been applied to.
|
|
1146
|
+
*
|
|
1147
|
+
* The scope a run traces and the destinations it writes are read from here
|
|
1148
|
+
* rather than from the options, so nothing downstream has to remember which
|
|
1149
|
+
* of a flag and a configured value won.
|
|
1150
|
+
*/
|
|
1151
|
+
readonly configuration: ResolvedCallidescopeConfiguration;
|
|
1152
|
+
/**
|
|
1153
|
+
* The file the configuration was read from, or `undefined` when the search
|
|
1154
|
+
* found none and the run is on the tool's defaults.
|
|
1155
|
+
*
|
|
1156
|
+
* The trace resolves a configuration beside every project it reaches, and
|
|
1157
|
+
* skips this one: a file a run was pointed at is already that run's workspace
|
|
1158
|
+
* configuration, and reading it again as a project's would refuse it for the
|
|
1159
|
+
* workspace-only fields it is entitled to set.
|
|
1160
|
+
*/
|
|
1161
|
+
readonly configurationPath: string | undefined;
|
|
1162
|
+
/**
|
|
1163
|
+
* What the run prints to standard output.
|
|
1164
|
+
*
|
|
1165
|
+
* A presentation choice a command line makes for this one invocation, never
|
|
1166
|
+
* a value a configuration file writes down.
|
|
1167
|
+
*/
|
|
1168
|
+
readonly format: CallidescopeOutputFormat;
|
|
1169
|
+
/**
|
|
1170
|
+
* The limits this command line overrode, if any.
|
|
1171
|
+
*
|
|
1172
|
+
* Carried past the resolved configuration because a limit is enforced per
|
|
1173
|
+
* project: each project's own file declares the number its gate reads, so an
|
|
1174
|
+
* override left in the workspace's copy alone would be a flag no gate looks
|
|
1175
|
+
* at.
|
|
1176
|
+
*/
|
|
1177
|
+
readonly limitOverrides: CallidescopeLimitOverrides;
|
|
1178
|
+
readonly mode: RunMode;
|
|
1179
|
+
readonly workspaceRoot: string;
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
/**
|
|
1183
|
+
* Raised when a project's own configuration file cannot be read or parsed.
|
|
1184
|
+
*
|
|
1185
|
+
* Names the project rather than only the path, because a run resolves a file
|
|
1186
|
+
* per project and the failure has to say which one to go and fix. The original
|
|
1187
|
+
* failure is kept as `cause` so nothing a reader would need is thrown away.
|
|
1188
|
+
*/
|
|
1189
|
+
export declare class ProjectConfigurationError extends Error {
|
|
1190
|
+
constructor(args: {
|
|
1191
|
+
cause: unknown;
|
|
1192
|
+
configurationPath: string;
|
|
1193
|
+
project: string;
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
/**
|
|
1198
|
+
* Raised when a project's own configuration sets a field only the workspace
|
|
1199
|
+
* configuration may set.
|
|
1200
|
+
*
|
|
1201
|
+
* Names the project, the offending field, and the four fields a project
|
|
1202
|
+
* configuration may set, so the message is actionable without opening a
|
|
1203
|
+
* README.
|
|
1204
|
+
*/
|
|
1205
|
+
export declare class ProjectConfigurationFieldNotPermittedError extends Error {
|
|
1206
|
+
constructor(args: {
|
|
1207
|
+
field: string;
|
|
1208
|
+
project: string;
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/**
|
|
1213
|
+
* Raised when a traced project's configuration leaves a field out.
|
|
1214
|
+
*
|
|
1215
|
+
* Names the field as a reader has to type it to fix the file — `write.mermaid`
|
|
1216
|
+
* rather than `write` — and points at the spread that supplies every field a
|
|
1217
|
+
* project has no opinion about, because the fix is almost always that one line
|
|
1218
|
+
* rather than a field written out by hand.
|
|
1219
|
+
*/
|
|
1220
|
+
export declare class ProjectConfigurationIncompleteError extends Error {
|
|
1221
|
+
constructor(args: {
|
|
1222
|
+
field: string;
|
|
1223
|
+
project: string;
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
/**
|
|
1228
|
+
* Raised when a traced project has no configuration file at all.
|
|
1229
|
+
*
|
|
1230
|
+
* A project that is traced is judged, and what it is judged by is written in
|
|
1231
|
+
* its own file or nowhere. Inheriting everything in silence is the arrangement
|
|
1232
|
+
* this replaces: it left a project's numbers resolvable only by reading two
|
|
1233
|
+
* files and knowing which one won.
|
|
1234
|
+
*/
|
|
1235
|
+
export declare class ProjectConfigurationMissingError extends Error {
|
|
1236
|
+
constructor(project: string);
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
/**
|
|
1240
|
+
* Resolves the configuration file sitting beside each traced project.
|
|
1241
|
+
*
|
|
1242
|
+
* Its own service rather than more of `ConfigurationFileService`, because the two
|
|
1243
|
+
* answer different questions: one loads the file a run was pointed at, and this
|
|
1244
|
+
* one asks which of a run's projects configure themselves. Every refusal a
|
|
1245
|
+
* project configuration can earn belongs here, where the project it names is
|
|
1246
|
+
* already in hand.
|
|
1247
|
+
*/
|
|
1248
|
+
declare class ProjectConfigurationService {
|
|
1249
|
+
constructor();
|
|
1250
|
+
/**
|
|
1251
|
+
* Refuses a project configuration that leaves any field out.
|
|
1252
|
+
*
|
|
1253
|
+
* Walked against `authored`, the file exactly as written, for the same reason
|
|
1254
|
+
* the permission check is: resolution manufactures every field for every
|
|
1255
|
+
* project, so asking the resolved object whether a field is missing can never
|
|
1256
|
+
* say yes.
|
|
1257
|
+
*/
|
|
1258
|
+
private assertComplete;
|
|
1259
|
+
/**
|
|
1260
|
+
* Refuses a project configuration that sets a field only the workspace
|
|
1261
|
+
* configuration may set.
|
|
1262
|
+
*/
|
|
1263
|
+
private assertNoForbiddenFields;
|
|
1264
|
+
/**
|
|
1265
|
+
* Reads the limits one project's own configuration declares.
|
|
1266
|
+
*
|
|
1267
|
+
* The whole object comes from that one file, because completeness means both
|
|
1268
|
+
* numbers were written in it. There is nothing left to fall back to and
|
|
1269
|
+
* nothing to fall back per field: a project that declared no breadth limit
|
|
1270
|
+
* wrote `maximumBreadth: undefined`, which is a decision rather than a gap.
|
|
1271
|
+
*/
|
|
1272
|
+
private buildProjectLimits;
|
|
1273
|
+
/**
|
|
1274
|
+
* Reads the limits the workspace file itself declares.
|
|
1275
|
+
*
|
|
1276
|
+
* These are the numbers `projectDefaults` carries into every project's file,
|
|
1277
|
+
* and the ones the directory holding the workspace configuration is judged
|
|
1278
|
+
* by — that being the one project which cannot write a file of its own.
|
|
1279
|
+
*
|
|
1280
|
+
* The file is named only when it really wrote a limit. `maximumDepth` is
|
|
1281
|
+
* defaulted during resolution, so a path stamped unconditionally would name a
|
|
1282
|
+
* file for a number that file never mentions.
|
|
1283
|
+
*/
|
|
1284
|
+
private buildWorkspaceLimits;
|
|
1285
|
+
/**
|
|
1286
|
+
* Finds the first field a project's own configuration sets that only the
|
|
1287
|
+
* workspace configuration may set.
|
|
1288
|
+
*
|
|
1289
|
+
* Checked against `authored`, the file exactly as written, never against the
|
|
1290
|
+
* resolved configuration: resolution manufactures every field for every
|
|
1291
|
+
* project, so asking the resolved object whether it "has" a field can never
|
|
1292
|
+
* say no.
|
|
1293
|
+
*
|
|
1294
|
+
* The file's own fields are walked and each is asked whether it is
|
|
1295
|
+
* permitted, rather than a list of forbidden ones being looked for. That is
|
|
1296
|
+
* what makes the check fail closed: a field nothing classifies — a tenth one
|
|
1297
|
+
* added upstream, a name somebody misspelled — is refused by name instead of
|
|
1298
|
+
* being accepted and then quietly doing nothing.
|
|
1299
|
+
*/
|
|
1300
|
+
private findForbiddenField;
|
|
1301
|
+
/**
|
|
1302
|
+
* Finds the first member a project set inside a field classified one member
|
|
1303
|
+
* at a time.
|
|
1304
|
+
*
|
|
1305
|
+
* The dotted name is what comes back — `write.json` rather than `write` —
|
|
1306
|
+
* because the field alone would send a reader to delete a block half of
|
|
1307
|
+
* which they are entitled to keep.
|
|
1308
|
+
*
|
|
1309
|
+
* A value that is not an object at all is refused under the field's own
|
|
1310
|
+
* name. The schema has already rejected every such file by the time this
|
|
1311
|
+
* runs, so this is the guard that makes the walk total rather than a branch
|
|
1312
|
+
* with a story behind it.
|
|
1313
|
+
*/
|
|
1314
|
+
private findForbiddenMember;
|
|
1315
|
+
/**
|
|
1316
|
+
* Finds the first name a project's configuration leaves out.
|
|
1317
|
+
*
|
|
1318
|
+
* A field is checked for presence rather than for a value, so a project
|
|
1319
|
+
* writing `maximumBreadth: undefined` or `mermaid: undefined` has spoken.
|
|
1320
|
+
* Those two are the whole reason presence and value are kept apart: each is a
|
|
1321
|
+
* project saying it gates no breadth, or publishes no diagram, and an absent
|
|
1322
|
+
* field could never distinguish either from a project that forgot.
|
|
1323
|
+
*
|
|
1324
|
+
* A field present but not an object is reported under its own name, which is
|
|
1325
|
+
* unreachable through the schema and is what makes the walk total.
|
|
1326
|
+
*/
|
|
1327
|
+
private findMissingField;
|
|
1328
|
+
/**
|
|
1329
|
+
* Reads one project's configuration file.
|
|
1330
|
+
*
|
|
1331
|
+
* Every failure the read can produce — a file nothing can parse, a shape the
|
|
1332
|
+
* schema rejects — is rethrown naming the project, because a run resolves a
|
|
1333
|
+
* file per project and a bare parse error says nothing about which one to go
|
|
1334
|
+
* and fix.
|
|
1335
|
+
*/
|
|
1336
|
+
private loadProjectConfiguration;
|
|
1337
|
+
/**
|
|
1338
|
+
* Applies one command-line limit override to one project's declared limit.
|
|
1339
|
+
*
|
|
1340
|
+
* The precedence rule, at the level a limit is actually enforced: a project
|
|
1341
|
+
* that declared the limit is judged by the flag instead, and a project that
|
|
1342
|
+
* declared none keeps no limit at all. A flag may override what a project chose
|
|
1343
|
+
* and may not choose for a project that chose nothing — which for breadth is
|
|
1344
|
+
* the whole difference between a run `--check breadth` can gate and one it
|
|
1345
|
+
* refuses.
|
|
1346
|
+
*/
|
|
1347
|
+
private overrideLimit;
|
|
1348
|
+
/** The name of a whole field a project may not set, or nothing when it may. */
|
|
1349
|
+
private readForbiddenField;
|
|
1350
|
+
/**
|
|
1351
|
+
* Resolves the configuration file sitting at each project's own root — the
|
|
1352
|
+
* directory holding the `tsconfig.json` that makes it a project.
|
|
1353
|
+
*
|
|
1354
|
+
* A traced project with no file of its own is refused. That is the whole
|
|
1355
|
+
* point of the arrangement: what a project is judged by is written in that
|
|
1356
|
+
* project's own file, so a project with no file has nothing written down and
|
|
1357
|
+
* a reader has no second file to go and resolve it against.
|
|
1358
|
+
*
|
|
1359
|
+
* The file must also be complete — every field present, `undefined` written
|
|
1360
|
+
* where a project means to publish nothing or gate nothing. A project spreads
|
|
1361
|
+
* the workspace's `projectDefaults` to get there in one line, which is what
|
|
1362
|
+
* makes completeness cheap enough to require. What it may **not** spread is
|
|
1363
|
+
* the workspace configuration itself: that object carries fields only the
|
|
1364
|
+
* workspace may set, and `findForbiddenField` below refuses the file for the
|
|
1365
|
+
* first one it finds.
|
|
1366
|
+
*
|
|
1367
|
+
* The file a run was pointed at is skipped, and the project holding it is
|
|
1368
|
+
* exempt from the two rules above, because that file is already serving as
|
|
1369
|
+
* the run's workspace configuration. One file, one role per run — reading it
|
|
1370
|
+
* a second time as a project's would refuse it for the workspace-only fields
|
|
1371
|
+
* it legitimately sets, and no second file can sit beside it under a name
|
|
1372
|
+
* discovery would find. That project is judged by the workspace's own limits,
|
|
1373
|
+
* which `resolveLimits` reports for it.
|
|
1374
|
+
*/
|
|
1375
|
+
loadProjectConfigurations(args: LoadProjectConfigurationsArguments, reader: ConfigurationFileReader): Promise<LoadedProjectConfiguration[]>;
|
|
1376
|
+
/**
|
|
1377
|
+
* Resolves the depth and breadth limits every traced project is judged
|
|
1378
|
+
* against, each carrying the file its number was written in.
|
|
1379
|
+
*
|
|
1380
|
+
* Every number comes from the project's own file, because loading refuses a
|
|
1381
|
+
* project whose file is absent or incomplete. Nothing is inherited and
|
|
1382
|
+
* nothing is merged — the workspace's numbers reach a project by being
|
|
1383
|
+
* spread into its file, where a reader can see them, rather than by being
|
|
1384
|
+
* resolved behind one.
|
|
1385
|
+
*
|
|
1386
|
+
* The one project handed the workspace's own limits is the directory holding
|
|
1387
|
+
* the workspace configuration, which cannot write a second file under a name
|
|
1388
|
+
* discovery would find.
|
|
1389
|
+
*
|
|
1390
|
+
* One resolver rather than one per reader. A gate and a listing that each
|
|
1391
|
+
* worked this out for themselves could disagree about the same number, and a
|
|
1392
|
+
* limit two answers can be given for is worse than no limit.
|
|
1393
|
+
*/
|
|
1394
|
+
resolveLimits(args: ResolveProjectLimitsArguments): ProjectLimitsLookup;
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
/** Whether a project's own configuration may set one field, or one member. */
|
|
1398
|
+
export declare type ProjectFieldPermission = "forbidden" | "permitted";
|
|
1399
|
+
|
|
1400
|
+
/**
|
|
1401
|
+
* The two limits one project is gated by, and the file both were written in.
|
|
1402
|
+
*
|
|
1403
|
+
* Only depth and breadth: every other limit shapes how the call graph itself is
|
|
1404
|
+
* built, which has to stay one answer for the whole workspace.
|
|
1405
|
+
*
|
|
1406
|
+
* One `path` for the pair rather than one apiece, because there is only one
|
|
1407
|
+
* file left for either to have come from. Every traced project's configuration
|
|
1408
|
+
* is complete, so both numbers are written in that project's own file or the
|
|
1409
|
+
* file is refused — there is no longer a state in which a project took one
|
|
1410
|
+
* limit from itself and the other from somewhere else.
|
|
1411
|
+
*/
|
|
1412
|
+
export declare interface ProjectLimits {
|
|
1413
|
+
/** Absent when the project declared no breadth limit, which most do not. */
|
|
1414
|
+
maximumBreadth: number | undefined;
|
|
1415
|
+
maximumDepth: number;
|
|
1416
|
+
/**
|
|
1417
|
+
* The file both numbers were written in.
|
|
1418
|
+
*
|
|
1419
|
+
* Absent only on a workspace row a file never wrote: `maximumDepth` is
|
|
1420
|
+
* defaulted during resolution, so a path stamped unconditionally would name
|
|
1421
|
+
* a file for a number that file never mentions.
|
|
1422
|
+
*/
|
|
1423
|
+
path: string | undefined;
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
/**
|
|
1427
|
+
* The limits every traced project is judged against.
|
|
1428
|
+
*
|
|
1429
|
+
* `byProject` holds an entry for every project a run reached, so a caller
|
|
1430
|
+
* listing the workspace's limits reads this and nothing else. `workspace` is
|
|
1431
|
+
* what the workspace file itself declares — the numbers `projectDefaults`
|
|
1432
|
+
* carries into each project's file, and the ones the directory holding that
|
|
1433
|
+
* very file is judged by, it being the one project that cannot write a
|
|
1434
|
+
* configuration of its own.
|
|
1435
|
+
*/
|
|
1436
|
+
export declare interface ProjectLimitsLookup {
|
|
1437
|
+
/** Keyed by workspace-relative project root. */
|
|
1438
|
+
byProject: ReadonlyMap<string, ProjectLimits>;
|
|
1439
|
+
workspace: ProjectLimits;
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
/**
|
|
1443
|
+
* A prompt someone dismissed without answering.
|
|
1444
|
+
*
|
|
1445
|
+
* Worded apart from a prompt that resolved to something unrecognized:
|
|
1446
|
+
* pressing escape is ordinary, and reporting it as a crash sends the reader
|
|
1447
|
+
* debugging for nothing.
|
|
1448
|
+
*/
|
|
1449
|
+
export declare const promptCancelledError: (subject: string) => InputError;
|
|
1450
|
+
|
|
1451
|
+
/** What a `render` function is handed. */
|
|
1452
|
+
export declare interface RenderMarkdownArguments {
|
|
1453
|
+
/** The configured description, for a renderer that wants to place it itself. */
|
|
1454
|
+
description: string | undefined;
|
|
1455
|
+
/**
|
|
1456
|
+
* The built-in table rendering of these same findings.
|
|
1457
|
+
*
|
|
1458
|
+
* Call it to add to the default report rather than replace it.
|
|
1459
|
+
*/
|
|
1460
|
+
renderTables: () => string;
|
|
1461
|
+
result: CallGraphResult;
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
/** Turns the traced findings into the markdown that will be written. */
|
|
1465
|
+
export declare type RenderMarkdownOutput = (args: RenderMarkdownArguments) => string;
|
|
1466
|
+
|
|
1467
|
+
/**
|
|
1468
|
+
* Files that mark a repository root.
|
|
1469
|
+
*
|
|
1470
|
+
* `package.json` is deliberately absent: every package in a workspace has one,
|
|
1471
|
+
* so it would stop the upward walk at the first project rather than the root.
|
|
1472
|
+
*/
|
|
1473
|
+
export declare const REPOSITORY_ROOT_MARKERS: readonly [".git", "pnpm-workspace.yaml"];
|
|
1474
|
+
|
|
1475
|
+
/**
|
|
1476
|
+
* Configuration with every default applied.
|
|
1477
|
+
*
|
|
1478
|
+
* Consumers read this shape rather than the authored one, so no analyzer has to
|
|
1479
|
+
* know which fields a configuration file may omit.
|
|
1480
|
+
*/
|
|
1481
|
+
export declare interface ResolvedCallidescopeConfiguration {
|
|
1482
|
+
directories: string[];
|
|
1483
|
+
entryPoints: ResolvedCallidescopeEntryPoints;
|
|
1484
|
+
exclude: string[];
|
|
1485
|
+
excludeCallees: string[];
|
|
1486
|
+
excludeFrom: string[];
|
|
1487
|
+
limits: ResolvedCallidescopeLimits;
|
|
1488
|
+
write: ResolvedCallidescopeWriteConfiguration;
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
/** Entry-point rules with defaults applied. */
|
|
1492
|
+
export declare interface ResolvedCallidescopeEntryPoints {
|
|
1493
|
+
addresses: string[];
|
|
1494
|
+
decorators: string[];
|
|
1495
|
+
includeExportedFunctions: boolean;
|
|
1496
|
+
includeOrphans: boolean;
|
|
1497
|
+
includeTests: boolean;
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
/** JSON output destination with defaults applied. */
|
|
1501
|
+
export declare interface ResolvedCallidescopeJsonOutputConfiguration {
|
|
1502
|
+
indentation: number;
|
|
1503
|
+
path: string;
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
/** Thresholds with defaults applied. */
|
|
1507
|
+
export declare interface ResolvedCallidescopeLimits {
|
|
1508
|
+
/**
|
|
1509
|
+
* Distinct callables a callable may call directly before it is reported.
|
|
1510
|
+
*
|
|
1511
|
+
* Stays optional even after resolution: unlike every other limit, this one
|
|
1512
|
+
* has no default, so its absence is a fact a `--check breadth` run must act
|
|
1513
|
+
* on rather than something resolution can paper over.
|
|
1514
|
+
*/
|
|
1515
|
+
maximumBreadth?: number | undefined;
|
|
1516
|
+
maximumDepth: number;
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
/**
|
|
1520
|
+
* Markdown output destination with defaults applied.
|
|
1521
|
+
*
|
|
1522
|
+
* `render` and `writeBlock` stay `undefined` when the configuration supplies
|
|
1523
|
+
* neither: the built-in implementations live in the CLI that calls them, so
|
|
1524
|
+
* "unset" is what selects them rather than a default named here.
|
|
1525
|
+
*/
|
|
1526
|
+
export declare interface ResolvedCallidescopeMarkdownOutputConfiguration {
|
|
1527
|
+
description: string | undefined;
|
|
1528
|
+
endMarker: string;
|
|
1529
|
+
heading: string;
|
|
1530
|
+
path: string;
|
|
1531
|
+
previewCount: number;
|
|
1532
|
+
render: RenderMarkdownOutput | undefined;
|
|
1533
|
+
startMarker: string;
|
|
1534
|
+
writeBlock: undefined | WriteMarkdownOutput;
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
/**
|
|
1538
|
+
* Output destinations with defaults applied.
|
|
1539
|
+
*
|
|
1540
|
+
* Both stay `undefined` when unconfigured, which is the normal case: a run that
|
|
1541
|
+
* names no destination reports to the console and exits on violations, so
|
|
1542
|
+
* nothing it writes can go stale.
|
|
1543
|
+
*/
|
|
1544
|
+
export declare interface ResolvedCallidescopeWriteConfiguration {
|
|
1545
|
+
json: ResolvedCallidescopeJsonOutputConfiguration | undefined;
|
|
1546
|
+
markdown: ResolvedCallidescopeMarkdownOutputConfiguration | undefined;
|
|
1547
|
+
mermaid: ResolvedCallidescopeMarkdownOutputConfiguration | undefined;
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
/** What a command line and the configuration it was resolved against produced. */
|
|
1551
|
+
export declare interface ResolvedRunFlags {
|
|
1552
|
+
/**
|
|
1553
|
+
* The configuration every override has been applied to.
|
|
1554
|
+
*
|
|
1555
|
+
* The scope and the destinations a run acts on are read from here rather
|
|
1556
|
+
* than from the flags, so nothing downstream has to remember which of the
|
|
1557
|
+
* two won.
|
|
1558
|
+
*/
|
|
1559
|
+
readonly configuration: ResolvedCallidescopeConfiguration;
|
|
1560
|
+
/**
|
|
1561
|
+
* Every reason the command line could not be resolved, collected rather
|
|
1562
|
+
* than thrown one at a time, so a command line with two mistakes in it is
|
|
1563
|
+
* two mistakes to fix rather than two runs.
|
|
1564
|
+
*/
|
|
1565
|
+
readonly errors: readonly string[];
|
|
1566
|
+
/** What the run prints. The default whenever the flag was left off. */
|
|
1567
|
+
readonly format: CallidescopeOutputFormat;
|
|
1568
|
+
/**
|
|
1569
|
+
* The limits a flag chose, and only those.
|
|
1570
|
+
*
|
|
1571
|
+
* Carried beside the configuration rather than only inside it because a
|
|
1572
|
+
* limit is enforced per project: each project's own file declares the number
|
|
1573
|
+
* its gate reads, so an override applied only to the workspace's copy would
|
|
1574
|
+
* be a flag no gate ever looks at. Empty whenever no limit flag was given.
|
|
1575
|
+
*/
|
|
1576
|
+
readonly limitOverrides: CallidescopeLimitOverrides;
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
/** Arguments accepted by the per-project limit resolver. */
|
|
1580
|
+
export declare interface ResolveProjectLimitsArguments {
|
|
1581
|
+
/**
|
|
1582
|
+
* The limits this run's command line overrode, if any.
|
|
1583
|
+
*
|
|
1584
|
+
* Applied to every project that declared the limit being overridden, because
|
|
1585
|
+
* a project's own number is the one its gate reads — an override that stopped
|
|
1586
|
+
* at the workspace file would be a flag that changed nothing any gate looks
|
|
1587
|
+
* at. A project that declared no breadth limit is left without one: the flag
|
|
1588
|
+
* overrides, and never supplies.
|
|
1589
|
+
*/
|
|
1590
|
+
limitOverrides?: CallidescopeLimitOverrides | undefined;
|
|
1591
|
+
/** The configuration files projects declared for themselves. */
|
|
1592
|
+
projectConfigurations: readonly LoadedProjectConfiguration[];
|
|
1593
|
+
/** Workspace-relative root of every project the run reached. */
|
|
1594
|
+
projects: readonly string[];
|
|
1595
|
+
/**
|
|
1596
|
+
* The limits the workspace file itself wrote down, exactly as authored.
|
|
1597
|
+
*
|
|
1598
|
+
* Presence is what decides whether the workspace row names a file: the
|
|
1599
|
+
* resolved configuration below manufactures `maximumDepth` for every run, so
|
|
1600
|
+
* a path stamped from it alone would name a file for a number that file
|
|
1601
|
+
* never wrote.
|
|
1602
|
+
*/
|
|
1603
|
+
workspaceAuthoredLimits: CallidescopeLimits | undefined;
|
|
1604
|
+
/** The run's own configuration, which the workspace row reads its numbers from. */
|
|
1605
|
+
workspaceConfiguration: ResolvedCallidescopeConfiguration;
|
|
1606
|
+
/** The file that configuration was read from, when one was found. */
|
|
1607
|
+
workspaceConfigurationPath: string | undefined;
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
/**
|
|
1611
|
+
* What the run does with what it traces.
|
|
1612
|
+
*
|
|
1613
|
+
* The four are independent. Writing gates on `writes` alone, staleness on
|
|
1614
|
+
* `checksReports` alone, a stack that is too deep on `checksDepth` alone, and
|
|
1615
|
+
* a callable calling too many things on `checksBreadth` alone, so no flag
|
|
1616
|
+
* ever quietly turns another one on.
|
|
1617
|
+
*/
|
|
1618
|
+
export declare interface RunMode {
|
|
1619
|
+
readonly checksBreadth: boolean;
|
|
1620
|
+
readonly checksDepth: boolean;
|
|
1621
|
+
readonly checksReports: boolean;
|
|
1622
|
+
readonly writes: boolean;
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
/**
|
|
1626
|
+
* What the command line asked the run to do, and what it could not make sense of.
|
|
1627
|
+
*
|
|
1628
|
+
* Every complaint is collected before any of them is reported, so a command
|
|
1629
|
+
* line with two mistakes in it is two mistakes to fix rather than two runs.
|
|
1630
|
+
*/
|
|
1631
|
+
declare interface RunModeSelection {
|
|
1632
|
+
readonly errors: readonly string[];
|
|
1633
|
+
readonly mode: RunMode;
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
/**
|
|
1637
|
+
* Reads a command line and its configuration into what the run will do.
|
|
1638
|
+
*
|
|
1639
|
+
* A collaborator rather than more of `ConfigurationService`, for the reason
|
|
1640
|
+
* every other one here is: resolving flags against a loaded file is its own
|
|
1641
|
+
* job, with its own vocabulary of checks and destinations, and a facade that
|
|
1642
|
+
* implemented it would be a facade in name only. What the layer publishes is
|
|
1643
|
+
* still one object — `ConfigurationService` fronts this the same way it
|
|
1644
|
+
* fronts the file loader, the project loader, and prompting.
|
|
1645
|
+
*
|
|
1646
|
+
* The file read arrives as an argument rather than an injected collaborator,
|
|
1647
|
+
* and the facade hands over itself. That is what keeps the whole layer
|
|
1648
|
+
* replaceable by a double at its one public object: a caller that stubs
|
|
1649
|
+
* `ConfigurationService.loadConfigurationFile` has stubbed what a run plan
|
|
1650
|
+
* reads, rather than only what it would have read by asking the facade
|
|
1651
|
+
* directly. It is a type-only import, so nothing points back at the facade at
|
|
1652
|
+
* module level.
|
|
1653
|
+
*/
|
|
1654
|
+
declare class RunPlanService {
|
|
1655
|
+
private readonly flagResolutionService;
|
|
1656
|
+
constructor(flagResolutionService: FlagResolutionService);
|
|
1657
|
+
/** States what `--check` accepts, in front of whatever went wrong. */
|
|
1658
|
+
private describeAcceptedCheckNames;
|
|
1659
|
+
/**
|
|
1660
|
+
* Reads the `--check` value into the set of things the run fails on.
|
|
1661
|
+
*
|
|
1662
|
+
* A flag passed without a value arrives as `true` and is a mistake rather
|
|
1663
|
+
* than a shorthand: it used to mean "fail on a deep stack and on a stale
|
|
1664
|
+
* report at once", and a set with nothing in it looks exactly like the flag
|
|
1665
|
+
* having been left off.
|
|
1666
|
+
*/
|
|
1667
|
+
private readCheckNames;
|
|
1668
|
+
/** Keeps the names `--check` knows and complains about the rest. */
|
|
1669
|
+
private validateCheckNames;
|
|
1670
|
+
/**
|
|
1671
|
+
* Reads `depth` and `breadth`'s scoping flags into a workspace root and a
|
|
1672
|
+
* resolved configuration, with no `--check`/`--write` mode to select.
|
|
1673
|
+
*
|
|
1674
|
+
* A lookup command never writes or compares a destination, so it has no
|
|
1675
|
+
* mode to reject in the first place — only the workspace to trace and the
|
|
1676
|
+
* format to print in, both of which every run already resolves the same
|
|
1677
|
+
* way `prepareRun` does.
|
|
1678
|
+
*
|
|
1679
|
+
* A refused command line is thrown rather than returned: unlike a run,
|
|
1680
|
+
* every caller here needs the resolved workspace to do anything at all, so
|
|
1681
|
+
* there is no half-prepared lookup to hand back. `InputError` is the class
|
|
1682
|
+
* every command already reports as a rejected command line.
|
|
1683
|
+
*/
|
|
1684
|
+
prepareLookup(options: AddressCommandOptions, reader: ConfigurationFileReader): Promise<PreparedLookup>;
|
|
1685
|
+
/**
|
|
1686
|
+
* Reads the command line and configuration into what the run will do.
|
|
1687
|
+
*
|
|
1688
|
+
* Hands back whatever could not be made sense of rather than reporting it:
|
|
1689
|
+
* two gates can refuse — what `--check` and `--write` mean together, decided
|
|
1690
|
+
* from the command line alone, and whether a destination flag has anything
|
|
1691
|
+
* to override, which needs the configuration loaded first — and both belong
|
|
1692
|
+
* to the host to say out loud, under one headline.
|
|
1693
|
+
*/
|
|
1694
|
+
prepareRun(options: CallidescopeCommandOptions, reader: ConfigurationFileReader): Promise<RunPreparation>;
|
|
1695
|
+
/**
|
|
1696
|
+
* Reads the flags into what the run writes and what it fails on.
|
|
1697
|
+
*
|
|
1698
|
+
* `--write --check reports` is refused rather than obeyed: nothing can be
|
|
1699
|
+
* stale immediately after being written, so a run asking for both has
|
|
1700
|
+
* misunderstood one of them and would pass whatever it was meant to catch.
|
|
1701
|
+
*/
|
|
1702
|
+
selectMode(options: CallidescopeCommandOptions): RunModeSelection;
|
|
1703
|
+
/**
|
|
1704
|
+
* Whether a run reads or rewrites the files its reports live in.
|
|
1705
|
+
*
|
|
1706
|
+
* A run that neither writes nor compares leaves every destination alone: it
|
|
1707
|
+
* prints what it traced and nothing else. That is what makes a bare run safe
|
|
1708
|
+
* to use at a prompt inside somebody's checkout.
|
|
1709
|
+
*/
|
|
1710
|
+
touchesFiles(mode: RunMode): boolean;
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
/**
|
|
1714
|
+
* What one command line resolved to, and what could not be made sense of.
|
|
1715
|
+
*
|
|
1716
|
+
* Both together rather than one or the other, because refusing is the host's
|
|
1717
|
+
* act rather than this layer's: resolving a run is deciding what it would do,
|
|
1718
|
+
* and saying so on a terminal is what the command-line host is for. Every
|
|
1719
|
+
* complaint is collected before any of them is reported, so a command line
|
|
1720
|
+
* with two mistakes in it is two mistakes to fix rather than two runs.
|
|
1721
|
+
*/
|
|
1722
|
+
export declare interface RunPreparation {
|
|
1723
|
+
readonly errors: readonly string[];
|
|
1724
|
+
/** Absent exactly when `errors` is not empty. */
|
|
1725
|
+
readonly run: PreparedRun | undefined;
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
/** Extensions the configuration loader knows how to read. */
|
|
1729
|
+
export declare const SUPPORTED_CONFIGURATION_EXTENSIONS: Set<string>;
|
|
1730
|
+
|
|
1731
|
+
/** Raised when a configuration file has an extension nothing can read. */
|
|
1732
|
+
export declare class UnknownConfigurationFileTypeError extends Error {
|
|
1733
|
+
constructor(filePath: string);
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
/** What a `writeBlock` function is handed. */
|
|
1737
|
+
export declare interface WriteMarkdownArguments {
|
|
1738
|
+
/** True when nothing may be written and staleness is the only question. */
|
|
1739
|
+
check: boolean;
|
|
1740
|
+
/** The rendered markdown, before any anchoring. */
|
|
1741
|
+
content: string;
|
|
1742
|
+
helpers: MarkdownAnchorHelpers;
|
|
1743
|
+
path: string | undefined;
|
|
1744
|
+
result: CallGraphResult;
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
/**
|
|
1748
|
+
* Decides which file the rendered markdown lands in, and how.
|
|
1749
|
+
*
|
|
1750
|
+
* Return `false` to report the destination as stale — in check mode that is
|
|
1751
|
+
* what fails the command. Anything else counts as up to date.
|
|
1752
|
+
*/
|
|
1753
|
+
export declare type WriteMarkdownOutput = (args: WriteMarkdownArguments) => boolean;
|
|
1754
|
+
|
|
1755
|
+
export { }
|