@callidescope/nx 0.0.1
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 +1041 -0
- package/dist/address.utilities-DJG3-xMW.js +20 -0
- package/dist/plugin-context.utilities-bBTXF3Wk.js +815 -0
- package/dist/plugin.utilities-CX_Q5t8_.js +18 -0
- package/dist/src/executors/breadth/executor.d.ts +34 -0
- package/dist/src/executors/breadth/executor.js +11 -0
- package/dist/src/executors/depth/executor.d.ts +34 -0
- package/dist/src/executors/depth/executor.js +11 -0
- package/dist/src/executors/gate/executor.d.ts +37 -0
- package/dist/src/executors/gate/executor.js +20 -0
- package/dist/src/executors/trace/executor.d.ts +33 -0
- package/dist/src/executors/trace/executor.js +21 -0
- package/dist/src/index.d.ts +698 -0
- package/dist/src/index.js +19 -0
- package/executors.json +25 -0
- package/package.json +78 -0
|
@@ -0,0 +1,698 @@
|
|
|
1
|
+
import { AddressDepthService } from '@callidescope/graph';
|
|
2
|
+
import { AddressLookupService } from '@callidescope/cli';
|
|
3
|
+
import { AddressReportService } from '@callidescope/output';
|
|
4
|
+
import { BreadthService } from '@callidescope/graph';
|
|
5
|
+
import { CallidescopeOutputFormat } from '@callidescope/configuration';
|
|
6
|
+
import { CallidescopeService } from '@callidescope/cli';
|
|
7
|
+
import { ConfigurationService } from '@callidescope/configuration';
|
|
8
|
+
import { CreateNodes } from '@nx/devkit';
|
|
9
|
+
import { FileFilterService } from '@callidescope/graph';
|
|
10
|
+
import { MarkdownReportService } from '@callidescope/output';
|
|
11
|
+
import { ProjectGraph } from '@nx/devkit';
|
|
12
|
+
import { ProjectReportsService } from '@callidescope/output';
|
|
13
|
+
import { ResolvedCallidescopeConfiguration } from '@callidescope/configuration';
|
|
14
|
+
|
|
15
|
+
/** Provides the `depth` and `breadth` lookups the executors run. */
|
|
16
|
+
export declare class AddressModule {
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Answers `depth` and `breadth` about the callables it is named, inside a
|
|
21
|
+
* resolved selection of Nx projects.
|
|
22
|
+
*
|
|
23
|
+
* The lookup itself is callidescope's — this only decides what it is asked
|
|
24
|
+
* about. What the plugin adds is the scope: the CLI resolves an address
|
|
25
|
+
* against the whole workspace, while here it is resolved against one project
|
|
26
|
+
* and its Nx dependencies, which is both faster and the set the address
|
|
27
|
+
* actually belongs to.
|
|
28
|
+
*/
|
|
29
|
+
export declare class AddressService {
|
|
30
|
+
private readonly addressLookupService;
|
|
31
|
+
private readonly addressReportService;
|
|
32
|
+
private readonly addressDepthService;
|
|
33
|
+
private readonly breadthService;
|
|
34
|
+
constructor(addressLookupService: AddressLookupService, addressReportService: AddressReportService, addressDepthService: AddressDepthService, breadthService: BreadthService);
|
|
35
|
+
/**
|
|
36
|
+
* Matches one address against an already-traced selection, or explains why
|
|
37
|
+
* it could not be.
|
|
38
|
+
*
|
|
39
|
+
* The explanation is returned rather than logged: an executor's product is
|
|
40
|
+
* what it writes to stdout, and a reader looking at a failed task needs the
|
|
41
|
+
* reason in the same place the report would have been.
|
|
42
|
+
*/
|
|
43
|
+
private identify;
|
|
44
|
+
/**
|
|
45
|
+
* Traces the selection, then matches every address against it.
|
|
46
|
+
*
|
|
47
|
+
* All or nothing, the way the command line is: a task that printed the
|
|
48
|
+
* addresses it understood and skipped the rest would report a partial
|
|
49
|
+
* answer under a `success` nobody asked it to qualify.
|
|
50
|
+
*/
|
|
51
|
+
private locate;
|
|
52
|
+
/** Prints each callable's direct callers and callees, side by side. */
|
|
53
|
+
runBreadth(args: LookupArguments): Promise<LookupResult>;
|
|
54
|
+
/** Prints every call stack above and below each callable. */
|
|
55
|
+
runDepth(args: LookupArguments): Promise<LookupResult>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Name this plugin is registered under in a workspace's `nx.json`. */
|
|
59
|
+
export declare const CALLIDESCOPE_NX_PLUGIN_NAME = "@callidescope/nx";
|
|
60
|
+
|
|
61
|
+
declare const callidescopePlugin: {
|
|
62
|
+
createNodes: CreateNodes;
|
|
63
|
+
name: string;
|
|
64
|
+
};
|
|
65
|
+
export default callidescopePlugin;
|
|
66
|
+
|
|
67
|
+
/** Options accepted from this plugin's `nx.json` registration. */
|
|
68
|
+
export declare interface CallidescopePluginOptions {
|
|
69
|
+
/** Name of the inferred per-project breadth-lookup target. */
|
|
70
|
+
readonly breadthTargetName: string;
|
|
71
|
+
/** Where the callidescope configuration lives, workspace-root relative. */
|
|
72
|
+
readonly configurationPath: string;
|
|
73
|
+
/** Name of the inferred per-project depth-lookup target. */
|
|
74
|
+
readonly depthTargetName: string;
|
|
75
|
+
/** Name of the inferred per-project gate target. */
|
|
76
|
+
readonly gateTargetName: string;
|
|
77
|
+
/** Name of the inferred per-project trace target. */
|
|
78
|
+
readonly traceTargetName: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Name of the inferred per-project breadth-lookup target. */
|
|
82
|
+
export declare const DEFAULT_BREADTH_TARGET_NAME = "breadth";
|
|
83
|
+
|
|
84
|
+
/** Name of the inferred per-project depth-lookup target. */
|
|
85
|
+
export declare const DEFAULT_DEPTH_TARGET_NAME = "depth";
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Name of the inferred per-project gate target.
|
|
89
|
+
*
|
|
90
|
+
* Named after what it decides rather than after what it measures. `trace`,
|
|
91
|
+
* `depth`, and `breadth` all print something a reader asked for; this one is
|
|
92
|
+
* the target here a pipeline is meant to read an exit code from, so it says
|
|
93
|
+
* `gate`.
|
|
94
|
+
*/
|
|
95
|
+
export declare const DEFAULT_GATE_TARGET_NAME = "gate";
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Names of the inferred per-project targets, when the registration names none.
|
|
99
|
+
*
|
|
100
|
+
* Short and unprefixed, so a run reads `nx run callidescope-nx:trace` rather
|
|
101
|
+
* than repeating the tool's name on both sides of the colon. Every one of them
|
|
102
|
+
* is overridable from the `nx.json` registration, which is the escape hatch
|
|
103
|
+
* for a workspace where a name this general would collide.
|
|
104
|
+
*/
|
|
105
|
+
export declare const DEFAULT_TRACE_TARGET_NAME = "trace";
|
|
106
|
+
|
|
107
|
+
/** A target this plugin infers onto a project. */
|
|
108
|
+
declare interface InferredTarget {
|
|
109
|
+
readonly cache: boolean;
|
|
110
|
+
readonly executor: string;
|
|
111
|
+
/** Files whose change must invalidate the cached result. */
|
|
112
|
+
readonly inputs?: string[];
|
|
113
|
+
readonly options: Record<string, unknown>;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** One project's inferred targets, keyed by target name. */
|
|
117
|
+
declare type InferredTargets = Record<string, InferredTarget>;
|
|
118
|
+
|
|
119
|
+
/** Arguments for inferring targets across every project in a workspace. */
|
|
120
|
+
declare interface InferTargetsArguments {
|
|
121
|
+
readonly options: unknown;
|
|
122
|
+
/** Every `project.json` Nx matched, workspace-root relative. */
|
|
123
|
+
readonly projectConfigurationFiles: readonly string[];
|
|
124
|
+
readonly workspaceRoot: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** A loaded configuration, beside the path the loader settled on. */
|
|
128
|
+
declare interface LoadedRunConfiguration {
|
|
129
|
+
readonly configuration: ResolvedCallidescopeConfiguration;
|
|
130
|
+
/**
|
|
131
|
+
* Where the configuration was read from, or nothing when none was found.
|
|
132
|
+
*
|
|
133
|
+
* The path the loader settled on rather than the one it was handed, since a
|
|
134
|
+
* search may have answered — and a run resolves a project's own
|
|
135
|
+
* configuration relative to it.
|
|
136
|
+
*/
|
|
137
|
+
readonly path: string | undefined;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Arguments for loading the configuration one run is judged by. */
|
|
141
|
+
declare interface LoadRunConfigurationArguments {
|
|
142
|
+
/** Resolved from this plugin's `nx.json` registration when omitted. */
|
|
143
|
+
readonly configurationPath?: string | undefined;
|
|
144
|
+
readonly workspaceRoot: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Arguments for looking callables up inside a resolved selection. */
|
|
148
|
+
export declare interface LookupArguments {
|
|
149
|
+
/** Each `<file>#<qualified-name>`, the form every callidescope stack prints. */
|
|
150
|
+
readonly addresses: readonly string[];
|
|
151
|
+
readonly configurationPath?: string | undefined;
|
|
152
|
+
/** Workspace-relative directories the lookup resolves the address against. */
|
|
153
|
+
readonly directories: readonly string[];
|
|
154
|
+
readonly format?: CallidescopeOutputFormat | undefined;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** What one lookup produced. */
|
|
158
|
+
export declare interface LookupResult {
|
|
159
|
+
/** False when any address named nothing the run traced. */
|
|
160
|
+
readonly ok: boolean;
|
|
161
|
+
/**
|
|
162
|
+
* The rendered report, or the reason every address that failed could not be
|
|
163
|
+
* resolved.
|
|
164
|
+
*/
|
|
165
|
+
readonly report: string;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Root module of the plugin's application context.
|
|
170
|
+
*
|
|
171
|
+
* Built once per process and cached — the Nx daemon is long-lived, so paying
|
|
172
|
+
* for a NestJS context on every inference or executor invocation would make
|
|
173
|
+
* this plugin the slowest thing in the graph.
|
|
174
|
+
*/
|
|
175
|
+
export declare class MainModule {
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* One Nx project, reduced to what a directory resolution needs of it.
|
|
180
|
+
*
|
|
181
|
+
* `codependix-nx-projects` declares a near-identical shape and reads it out of the
|
|
182
|
+
* graph the same way. They are deliberately not shared: the two packages sit
|
|
183
|
+
* in different toolchains, and `configuration/eslint.config.ts` lets this one
|
|
184
|
+
* depend on nothing but `logger` precisely so `@nx/devkit` cannot spread. A
|
|
185
|
+
* package extracted to hold both would have to be depended on by both, which
|
|
186
|
+
* is the coupling that rule exists to prevent.
|
|
187
|
+
*/
|
|
188
|
+
export declare interface NxProject {
|
|
189
|
+
readonly name: string;
|
|
190
|
+
/** Workspace-relative root, exactly as the Nx project graph states it. */
|
|
191
|
+
readonly root: string;
|
|
192
|
+
/** The tags `project.json` declares. Empty for a project declaring none. */
|
|
193
|
+
readonly tags: string[];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** Provides the reader for this plugin's `nx.json` registration. */
|
|
197
|
+
export declare class OptionsModule {
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Narrows the untyped options object Nx hands a plugin.
|
|
202
|
+
*
|
|
203
|
+
* Nx passes whatever the consumer wrote in `nx.json` with no validation, so
|
|
204
|
+
* every field is checked before use rather than cast. A bad value falls back
|
|
205
|
+
* to its default: a typo in a target name should not stop the project graph
|
|
206
|
+
* from being built.
|
|
207
|
+
*/
|
|
208
|
+
export declare class OptionsService {
|
|
209
|
+
constructor();
|
|
210
|
+
/** Narrows an untrusted value to an array without widening it to `any`. */
|
|
211
|
+
private isUnknownArray;
|
|
212
|
+
/** Reads one `nx.json` plugin entry, if it is this plugin's registration. */
|
|
213
|
+
private readEntryConfigurationPath;
|
|
214
|
+
/** Reads this plugin's `configurationPath` out of an `nx.json`, if it names one. */
|
|
215
|
+
private readRegisteredConfigurationPath;
|
|
216
|
+
/** Reads a string field from an untrusted record, or `undefined`. */
|
|
217
|
+
private readString;
|
|
218
|
+
/**
|
|
219
|
+
* Narrows an untrusted output format to one callidescope renders.
|
|
220
|
+
*
|
|
221
|
+
* A target written by hand in a `project.json` bypasses the executor's
|
|
222
|
+
* `schema.json` enum, so an unrecognized value falls back to whatever the
|
|
223
|
+
* configuration chose rather than reaching the renderer.
|
|
224
|
+
*/
|
|
225
|
+
readFormat(value: unknown): CallidescopeOutputFormat | undefined;
|
|
226
|
+
/**
|
|
227
|
+
* Reads a list of strings out of an executor's options.
|
|
228
|
+
*
|
|
229
|
+
* Nx validates an option against its `schema.json` before the executor sees
|
|
230
|
+
* it, but a target written by hand in a `project.json` reaches here
|
|
231
|
+
* unchecked, so a non-array or a list holding non-strings is narrowed rather
|
|
232
|
+
* than trusted. Entries are trimmed and the blanks dropped, so a trailing
|
|
233
|
+
* comma in `--projects a,b,` names two projects rather than three.
|
|
234
|
+
*/
|
|
235
|
+
readStringList(value: unknown): string[];
|
|
236
|
+
/**
|
|
237
|
+
* Resolves the configuration path a workspace means, without assuming one.
|
|
238
|
+
*
|
|
239
|
+
* Nx passes plugin options to `createNodes` and to executors, but not to
|
|
240
|
+
* anything run outside Nx, so a caller that has a filesystem resolves the
|
|
241
|
+
* path itself rather than assuming a workspace keeps its configuration at
|
|
242
|
+
* the root. `exists` is supplied by the caller because the callers do not
|
|
243
|
+
* agree on what a filesystem is.
|
|
244
|
+
*/
|
|
245
|
+
resolveConfigurationPath(args: {
|
|
246
|
+
exists: (candidatePath: string) => boolean;
|
|
247
|
+
nxConfiguration: unknown;
|
|
248
|
+
}): string;
|
|
249
|
+
/** Resolves the effective plugin options from an untrusted value. */
|
|
250
|
+
resolvePluginOptions(options: unknown): CallidescopePluginOptions;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** Provides target inference and the trace the executor runs. */
|
|
254
|
+
export declare class PluginModule {
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Everything this plugin does, behind one injectable.
|
|
259
|
+
*
|
|
260
|
+
* Nx calls plugins from module-level functions with no injection of their own,
|
|
261
|
+
* so the bare entry points in `index.ts` and the executor build nothing
|
|
262
|
+
* themselves — they resolve this service and hand it the arguments.
|
|
263
|
+
*/
|
|
264
|
+
export declare class PluginService {
|
|
265
|
+
private readonly callidescopeService;
|
|
266
|
+
private readonly configurationService;
|
|
267
|
+
private readonly fileFilterService;
|
|
268
|
+
private readonly markdownReportService;
|
|
269
|
+
private readonly optionsService;
|
|
270
|
+
private readonly projectReportsService;
|
|
271
|
+
private readonly projectsService;
|
|
272
|
+
private readonly runConfigurationService;
|
|
273
|
+
constructor(callidescopeService: CallidescopeService, configurationService: ConfigurationService, fileFilterService: FileFilterService, markdownReportService: MarkdownReportService, optionsService: OptionsService, projectReportsService: ProjectReportsService, projectsService: ProjectsService, runConfigurationService: RunConfigurationService);
|
|
274
|
+
/**
|
|
275
|
+
* Builds the predicate deciding which projects the workspace configuration
|
|
276
|
+
* keeps out of every trace.
|
|
277
|
+
*
|
|
278
|
+
* The run's own filter, built from the same two fields
|
|
279
|
+
* `WorkspaceService.discoverProjects` builds it from and asked the same
|
|
280
|
+
* question it asks — is this project's `tsconfig.json` excluded — so
|
|
281
|
+
* inference and discovery can never disagree about which projects a run
|
|
282
|
+
* covers.
|
|
283
|
+
*
|
|
284
|
+
* A configuration that cannot be loaded excludes nothing. This runs while Nx
|
|
285
|
+
* is building the project graph, where a thrown error stops every command in
|
|
286
|
+
* the workspace rather than one task; the executor loads the same file again
|
|
287
|
+
* and refuses there, where a refusal is about the run that asked for it.
|
|
288
|
+
*/
|
|
289
|
+
private buildExclusionFilter;
|
|
290
|
+
/**
|
|
291
|
+
* Builds one project's targets, gate included unless it is excluded.
|
|
292
|
+
*
|
|
293
|
+
* An excluded project gets the three that print something and not the one
|
|
294
|
+
* that decides an exit code. Its own code is never traced — discovery drops
|
|
295
|
+
* it before its `tsconfig.json` is opened — so a gate there would own no
|
|
296
|
+
* finding at all and report green for a project it never read.
|
|
297
|
+
* `packages/ic-suite/callidescope/callidescope-examples` is the case: its fixtures exist to breach
|
|
298
|
+
* the limits, which is why `.callidescopeignore` names it.
|
|
299
|
+
*
|
|
300
|
+
* That sentence is what `runTrace`'s exemption from the unread rule keeps
|
|
301
|
+
* true: such a project reads nothing of its own by definition, so a trace
|
|
302
|
+
* failing on that would hand it a permanently red target.
|
|
303
|
+
*/
|
|
304
|
+
private buildInferredTargets;
|
|
305
|
+
/**
|
|
306
|
+
* The block a verdict owes the reader when its findings cannot explain it.
|
|
307
|
+
*
|
|
308
|
+
* Both targets print this and only one fails on it — see `judge` — because
|
|
309
|
+
* an unread project is a fact about the run either way. The unread projects
|
|
310
|
+
* come first when both apply: they name what went missing, where the
|
|
311
|
+
* whole-run reason can only say that something did.
|
|
312
|
+
*/
|
|
313
|
+
private explainVerdict;
|
|
314
|
+
/** Whether a project's directory holds a TypeScript program to trace. */
|
|
315
|
+
private holdsProgram;
|
|
316
|
+
/**
|
|
317
|
+
* Whether the workspace configuration excludes this project outright.
|
|
318
|
+
*
|
|
319
|
+
* The project's own `tsconfig.json` is the path asked about, because that is
|
|
320
|
+
* the path `WorkspaceService.discoverProjects` asks about — a project is
|
|
321
|
+
* excluded when the file that makes it a project is.
|
|
322
|
+
*
|
|
323
|
+
* Joined with `path.posix` rather than `path.join`, unlike `holdsProgram`
|
|
324
|
+
* beside it: a filter matches the workspace-relative POSIX paths git and the
|
|
325
|
+
* exclusion globs are written in, where `holdsProgram` hands `existsSync` a
|
|
326
|
+
* native absolute path.
|
|
327
|
+
*/
|
|
328
|
+
private isExcludedProject;
|
|
329
|
+
/**
|
|
330
|
+
* Decides whether a traced result passes, for every target that reads one.
|
|
331
|
+
*
|
|
332
|
+
* One predicate rather than the same expression beside each caller, so a
|
|
333
|
+
* rule added here cannot reach one verdict and miss the other.
|
|
334
|
+
*
|
|
335
|
+
* **Only the projects the run was scoped to are judged.** A trace reaches
|
|
336
|
+
* into the dependencies of what it was pointed at, so judging the whole
|
|
337
|
+
* run's findings would fail `alpha`'s task for a breach in `beta`. The same
|
|
338
|
+
* line the publishing side already draws, one step further along:
|
|
339
|
+
* measurement reaches into dependencies, publishing does not, and judging
|
|
340
|
+
* does not either. A dependency's breach is its own gate's business, and
|
|
341
|
+
* `nx affected` selects it too when it changes, so nothing escapes a verdict.
|
|
342
|
+
*
|
|
343
|
+
* **A judged project none of whose own files were read is named back**, the
|
|
344
|
+
* case `callidescope`'s own `reportEmptyTrace` fails for the same reason: a
|
|
345
|
+
* gate that passes because it never looked reports the project as clean.
|
|
346
|
+
* Asked of each judged project rather than of the whole run, because
|
|
347
|
+
* narrowing made those two different questions — a project with dependencies
|
|
348
|
+
* has a non-empty run whatever became of its own sources, so its own
|
|
349
|
+
* `exclude` over-matching would otherwise leave it owning no finding and
|
|
350
|
+
* passing green. The whole run is asked too, for a run judging no project at
|
|
351
|
+
* all.
|
|
352
|
+
*
|
|
353
|
+
* It is the one rule whose **consequence** is the caller's rather than this
|
|
354
|
+
* predicate's, and so the one thing `unreadProjectNames` is returned beside
|
|
355
|
+
* `ok` for: a `gate` fails on it and a `trace` prints it and passes. Every
|
|
356
|
+
* project the workspace configuration excludes reads nothing of its own and
|
|
357
|
+
* is denied a gate while keeping its trace, so failing the trace too would
|
|
358
|
+
* make that project's target permanently red for being configured exactly as
|
|
359
|
+
* it was asked to be. Finding the projects stays here either way, so the
|
|
360
|
+
* rule cannot be applied to one verdict and forgotten by the other.
|
|
361
|
+
*
|
|
362
|
+
* **Depth is judged always, breadth wherever a limit exists** — not two
|
|
363
|
+
* modes to be selected between. `maximumDepth` has a default and
|
|
364
|
+
* `maximumBreadth` has none at any level, so a project declaring no breadth
|
|
365
|
+
* limit can produce no breadth finding to fail on. Reading the findings
|
|
366
|
+
* rather than naming a check is what keeps that true without a decision.
|
|
367
|
+
*/
|
|
368
|
+
private judge;
|
|
369
|
+
/**
|
|
370
|
+
* States what a selection asked for that the workspace does not have.
|
|
371
|
+
*
|
|
372
|
+
* Both kinds of mistake are named at once, each beside the vocabulary it
|
|
373
|
+
* was drawn from, so a command line with two typos in it is two typos to
|
|
374
|
+
* fix rather than two runs.
|
|
375
|
+
*/
|
|
376
|
+
describeRefusedScope(scope: ResolvedTraceScope): string;
|
|
377
|
+
/**
|
|
378
|
+
* Infers this plugin's targets onto every project holding a `tsconfig.json`.
|
|
379
|
+
*
|
|
380
|
+
* A project with no program of its own is skipped rather than given a target
|
|
381
|
+
* that would trace nothing — `callidescope` warns and moves on, so an
|
|
382
|
+
* inferred target there would be a permanently empty report. The
|
|
383
|
+
* workspace-root project is skipped for the opposite reason: it contains
|
|
384
|
+
* every other project, so its target would trace the whole workspace under
|
|
385
|
+
* one uncacheable task.
|
|
386
|
+
*
|
|
387
|
+
* Asynchronous because the gate is only inferred onto a project the
|
|
388
|
+
* workspace configuration does not exclude, and only that file can say which
|
|
389
|
+
* projects those are — see `buildExclusionFilter`, which is read once here
|
|
390
|
+
* rather than once per project for the same reason the plugin options are.
|
|
391
|
+
*/
|
|
392
|
+
inferTargets(args: InferTargetsArguments): Promise<Map<string, InferredTargets>>;
|
|
393
|
+
/**
|
|
394
|
+
* Resolves an executor's `projects`/`tags` selection into directories.
|
|
395
|
+
*
|
|
396
|
+
* The selection is widened along the Nx dependency graph unless asked not to
|
|
397
|
+
* be — see `ProjectsService.resolveDependencyClosure` for why a trace that
|
|
398
|
+
* stops at a project's own boundary measures the wrong thing. Two sets of
|
|
399
|
+
* directories come back for that reason: what the widened selection reads,
|
|
400
|
+
* and what the selection itself is answerable for.
|
|
401
|
+
*/
|
|
402
|
+
resolveTraceScope(args: ResolveTraceScopeArguments): Promise<ResolvedTraceScope>;
|
|
403
|
+
/**
|
|
404
|
+
* Traces the resolved directories and judges what it found against the
|
|
405
|
+
* limits every project in scope declared.
|
|
406
|
+
*
|
|
407
|
+
* The verdict is `judge`'s, which is where the rules are written; this
|
|
408
|
+
* chooses what to print for it — the findings it judged, or, for a run that
|
|
409
|
+
* read nothing and so has none to show, the reason it failed instead.
|
|
410
|
+
*
|
|
411
|
+
* The one thing it adds to that verdict is the exit code for an unread
|
|
412
|
+
* judged project, which is the gate's alone — see `judge`.
|
|
413
|
+
*/
|
|
414
|
+
runGate(args: RunGateArguments): Promise<RunTraceResult>;
|
|
415
|
+
/**
|
|
416
|
+
* Traces the resolved directories and renders the report.
|
|
417
|
+
*
|
|
418
|
+
* This is the whole of the "logic on top of core callidescope": the
|
|
419
|
+
* selection above is Nx's to resolve, and everything below this line is
|
|
420
|
+
* callidescope's own, reached through the same services the `callidescope`
|
|
421
|
+
* command uses rather than through a subprocess.
|
|
422
|
+
*
|
|
423
|
+
* Judged by the same predicate the gate is, so the two targets cannot come
|
|
424
|
+
* to disagree about what a passing run is. A run that read nothing keeps its
|
|
425
|
+
* report and gains the reason underneath it: a summary table of zeroes is
|
|
426
|
+
* what happened, not why it failed.
|
|
427
|
+
*
|
|
428
|
+
* The one rule the two act on differently: a judged project none of whose
|
|
429
|
+
* own files were read is **printed here and not failed on**, where a gate
|
|
430
|
+
* fails — see `judge` for why that is the one exemption.
|
|
431
|
+
*/
|
|
432
|
+
runTrace(args: RunTraceArguments): Promise<RunTraceResult>;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/** Provides the Nx project-name to directory resolution. */
|
|
436
|
+
export declare class ProjectsModule {
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Resolves Nx project names to the directories a callidescope run traces.
|
|
441
|
+
*
|
|
442
|
+
* This is the whole of callidescope's Nx awareness. `callidescope-cli` and
|
|
443
|
+
* `callidescope-graph` know nothing about Nx and never read a project graph;
|
|
444
|
+
* they take directories. What an Nx workspace has that plain paths do not is
|
|
445
|
+
* a stable name for each of those directories, and turning one into the other
|
|
446
|
+
* is the only thing this package is for.
|
|
447
|
+
*
|
|
448
|
+
* The project graph is passed in rather than read here, so every resolution
|
|
449
|
+
* rule below is testable without a workspace to build a graph from —
|
|
450
|
+
* `readProjectGraph` is the one method that touches Nx at run time.
|
|
451
|
+
*/
|
|
452
|
+
export declare class ProjectsService {
|
|
453
|
+
constructor();
|
|
454
|
+
/** Every tag any project carries, sorted and deduplicated. */
|
|
455
|
+
private readTags;
|
|
456
|
+
/**
|
|
457
|
+
* Collects the names of every project carrying any of the given tags, and
|
|
458
|
+
* the tags nothing carries.
|
|
459
|
+
*
|
|
460
|
+
* Any of them rather than all of them. Nx tags come in families whose
|
|
461
|
+
* members are mutually exclusive on one project — nothing is both
|
|
462
|
+
* `type:application` and `type:package` — so requiring every tag would make
|
|
463
|
+
* the common selection resolve to nothing. Any is also the reading that
|
|
464
|
+
* composes: each tag widens the set, the way naming another project does.
|
|
465
|
+
*/
|
|
466
|
+
private resolveTaggedNames;
|
|
467
|
+
/** Reads the workspace's Nx project graph. */
|
|
468
|
+
readProjectGraph(): Promise<ProjectGraph>;
|
|
469
|
+
/**
|
|
470
|
+
* Lists every project the graph knows, sorted by name.
|
|
471
|
+
*
|
|
472
|
+
* A project rooted at the workspace root is kept rather than filtered out.
|
|
473
|
+
* It resolves to `.`, which `--directories` accepts, and naming it is a
|
|
474
|
+
* caller saying they mean the root program — a different thing from
|
|
475
|
+
* omitting `--directories`, which walks the workspace for every
|
|
476
|
+
* `tsconfig.json` there is.
|
|
477
|
+
*/
|
|
478
|
+
readProjects(graph: ProjectGraph): NxProject[];
|
|
479
|
+
/**
|
|
480
|
+
* Widens a set of project names to include everything they depend on.
|
|
481
|
+
*
|
|
482
|
+
* Dependencies, never dependents. A call stack runs downward — a command
|
|
483
|
+
* calls into the service it was injected with, which lives in a package it
|
|
484
|
+
* depends on — and those packages are what a trace of one project has to
|
|
485
|
+
* carry. Its dependents call *into* it and add no frames below it.
|
|
486
|
+
*
|
|
487
|
+
* This widens what the run is *scoped to*, not how far a stack runs:
|
|
488
|
+
* `WorkspaceService.walkImportedProjectClosure` already builds the program
|
|
489
|
+
* of every project the named directories transitively import. What the Nx
|
|
490
|
+
* graph adds is edges the compiler never read — an implicit dependency, or
|
|
491
|
+
* one that exists only at run time. Being scoped rather than merely reached
|
|
492
|
+
* costs nothing in this plugin, which writes nothing anywhere; it is the
|
|
493
|
+
* command-line host that acts on it, publishing a `README.md` section for a
|
|
494
|
+
* scoped project on a `--write` run.
|
|
495
|
+
*
|
|
496
|
+
* External `npm:` targets are dropped: they have no workspace directory to
|
|
497
|
+
* trace, and following them would mean tracing `node_modules`.
|
|
498
|
+
*/
|
|
499
|
+
resolveDependencyClosure(args: {
|
|
500
|
+
graph: ProjectGraph;
|
|
501
|
+
projectNames: readonly string[];
|
|
502
|
+
}): string[];
|
|
503
|
+
/**
|
|
504
|
+
* Resolves Nx project names and tags to their workspace-relative roots.
|
|
505
|
+
*
|
|
506
|
+
* The two selections are unioned, not intersected: naming a project and
|
|
507
|
+
* naming a tag both widen what gets traced, and a project reached both ways
|
|
508
|
+
* is still one directory. Intersecting them would make `--tags` a filter on
|
|
509
|
+
* `--projects`, which would resolve to nothing whenever only one was given.
|
|
510
|
+
*
|
|
511
|
+
* Unknown names and unmatched tags are collected rather than dropped or
|
|
512
|
+
* thrown on, so one resolution reports every typo at once instead of one
|
|
513
|
+
* per run, and the caller decides whether a partial resolution is worth
|
|
514
|
+
* tracing.
|
|
515
|
+
*/
|
|
516
|
+
resolveDirectories(args: {
|
|
517
|
+
graph: ProjectGraph;
|
|
518
|
+
projectNames?: readonly string[] | undefined;
|
|
519
|
+
tags?: readonly string[] | undefined;
|
|
520
|
+
}): ResolvedProjectDirectories;
|
|
521
|
+
/**
|
|
522
|
+
* Resolves names and tags to the project names they stand for.
|
|
523
|
+
*
|
|
524
|
+
* Separate from `resolveDirectories` because a directory is the last step,
|
|
525
|
+
* not the only one: widening a selection along the Nx dependency graph
|
|
526
|
+
* happens between the two, and it happens in names, which is the only
|
|
527
|
+
* vocabulary the project graph speaks.
|
|
528
|
+
*/
|
|
529
|
+
resolveProjectNames(args: {
|
|
530
|
+
graph: ProjectGraph;
|
|
531
|
+
projectNames?: readonly string[] | undefined;
|
|
532
|
+
tags?: readonly string[] | undefined;
|
|
533
|
+
}): ResolvedProjectSelection;
|
|
534
|
+
/** Maps project names to their workspace-relative roots, sorted and deduplicated. */
|
|
535
|
+
toDirectories(args: {
|
|
536
|
+
graph: ProjectGraph;
|
|
537
|
+
projectNames: readonly string[];
|
|
538
|
+
}): string[];
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/** Resolves the service backing the `depth` and `breadth` lookups. */
|
|
542
|
+
export declare function resolveAddressService(): Promise<AddressService>;
|
|
543
|
+
|
|
544
|
+
/** A resolved selection, mapped on to the directories a trace takes. */
|
|
545
|
+
export declare interface ResolvedProjectDirectories extends ResolvedProjectSelection {
|
|
546
|
+
/**
|
|
547
|
+
* Workspace-relative roots of the names that resolved, sorted and
|
|
548
|
+
* deduplicated — the form `callidescope --directories` takes.
|
|
549
|
+
*/
|
|
550
|
+
readonly directories: string[];
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/** What a set of Nx project names and tags resolved to, before directories. */
|
|
554
|
+
export declare interface ResolvedProjectSelection {
|
|
555
|
+
/**
|
|
556
|
+
* Every project name the graph knew, sorted — what a caller names back when
|
|
557
|
+
* refusing an unknown one.
|
|
558
|
+
*/
|
|
559
|
+
readonly knownNames: string[];
|
|
560
|
+
/**
|
|
561
|
+
* Every tag any project in the workspace carries, sorted and deduplicated —
|
|
562
|
+
* what a caller names back when refusing one nothing carries.
|
|
563
|
+
*/
|
|
564
|
+
readonly knownTags: string[];
|
|
565
|
+
/** The projects the selection reached, sorted and deduplicated. */
|
|
566
|
+
readonly projectNames: string[];
|
|
567
|
+
/**
|
|
568
|
+
* The names the project graph does not know, in the order they were given.
|
|
569
|
+
*
|
|
570
|
+
* Reported rather than dropped: a name nobody resolves is a trace that
|
|
571
|
+
* silently covers less than it was asked to, which is the one failure a
|
|
572
|
+
* report cannot show you.
|
|
573
|
+
*/
|
|
574
|
+
readonly unknownNames: string[];
|
|
575
|
+
/**
|
|
576
|
+
* The tags no project in the workspace carries, in the order they were
|
|
577
|
+
* given.
|
|
578
|
+
*
|
|
579
|
+
* Refused for the same reason an unknown name is: a tag matching nothing is
|
|
580
|
+
* far more often a typo than an empty category, and either way the run it
|
|
581
|
+
* would produce covers less than it was asked to without saying so.
|
|
582
|
+
*/
|
|
583
|
+
readonly unmatchedTags: string[];
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/** What a selection of Nx projects resolved to before a trace runs. */
|
|
587
|
+
export declare interface ResolvedTraceScope {
|
|
588
|
+
/** Workspace-relative directories to hand `callidescope --directories`. */
|
|
589
|
+
readonly directories: string[];
|
|
590
|
+
/** Every project name the workspace has, for naming an unknown one back. */
|
|
591
|
+
readonly knownNames: string[];
|
|
592
|
+
/** Every tag the workspace carries, for naming an unmatched one back. */
|
|
593
|
+
readonly knownTags: string[];
|
|
594
|
+
/** Every project the selection reached, including pulled-in dependencies. */
|
|
595
|
+
readonly projectNames: string[];
|
|
596
|
+
/**
|
|
597
|
+
* Directories of the projects the selection itself named, before the
|
|
598
|
+
* dependency widening.
|
|
599
|
+
*
|
|
600
|
+
* What a verdict covers, where `directories` is what a trace reads: a
|
|
601
|
+
* dependency pulled in to keep a stack from stopping at a package boundary
|
|
602
|
+
* is measured by this run and judged by its own.
|
|
603
|
+
*/
|
|
604
|
+
readonly selectedDirectories: string[];
|
|
605
|
+
/** Names the workspace does not have. */
|
|
606
|
+
readonly unknownNames: string[];
|
|
607
|
+
/** Tags no project in the workspace carries. */
|
|
608
|
+
readonly unmatchedTags: string[];
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/** Resolves the service that reads this plugin's registration in `nx.json`. */
|
|
612
|
+
export declare function resolveOptionsService(): Promise<OptionsService>;
|
|
613
|
+
|
|
614
|
+
/** Resolves the service backing target inference and the trace executor. */
|
|
615
|
+
export declare function resolvePluginService(): Promise<PluginService>;
|
|
616
|
+
|
|
617
|
+
/** Resolves the service that reads the workspace's Nx project graph. */
|
|
618
|
+
export declare function resolveProjectsService(): Promise<ProjectsService>;
|
|
619
|
+
|
|
620
|
+
/** Arguments for resolving what one executor invocation should trace. */
|
|
621
|
+
declare interface ResolveTraceScopeArguments {
|
|
622
|
+
/** Names from the executor's `projects` option. Empty selects nothing. */
|
|
623
|
+
readonly projectNames: readonly string[];
|
|
624
|
+
/** Tags from the executor's `tags` option. Empty selects nothing. */
|
|
625
|
+
readonly tags: readonly string[];
|
|
626
|
+
/** Whether the selection widens along the Nx dependency graph. */
|
|
627
|
+
readonly withDependencies: boolean;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Finds and reads the callidescope configuration one run is judged by.
|
|
632
|
+
*
|
|
633
|
+
* Its own service rather than more of `PluginService`, because every target
|
|
634
|
+
* here starts by answering the same question — which configuration file is
|
|
635
|
+
* this run's — and none of them can be written until it is answered. Keeping
|
|
636
|
+
* it apart also keeps the verdict and the inference in `PluginService` beside
|
|
637
|
+
* each other, which is where the rules a reader comes looking for are.
|
|
638
|
+
*/
|
|
639
|
+
declare class RunConfigurationService {
|
|
640
|
+
private readonly configurationService;
|
|
641
|
+
private readonly optionsService;
|
|
642
|
+
constructor(configurationService: ConfigurationService, optionsService: OptionsService);
|
|
643
|
+
/**
|
|
644
|
+
* Reads the workspace's `nx.json`, so this plugin's own registration can be
|
|
645
|
+
* consulted for a configuration path an executor was not given.
|
|
646
|
+
*
|
|
647
|
+
* Unreadable or malformed is not an error: the caller falls back to the
|
|
648
|
+
* conventional filenames, which a workspace with no registration gets anyway.
|
|
649
|
+
*/
|
|
650
|
+
private readNxConfiguration;
|
|
651
|
+
/**
|
|
652
|
+
* Resolves and loads the configuration one run is judged by.
|
|
653
|
+
*
|
|
654
|
+
* The file-aware load rather than the plain one: a run resolves a
|
|
655
|
+
* configuration beside every project it reaches, and skips whichever file is
|
|
656
|
+
* already serving as this run's own.
|
|
657
|
+
*/
|
|
658
|
+
load(args: LoadRunConfigurationArguments): Promise<LoadedRunConfiguration>;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Arguments for gating one resolved selection against its limits.
|
|
663
|
+
*
|
|
664
|
+
* The trace's arguments without `format`: a gate's output is the findings that
|
|
665
|
+
* decided its exit code, so there is no second rendering of it to ask for.
|
|
666
|
+
*/
|
|
667
|
+
declare type RunGateArguments = Omit<RunTraceArguments, "format">;
|
|
668
|
+
|
|
669
|
+
/** Arguments for tracing one resolved selection. */
|
|
670
|
+
declare interface RunTraceArguments {
|
|
671
|
+
/** Resolved from this plugin's `nx.json` registration when omitted. */
|
|
672
|
+
readonly configurationPath?: string | undefined;
|
|
673
|
+
readonly directories: readonly string[];
|
|
674
|
+
/** What the run prints. Defaults to markdown when omitted. */
|
|
675
|
+
readonly format?: CallidescopeOutputFormat | undefined;
|
|
676
|
+
/**
|
|
677
|
+
* The projects whose findings decide the verdict.
|
|
678
|
+
*
|
|
679
|
+
* A subset of `directories`, which is what gets traced: a run reaches into
|
|
680
|
+
* the dependencies of what it was pointed at, and a finding there belongs
|
|
681
|
+
* to the task named after the project that owns it.
|
|
682
|
+
*
|
|
683
|
+
* Workspace-relative roots, because that is what callidescope calls a
|
|
684
|
+
* project name — `WorkspaceService.discoverProjects` names each project by
|
|
685
|
+
* the directory holding its `tsconfig.json`, and a report's `projectName`
|
|
686
|
+
* is that same string. An Nx project name would match nothing.
|
|
687
|
+
*/
|
|
688
|
+
readonly judgedProjectNames: readonly string[];
|
|
689
|
+
readonly workspaceRoot: string;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
/** The outcome of tracing one selection. */
|
|
693
|
+
export declare interface RunTraceResult {
|
|
694
|
+
readonly ok: boolean;
|
|
695
|
+
readonly report: string;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
export { }
|