@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,815 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { NestFactory as e } from "@nestjs/core";
|
|
3
|
+
import { ConsoleLogger as t, Global as n, Injectable as r, Module as i, Scope as a } from "@nestjs/common";
|
|
4
|
+
import { existsSync as o, mkdirSync as s, readFileSync as c } from "node:fs";
|
|
5
|
+
import l from "node:path";
|
|
6
|
+
import u from "pino";
|
|
7
|
+
import { AddressLookupModule as ee, AddressLookupService as d, CallidescopeModule as te, CallidescopeService as f } from "@callidescope/cli";
|
|
8
|
+
import { AddressDepthService as p, BreadthService as m, FileFilterService as h, GraphModule as g, WorkspaceModule as ne } from "@callidescope/graph";
|
|
9
|
+
import { AddressReportModule as _, AddressReportService as v, MarkdownReportService as y, ProjectReportsModule as b, ProjectReportsService as x, ReportModule as re } from "@callidescope/output";
|
|
10
|
+
import { CALLIDESCOPE_OUTPUT_FORMATS as ie, ConfigurationModule as S, ConfigurationService as C, DEFAULT_OUTPUT_FORMAT as w, DEFAULT_PREVIEW_COUNT as T, DEFAULT_RUN_HEADING as ae } from "@callidescope/configuration";
|
|
11
|
+
import { createProjectGraphAsync as oe } from "@nx/devkit";
|
|
12
|
+
//#region packages/logger/src/modules/logger/logger.constants.ts
|
|
13
|
+
var se = /^(\p{Extended_Pictographic}️?(?:\p{Extended_Pictographic}️?)*)\s+/u, E = /^([A-Za-z]+)/, D = /* @__PURE__ */ new Set([
|
|
14
|
+
"built",
|
|
15
|
+
"cut",
|
|
16
|
+
"found",
|
|
17
|
+
"got",
|
|
18
|
+
"kept",
|
|
19
|
+
"left",
|
|
20
|
+
"lost",
|
|
21
|
+
"made",
|
|
22
|
+
"put",
|
|
23
|
+
"ran",
|
|
24
|
+
"read",
|
|
25
|
+
"rebuilt",
|
|
26
|
+
"sent",
|
|
27
|
+
"set",
|
|
28
|
+
"split",
|
|
29
|
+
"took",
|
|
30
|
+
"wrote"
|
|
31
|
+
]), O = /* @__PURE__ */ new Set([
|
|
32
|
+
"CommandFactory",
|
|
33
|
+
"ExceptionHandler",
|
|
34
|
+
"GraphQLModule",
|
|
35
|
+
"InstanceLoader",
|
|
36
|
+
"NestApplication",
|
|
37
|
+
"NestFactory",
|
|
38
|
+
"RouterExplorer",
|
|
39
|
+
"RoutesResolver",
|
|
40
|
+
"TypeOrmModule"
|
|
41
|
+
]);
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region \0@oxc-project+runtime@0.151.0/helpers/esm/decorateMetadata.js
|
|
44
|
+
function k(e, t) {
|
|
45
|
+
if (typeof Reflect == "object" && typeof Reflect.metadata == "function") return Reflect.metadata(e, t);
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region \0@oxc-project+runtime@0.151.0/helpers/esm/decorate.js
|
|
49
|
+
function A(e, t, n, r) {
|
|
50
|
+
var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
|
|
51
|
+
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
|
|
52
|
+
else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
|
|
53
|
+
return i > 3 && a && Object.defineProperty(t, n, a), a;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region packages/logger/src/modules/logger/logger.service.ts
|
|
57
|
+
var j, M = class extends t {
|
|
58
|
+
static {
|
|
59
|
+
j = this;
|
|
60
|
+
}
|
|
61
|
+
constructor() {
|
|
62
|
+
super();
|
|
63
|
+
}
|
|
64
|
+
static isProduction = process.env.NODE_ENV === "production";
|
|
65
|
+
static rootLogger;
|
|
66
|
+
static writesToStandardError = !1;
|
|
67
|
+
child = j.root;
|
|
68
|
+
static createRootLogger() {
|
|
69
|
+
let e = process.env.LOG_LEVEL ?? "info";
|
|
70
|
+
return j.isProduction ? j.writesToStandardError ? u({ level: e }, u.destination(2)) : u({ level: e }) : u({
|
|
71
|
+
level: e,
|
|
72
|
+
transport: {
|
|
73
|
+
options: {
|
|
74
|
+
colorize: !0,
|
|
75
|
+
destination: j.writesToStandardError ? 2 : 1,
|
|
76
|
+
ignore: "pid,hostname,emoji",
|
|
77
|
+
messageFormat: "{emoji} {msg}",
|
|
78
|
+
singleLine: !0
|
|
79
|
+
},
|
|
80
|
+
target: "pino-pretty"
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
static logToStandardError() {
|
|
85
|
+
if (j.rootLogger !== void 0) {
|
|
86
|
+
process.emitWarning("LoggerService.logToStandardError() was called after the first log line, so log lines still go to standard output and anything piping that stream will read them as data. Call it as the first statement of the application's bootstrap.");
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
j.writesToStandardError = !0;
|
|
90
|
+
}
|
|
91
|
+
assertConventionalMessage(e) {
|
|
92
|
+
if (j.isProduction || this.shouldSkipConventionalMessageValidation(e.context)) return;
|
|
93
|
+
let t = this.getConventionalMessageViolation(e.parsed);
|
|
94
|
+
if (t !== void 0) throw Error(t);
|
|
95
|
+
}
|
|
96
|
+
buildBindings(e) {
|
|
97
|
+
return this.assertConventionalMessage({
|
|
98
|
+
context: e.context,
|
|
99
|
+
parsed: e.parsed
|
|
100
|
+
}), {
|
|
101
|
+
...e.data,
|
|
102
|
+
context: e.context,
|
|
103
|
+
...j.isProduction ? {} : { emoji: e.parsed.emoji }
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
getConventionalMessageViolation(e) {
|
|
107
|
+
let t = e.emoji, n = e.text;
|
|
108
|
+
if (t === void 0) return `Log message must start with an emoji naming its subject, then a verb: "${n}"`;
|
|
109
|
+
let r = E.exec(n)?.[1];
|
|
110
|
+
if (r === void 0 || !this.isConventionalVerb(r)) return `Log message must begin with a verb in present progressive or past tense, got "${r ?? ""}": "${t} ${n}"`;
|
|
111
|
+
}
|
|
112
|
+
isConventionalVerb(e) {
|
|
113
|
+
let t = e.toLowerCase();
|
|
114
|
+
return t.endsWith("ing") || t.endsWith("ed") || D.has(t);
|
|
115
|
+
}
|
|
116
|
+
parseMessage(e) {
|
|
117
|
+
let t = String(e), n = se.exec(t), r = n?.[1];
|
|
118
|
+
return r === void 0 ? {
|
|
119
|
+
emoji: void 0,
|
|
120
|
+
text: t
|
|
121
|
+
} : {
|
|
122
|
+
emoji: r,
|
|
123
|
+
text: t.slice(n?.[0].length)
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
shouldSkipConventionalMessageValidation(e) {
|
|
127
|
+
return e !== void 0 && O.has(e);
|
|
128
|
+
}
|
|
129
|
+
static get root() {
|
|
130
|
+
return j.rootLogger ??= j.createRootLogger(), j.rootLogger;
|
|
131
|
+
}
|
|
132
|
+
buildErrorLogEntry(e, t) {
|
|
133
|
+
let n = t instanceof Error ? t.stack || t.message : String(t);
|
|
134
|
+
return {
|
|
135
|
+
errorMessage: n,
|
|
136
|
+
logLine: `[${(/* @__PURE__ */ new Date()).toISOString()}] ${e}: ${n}\n`
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
createTimestampedOutputLogFilePath(e) {
|
|
140
|
+
let t = l.join(process.cwd(), "output");
|
|
141
|
+
return o(t) || s(t, { recursive: !0 }), l.join(t, `${e}-${(/* @__PURE__ */ new Date()).toISOString().replaceAll(/[:.]/g, "-")}.log`);
|
|
142
|
+
}
|
|
143
|
+
debug(e, t, n) {
|
|
144
|
+
let r = this.parseMessage(e);
|
|
145
|
+
this.child.debug(this.buildBindings({
|
|
146
|
+
context: t ?? this.context,
|
|
147
|
+
data: n,
|
|
148
|
+
parsed: r
|
|
149
|
+
}), r.text);
|
|
150
|
+
}
|
|
151
|
+
error(e, t, n) {
|
|
152
|
+
let r = this.parseMessage(e), i = typeof n == "object" ? n : void 0, a = typeof n == "string" ? n : this.context;
|
|
153
|
+
this.child.error({
|
|
154
|
+
...this.buildBindings({
|
|
155
|
+
context: a,
|
|
156
|
+
data: i,
|
|
157
|
+
parsed: r
|
|
158
|
+
}),
|
|
159
|
+
stack: t
|
|
160
|
+
}, r.text);
|
|
161
|
+
}
|
|
162
|
+
info(e, t, n) {
|
|
163
|
+
let r = this.parseMessage(e);
|
|
164
|
+
this.child.info(this.buildBindings({
|
|
165
|
+
context: t ?? this.context,
|
|
166
|
+
data: n,
|
|
167
|
+
parsed: r
|
|
168
|
+
}), r.text);
|
|
169
|
+
}
|
|
170
|
+
log(e, t, n) {
|
|
171
|
+
this.info(e, t, n);
|
|
172
|
+
}
|
|
173
|
+
setContext(e) {
|
|
174
|
+
super.setContext(e), this.child = j.root.child({ context: e });
|
|
175
|
+
}
|
|
176
|
+
verbose(e, t, n) {
|
|
177
|
+
let r = this.parseMessage(e);
|
|
178
|
+
this.child.trace(this.buildBindings({
|
|
179
|
+
context: t ?? this.context,
|
|
180
|
+
data: n,
|
|
181
|
+
parsed: r
|
|
182
|
+
}), r.text);
|
|
183
|
+
}
|
|
184
|
+
warn(e, t, n) {
|
|
185
|
+
let r = this.parseMessage(e);
|
|
186
|
+
this.child.warn(this.buildBindings({
|
|
187
|
+
context: t ?? this.context,
|
|
188
|
+
data: n,
|
|
189
|
+
parsed: r
|
|
190
|
+
}), r.text);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
M = j = A([r({ scope: a.TRANSIENT }), k("design:paramtypes", [])], M);
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region packages/logger/src/modules/logger/logger.module.ts
|
|
196
|
+
var N = class {};
|
|
197
|
+
N = A([n(), i({
|
|
198
|
+
controllers: [],
|
|
199
|
+
exports: [M],
|
|
200
|
+
imports: [],
|
|
201
|
+
providers: [M]
|
|
202
|
+
})], N);
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region packages/ic-suite/callidescope/callidescope-nx/src/modules/address/address.service.ts
|
|
205
|
+
var P = class {
|
|
206
|
+
addressLookupService;
|
|
207
|
+
addressReportService;
|
|
208
|
+
addressDepthService;
|
|
209
|
+
breadthService;
|
|
210
|
+
constructor(e, t, n, r) {
|
|
211
|
+
this.addressLookupService = e, this.addressReportService = t, this.addressDepthService = n, this.breadthService = r;
|
|
212
|
+
}
|
|
213
|
+
identify(e) {
|
|
214
|
+
let t = this.addressLookupService.resolve(e), n = this.addressLookupService.describeProblem({
|
|
215
|
+
address: e.address,
|
|
216
|
+
resolution: t
|
|
217
|
+
});
|
|
218
|
+
return n !== void 0 || t.kind !== "resolved" ? { problem: n ?? `"${e.address}" resolved to nothing.` } : { id: t.id };
|
|
219
|
+
}
|
|
220
|
+
async locate(e) {
|
|
221
|
+
let t = await this.addressLookupService.locate({
|
|
222
|
+
...e.configurationPath === void 0 ? {} : { config: e.configurationPath },
|
|
223
|
+
directories: [...e.directories],
|
|
224
|
+
...e.format === void 0 ? {} : { format: e.format }
|
|
225
|
+
}), n = [], r = [];
|
|
226
|
+
for (let i of e.addresses) {
|
|
227
|
+
let e = this.identify({
|
|
228
|
+
address: i,
|
|
229
|
+
workspace: t
|
|
230
|
+
});
|
|
231
|
+
if ("problem" in e) {
|
|
232
|
+
r.push(e.problem);
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
n.push({
|
|
236
|
+
address: i,
|
|
237
|
+
id: e.id
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
return r.length > 0 ? r.join("\n") : {
|
|
241
|
+
identified: n,
|
|
242
|
+
workspace: t
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
async runBreadth(e) {
|
|
246
|
+
let t = await this.locate(e);
|
|
247
|
+
if (typeof t == "string") return {
|
|
248
|
+
ok: !1,
|
|
249
|
+
report: t
|
|
250
|
+
};
|
|
251
|
+
let { identified: n, workspace: r } = t, { located: i } = r, a = [];
|
|
252
|
+
for (let { address: e, id: t } of n) {
|
|
253
|
+
let n = i.callablesById.get(t);
|
|
254
|
+
if (n === void 0) return {
|
|
255
|
+
ok: !1,
|
|
256
|
+
report: `"${e}" resolved to a callable that was not traced.`
|
|
257
|
+
};
|
|
258
|
+
a.push({
|
|
259
|
+
address: e,
|
|
260
|
+
directCalls: this.breadthService.describeDirectCalls({
|
|
261
|
+
callablesById: i.callablesById,
|
|
262
|
+
graph: i.graph,
|
|
263
|
+
id: t
|
|
264
|
+
}),
|
|
265
|
+
displayName: n.node.displayName,
|
|
266
|
+
id: t,
|
|
267
|
+
location: n.node.location
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
ok: !0,
|
|
272
|
+
report: this.addressReportService.renderBreadthReports({
|
|
273
|
+
format: e.format ?? w,
|
|
274
|
+
reports: a
|
|
275
|
+
})
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
async runDepth(e) {
|
|
279
|
+
let t = await this.locate(e);
|
|
280
|
+
if (typeof t == "string") return {
|
|
281
|
+
ok: !1,
|
|
282
|
+
report: t
|
|
283
|
+
};
|
|
284
|
+
let { identified: n, workspace: r } = t;
|
|
285
|
+
return {
|
|
286
|
+
ok: !0,
|
|
287
|
+
report: this.addressReportService.renderDepthReports({
|
|
288
|
+
format: e.format ?? w,
|
|
289
|
+
reports: n.map(({ address: e, id: t }) => {
|
|
290
|
+
let n = {
|
|
291
|
+
callablesById: r.located.callablesById,
|
|
292
|
+
graph: r.located.graph,
|
|
293
|
+
startId: t
|
|
294
|
+
};
|
|
295
|
+
return {
|
|
296
|
+
address: e,
|
|
297
|
+
downward: this.addressDepthService.buildDownwardStacks(n),
|
|
298
|
+
upward: this.addressDepthService.buildUpwardStacks(n)
|
|
299
|
+
};
|
|
300
|
+
})
|
|
301
|
+
})
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
P = A([r(), k("design:paramtypes", [
|
|
306
|
+
d === void 0 ? Object : d,
|
|
307
|
+
v === void 0 ? Object : v,
|
|
308
|
+
p === void 0 ? Object : p,
|
|
309
|
+
m === void 0 ? Object : m
|
|
310
|
+
])], P);
|
|
311
|
+
//#endregion
|
|
312
|
+
//#region packages/ic-suite/callidescope/callidescope-nx/src/modules/address/address.module.ts
|
|
313
|
+
var F = class {};
|
|
314
|
+
F = A([i({
|
|
315
|
+
controllers: [],
|
|
316
|
+
exports: [P],
|
|
317
|
+
imports: [
|
|
318
|
+
ee,
|
|
319
|
+
_,
|
|
320
|
+
g
|
|
321
|
+
],
|
|
322
|
+
providers: [P]
|
|
323
|
+
})], F);
|
|
324
|
+
//#endregion
|
|
325
|
+
//#region packages/ic-suite/callidescope/callidescope-nx/src/modules/options/options.constants.ts
|
|
326
|
+
var I = "@callidescope/nx", L = "trace", R = "depth", z = "breadth", B = "gate", V = ["callidescope.config.ts", "configuration/callidescope.config.ts"], H = "tsconfig.json", U = class {
|
|
327
|
+
constructor() {}
|
|
328
|
+
isUnknownArray(e) {
|
|
329
|
+
return Array.isArray(e);
|
|
330
|
+
}
|
|
331
|
+
readEntryConfigurationPath(e) {
|
|
332
|
+
if (typeof e != "object" || !e) return;
|
|
333
|
+
let { options: t, plugin: n } = { ...e };
|
|
334
|
+
if (n === "@callidescope/nx" && typeof t == "object" && t) return this.readString({
|
|
335
|
+
key: "configurationPath",
|
|
336
|
+
options: { ...t }
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
readRegisteredConfigurationPath(e) {
|
|
340
|
+
if (typeof e != "object" || !e) return;
|
|
341
|
+
let { plugins: t } = { ...e };
|
|
342
|
+
if (this.isUnknownArray(t)) for (let e of t) {
|
|
343
|
+
let t = this.readEntryConfigurationPath(e);
|
|
344
|
+
if (t !== void 0) return t;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
readString(e) {
|
|
348
|
+
let t = e.options[e.key];
|
|
349
|
+
return typeof t == "string" && t !== "" ? t : void 0;
|
|
350
|
+
}
|
|
351
|
+
readFormat(e) {
|
|
352
|
+
return ie.find((t) => t === e);
|
|
353
|
+
}
|
|
354
|
+
readStringList(e) {
|
|
355
|
+
return this.isUnknownArray(e) ? e.filter((e) => typeof e == "string").flatMap((e) => e.split(",")).map((e) => e.trim()).filter((e) => e !== "") : typeof e == "string" ? this.readStringList([e]) : [];
|
|
356
|
+
}
|
|
357
|
+
resolveConfigurationPath(e) {
|
|
358
|
+
return this.readRegisteredConfigurationPath(e.nxConfiguration) ?? V.find((t) => e.exists(t)) ?? V[0];
|
|
359
|
+
}
|
|
360
|
+
resolvePluginOptions(e) {
|
|
361
|
+
let t = typeof e == "object" && e ? { ...e } : {};
|
|
362
|
+
return {
|
|
363
|
+
breadthTargetName: this.readString({
|
|
364
|
+
key: "breadthTargetName",
|
|
365
|
+
options: t
|
|
366
|
+
}) ?? "breadth",
|
|
367
|
+
configurationPath: this.readString({
|
|
368
|
+
key: "configurationPath",
|
|
369
|
+
options: t
|
|
370
|
+
}) ?? V[0],
|
|
371
|
+
depthTargetName: this.readString({
|
|
372
|
+
key: "depthTargetName",
|
|
373
|
+
options: t
|
|
374
|
+
}) ?? "depth",
|
|
375
|
+
gateTargetName: this.readString({
|
|
376
|
+
key: "gateTargetName",
|
|
377
|
+
options: t
|
|
378
|
+
}) ?? "gate",
|
|
379
|
+
traceTargetName: this.readString({
|
|
380
|
+
key: "traceTargetName",
|
|
381
|
+
options: t
|
|
382
|
+
}) ?? "trace"
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
U = A([r(), k("design:paramtypes", [])], U);
|
|
387
|
+
//#endregion
|
|
388
|
+
//#region packages/ic-suite/callidescope/callidescope-nx/src/modules/options/options.module.ts
|
|
389
|
+
var W = class {};
|
|
390
|
+
W = A([i({
|
|
391
|
+
controllers: [],
|
|
392
|
+
exports: [U],
|
|
393
|
+
imports: [],
|
|
394
|
+
providers: [U]
|
|
395
|
+
})], W);
|
|
396
|
+
//#endregion
|
|
397
|
+
//#region packages/ic-suite/callidescope/callidescope-nx/src/modules/projects/projects.service.ts
|
|
398
|
+
var G = class {
|
|
399
|
+
constructor() {}
|
|
400
|
+
readTags(e) {
|
|
401
|
+
return [...new Set(e.flatMap((e) => e.tags))].toSorted((e, t) => e.localeCompare(t));
|
|
402
|
+
}
|
|
403
|
+
resolveTaggedNames(e) {
|
|
404
|
+
let t = [], n = [];
|
|
405
|
+
for (let r of e.tags) {
|
|
406
|
+
let i = e.projects.filter((e) => e.tags.includes(r));
|
|
407
|
+
if (i.length === 0) {
|
|
408
|
+
n.push(r);
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
t.push(...i.map((e) => e.name));
|
|
412
|
+
}
|
|
413
|
+
return {
|
|
414
|
+
names: t,
|
|
415
|
+
unmatchedTags: n
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
async readProjectGraph() {
|
|
419
|
+
return oe({ exitOnError: !1 });
|
|
420
|
+
}
|
|
421
|
+
readProjects(e) {
|
|
422
|
+
return Object.entries(e.nodes).map(([e, t]) => ({
|
|
423
|
+
name: e,
|
|
424
|
+
root: t.data.root,
|
|
425
|
+
tags: t.data.tags ?? []
|
|
426
|
+
})).toSorted((e, t) => e.name.localeCompare(t.name));
|
|
427
|
+
}
|
|
428
|
+
resolveDependencyClosure(e) {
|
|
429
|
+
let t = new Set(Object.keys(e.graph.nodes)), n = /* @__PURE__ */ new Set(), r = e.projectNames.filter((e) => t.has(e));
|
|
430
|
+
for (; r.length > 0;) {
|
|
431
|
+
let i = [];
|
|
432
|
+
for (let a of r) if (!n.has(a)) {
|
|
433
|
+
n.add(a);
|
|
434
|
+
for (let n of e.graph.dependencies[a] ?? []) t.has(n.target) && i.push(n.target);
|
|
435
|
+
}
|
|
436
|
+
r = i;
|
|
437
|
+
}
|
|
438
|
+
return [...n].toSorted((e, t) => e.localeCompare(t));
|
|
439
|
+
}
|
|
440
|
+
resolveDirectories(e) {
|
|
441
|
+
let t = this.resolveProjectNames(e);
|
|
442
|
+
return {
|
|
443
|
+
...t,
|
|
444
|
+
directories: this.toDirectories({
|
|
445
|
+
graph: e.graph,
|
|
446
|
+
projectNames: t.projectNames
|
|
447
|
+
})
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
resolveProjectNames(e) {
|
|
451
|
+
let t = this.readProjects(e.graph), n = new Set(t.map((e) => e.name)), r = /* @__PURE__ */ new Set(), i = [];
|
|
452
|
+
for (let t of e.projectNames ?? []) {
|
|
453
|
+
if (n.has(t)) {
|
|
454
|
+
r.add(t);
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
i.push(t);
|
|
458
|
+
}
|
|
459
|
+
let a = this.resolveTaggedNames({
|
|
460
|
+
projects: t,
|
|
461
|
+
tags: e.tags ?? []
|
|
462
|
+
});
|
|
463
|
+
for (let e of a.names) r.add(e);
|
|
464
|
+
return {
|
|
465
|
+
knownNames: t.map((e) => e.name),
|
|
466
|
+
knownTags: this.readTags(t),
|
|
467
|
+
projectNames: [...r].toSorted((e, t) => e.localeCompare(t)),
|
|
468
|
+
unknownNames: i,
|
|
469
|
+
unmatchedTags: a.unmatchedTags
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
toDirectories(e) {
|
|
473
|
+
let t = new Map(this.readProjects(e.graph).map((e) => [e.name, e.root])), n = /* @__PURE__ */ new Set();
|
|
474
|
+
for (let r of e.projectNames) {
|
|
475
|
+
let e = t.get(r);
|
|
476
|
+
e !== void 0 && n.add(e);
|
|
477
|
+
}
|
|
478
|
+
return [...n].toSorted((e, t) => e.localeCompare(t));
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
G = A([r(), k("design:paramtypes", [])], G);
|
|
482
|
+
//#endregion
|
|
483
|
+
//#region packages/ic-suite/callidescope/callidescope-nx/src/modules/projects/projects.module.ts
|
|
484
|
+
var K = class {};
|
|
485
|
+
K = A([i({
|
|
486
|
+
controllers: [],
|
|
487
|
+
exports: [G],
|
|
488
|
+
imports: [],
|
|
489
|
+
providers: [G]
|
|
490
|
+
})], K);
|
|
491
|
+
//#endregion
|
|
492
|
+
//#region packages/ic-suite/callidescope/callidescope-nx/src/modules/run-configuration/run-configuration.constants.ts
|
|
493
|
+
var ce = "nx.json", q = class {
|
|
494
|
+
configurationService;
|
|
495
|
+
optionsService;
|
|
496
|
+
constructor(e, t) {
|
|
497
|
+
this.configurationService = e, this.optionsService = t;
|
|
498
|
+
}
|
|
499
|
+
readNxConfiguration(e) {
|
|
500
|
+
try {
|
|
501
|
+
return JSON.parse(c(l.join(e, ce), "utf8"));
|
|
502
|
+
} catch {
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
async load(e) {
|
|
507
|
+
let t = e.configurationPath ?? this.optionsService.resolveConfigurationPath({
|
|
508
|
+
exists: (t) => o(l.join(e.workspaceRoot, t)),
|
|
509
|
+
nxConfiguration: this.readNxConfiguration(e.workspaceRoot)
|
|
510
|
+
}), n = await this.configurationService.loadConfigurationFile({
|
|
511
|
+
configurationPath: t,
|
|
512
|
+
searchDirectory: e.workspaceRoot
|
|
513
|
+
});
|
|
514
|
+
return {
|
|
515
|
+
configuration: n.configuration,
|
|
516
|
+
path: n.path
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
q = A([r(), k("design:paramtypes", [C === void 0 ? Object : C, U === void 0 ? Object : U])], q);
|
|
521
|
+
//#endregion
|
|
522
|
+
//#region packages/ic-suite/callidescope/callidescope-nx/src/modules/run-configuration/run-configuration.module.ts
|
|
523
|
+
var J = class {};
|
|
524
|
+
J = A([i({
|
|
525
|
+
controllers: [],
|
|
526
|
+
exports: [q],
|
|
527
|
+
imports: [S, W],
|
|
528
|
+
providers: [q]
|
|
529
|
+
})], J);
|
|
530
|
+
//#endregion
|
|
531
|
+
//#region packages/ic-suite/callidescope/callidescope-nx/src/modules/plugin/plugin.constants.ts
|
|
532
|
+
var le = "**/{project.json,callidescope.config.*}", ue = "{projectRoot}/callidescope.config.*", Y = "__callidescopePluginContext", de = (e) => [
|
|
533
|
+
"## Read nothing of its own (0 files)",
|
|
534
|
+
"",
|
|
535
|
+
`This run judged ${e.length === 1 ? "a project" : "projects"} whose own code it never read:`,
|
|
536
|
+
"",
|
|
537
|
+
...e.map((e) => `- \`${e}\``),
|
|
538
|
+
"",
|
|
539
|
+
"A `gate` fails on this and a `trace` does not: a gate that never looked",
|
|
540
|
+
"cannot tell a clean project from an unread one, where a trace decides",
|
|
541
|
+
"nothing and is a report for a reader to open. The run itself was not",
|
|
542
|
+
"empty — the dependencies it traced were read — so only the judged",
|
|
543
|
+
"project's own sources went missing.",
|
|
544
|
+
"",
|
|
545
|
+
"Check `exclude` and `excludeFrom` in the workspace callidescope",
|
|
546
|
+
"configuration and `exclude` in the project's own `callidescope.config.*`",
|
|
547
|
+
"for a pattern matching everything that project holds, and check that the",
|
|
548
|
+
"project still holds sources its `tsconfig.json` includes."
|
|
549
|
+
].join("\n"), fe = [
|
|
550
|
+
"## Traced nothing (0 callables)",
|
|
551
|
+
"",
|
|
552
|
+
"This gate read no code, so it judged none. It fails rather than passing:",
|
|
553
|
+
"a gate that never looked cannot tell a clean project from an unread one.",
|
|
554
|
+
"",
|
|
555
|
+
"Check `exclude` and `excludeFrom` in the workspace callidescope",
|
|
556
|
+
"configuration and in this project's own `callidescope.config.*` for a",
|
|
557
|
+
"pattern matching everything the project holds."
|
|
558
|
+
].join("\n"), pe = [
|
|
559
|
+
"## Traced nothing (no directories in scope)",
|
|
560
|
+
"",
|
|
561
|
+
"This gate's Nx selection resolved to no directory, so nothing was traced",
|
|
562
|
+
"and nothing was judged. It fails rather than passing: a gate that never",
|
|
563
|
+
"looked cannot tell a clean project from an unread one.",
|
|
564
|
+
"",
|
|
565
|
+
"Check the `projects` and `tags` this target was given, and whether the",
|
|
566
|
+
"projects they name still hold a root of their own."
|
|
567
|
+
].join("\n"), X = class {
|
|
568
|
+
callidescopeService;
|
|
569
|
+
configurationService;
|
|
570
|
+
fileFilterService;
|
|
571
|
+
markdownReportService;
|
|
572
|
+
optionsService;
|
|
573
|
+
projectReportsService;
|
|
574
|
+
projectsService;
|
|
575
|
+
runConfigurationService;
|
|
576
|
+
constructor(e, t, n, r, i, a, o, s) {
|
|
577
|
+
this.callidescopeService = e, this.configurationService = t, this.fileFilterService = n, this.markdownReportService = r, this.optionsService = i, this.projectReportsService = a, this.projectsService = o, this.runConfigurationService = s;
|
|
578
|
+
}
|
|
579
|
+
async buildExclusionFilter(e) {
|
|
580
|
+
try {
|
|
581
|
+
let { configuration: t } = await this.configurationService.loadConfigurationFile({
|
|
582
|
+
configurationPath: e.configurationPath,
|
|
583
|
+
searchDirectory: e.workspaceRoot
|
|
584
|
+
});
|
|
585
|
+
return this.fileFilterService.buildFileFilter({
|
|
586
|
+
exclude: t.exclude,
|
|
587
|
+
excludeFrom: t.excludeFrom,
|
|
588
|
+
workspaceRoot: e.workspaceRoot
|
|
589
|
+
});
|
|
590
|
+
} catch {
|
|
591
|
+
return { isExcluded: () => !1 };
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
buildInferredTargets(e) {
|
|
595
|
+
let { pluginOptions: t } = e, n = [
|
|
596
|
+
"default",
|
|
597
|
+
"^default",
|
|
598
|
+
`{workspaceRoot}/${t.configurationPath}`
|
|
599
|
+
], r = {
|
|
600
|
+
[t.breadthTargetName]: {
|
|
601
|
+
cache: !0,
|
|
602
|
+
executor: `${I}:breadth`,
|
|
603
|
+
inputs: n,
|
|
604
|
+
options: {}
|
|
605
|
+
},
|
|
606
|
+
[t.depthTargetName]: {
|
|
607
|
+
cache: !0,
|
|
608
|
+
executor: `${I}:depth`,
|
|
609
|
+
inputs: n,
|
|
610
|
+
options: {}
|
|
611
|
+
},
|
|
612
|
+
[t.traceTargetName]: {
|
|
613
|
+
cache: !0,
|
|
614
|
+
executor: `${I}:trace`,
|
|
615
|
+
inputs: n,
|
|
616
|
+
options: {}
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
return e.isExcluded ? r : {
|
|
620
|
+
...r,
|
|
621
|
+
[t.gateTargetName]: {
|
|
622
|
+
cache: !0,
|
|
623
|
+
executor: `${I}:gate`,
|
|
624
|
+
inputs: [...n, ue],
|
|
625
|
+
options: {}
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
explainVerdict(e) {
|
|
630
|
+
return e.unreadProjectNames.length > 0 ? de(e.unreadProjectNames) : e.reason;
|
|
631
|
+
}
|
|
632
|
+
holdsProgram(e) {
|
|
633
|
+
return o(l.join(e.workspaceRoot, e.projectRoot, H));
|
|
634
|
+
}
|
|
635
|
+
isExcludedProject(e) {
|
|
636
|
+
return e.fileFilter.isExcluded(l.posix.join(e.projectRoot, H));
|
|
637
|
+
}
|
|
638
|
+
judge(e) {
|
|
639
|
+
let t = this.projectReportsService.findOwnedFindings({
|
|
640
|
+
limits: e.projectLimits,
|
|
641
|
+
projectNames: e.judgedProjectNames,
|
|
642
|
+
reports: e.result.projects
|
|
643
|
+
}), n = this.projectReportsService.findUnreadProjects({
|
|
644
|
+
projectNames: e.judgedProjectNames,
|
|
645
|
+
reports: e.result.projects
|
|
646
|
+
});
|
|
647
|
+
return e.result.summary.callableCount === 0 ? {
|
|
648
|
+
findings: t,
|
|
649
|
+
ok: !1,
|
|
650
|
+
reason: fe,
|
|
651
|
+
unreadProjectNames: n
|
|
652
|
+
} : {
|
|
653
|
+
findings: t,
|
|
654
|
+
ok: t.deepStacks.length === 0 && t.wideCallables.length === 0,
|
|
655
|
+
reason: void 0,
|
|
656
|
+
unreadProjectNames: n
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
describeRefusedScope(e) {
|
|
660
|
+
return [e.unknownNames.length > 0 ? `Unknown Nx projects: ${e.unknownNames.join(", ")}. Known: ${e.knownNames.join(", ")}.` : void 0, e.unmatchedTags.length > 0 ? `Unmatched Nx tags: ${e.unmatchedTags.join(", ")}. Known: ${e.knownTags.join(", ")}.` : void 0].filter((e) => e !== void 0).join(" ");
|
|
661
|
+
}
|
|
662
|
+
async inferTargets(e) {
|
|
663
|
+
let t = this.optionsService.resolvePluginOptions(e.options), n = await this.buildExclusionFilter({
|
|
664
|
+
configurationPath: t.configurationPath,
|
|
665
|
+
workspaceRoot: e.workspaceRoot
|
|
666
|
+
}), r = /* @__PURE__ */ new Map();
|
|
667
|
+
for (let i of e.projectConfigurationFiles) {
|
|
668
|
+
if (l.basename(i) !== "project.json") continue;
|
|
669
|
+
let a = l.dirname(i);
|
|
670
|
+
a !== "." && this.holdsProgram({
|
|
671
|
+
projectRoot: a,
|
|
672
|
+
workspaceRoot: e.workspaceRoot
|
|
673
|
+
}) && r.set(a, this.buildInferredTargets({
|
|
674
|
+
isExcluded: this.isExcludedProject({
|
|
675
|
+
fileFilter: n,
|
|
676
|
+
projectRoot: a
|
|
677
|
+
}),
|
|
678
|
+
pluginOptions: t
|
|
679
|
+
}));
|
|
680
|
+
}
|
|
681
|
+
return r;
|
|
682
|
+
}
|
|
683
|
+
async resolveTraceScope(e) {
|
|
684
|
+
let t = await this.projectsService.readProjectGraph(), n = this.projectsService.resolveProjectNames({
|
|
685
|
+
graph: t,
|
|
686
|
+
projectNames: e.projectNames,
|
|
687
|
+
tags: e.tags
|
|
688
|
+
}), r = e.withDependencies ? this.projectsService.resolveDependencyClosure({
|
|
689
|
+
graph: t,
|
|
690
|
+
projectNames: n.projectNames
|
|
691
|
+
}) : n.projectNames;
|
|
692
|
+
return {
|
|
693
|
+
directories: this.projectsService.resolveDirectories({
|
|
694
|
+
graph: t,
|
|
695
|
+
projectNames: r
|
|
696
|
+
}).directories,
|
|
697
|
+
knownNames: n.knownNames,
|
|
698
|
+
knownTags: n.knownTags,
|
|
699
|
+
projectNames: r,
|
|
700
|
+
selectedDirectories: this.projectsService.resolveDirectories({
|
|
701
|
+
graph: t,
|
|
702
|
+
projectNames: n.projectNames
|
|
703
|
+
}).directories,
|
|
704
|
+
unknownNames: n.unknownNames,
|
|
705
|
+
unmatchedTags: n.unmatchedTags
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
async runGate(e) {
|
|
709
|
+
let { configuration: t, path: n } = await this.runConfigurationService.load(e), r = await this.callidescopeService.trace({
|
|
710
|
+
configuration: t,
|
|
711
|
+
configurationPath: n,
|
|
712
|
+
directories: e.directories,
|
|
713
|
+
workspaceRoot: e.workspaceRoot
|
|
714
|
+
}), i = this.judge({
|
|
715
|
+
judgedProjectNames: e.judgedProjectNames,
|
|
716
|
+
projectLimits: r.projectLimits,
|
|
717
|
+
result: r.result
|
|
718
|
+
});
|
|
719
|
+
return {
|
|
720
|
+
ok: i.ok && i.unreadProjectNames.length === 0,
|
|
721
|
+
report: this.explainVerdict(i) ?? this.markdownReportService.renderFindings({
|
|
722
|
+
...i.findings,
|
|
723
|
+
previewCount: T
|
|
724
|
+
})
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
async runTrace(e) {
|
|
728
|
+
let { configuration: t, path: n } = await this.runConfigurationService.load(e), r = e.format ?? w, i = await this.callidescopeService.trace({
|
|
729
|
+
configuration: t,
|
|
730
|
+
configurationPath: n,
|
|
731
|
+
directories: e.directories,
|
|
732
|
+
workspaceRoot: e.workspaceRoot
|
|
733
|
+
}), a = this.judge({
|
|
734
|
+
judgedProjectNames: e.judgedProjectNames,
|
|
735
|
+
projectLimits: i.projectLimits,
|
|
736
|
+
result: i.result
|
|
737
|
+
}), o = this.markdownReportService.renderRun({
|
|
738
|
+
description: void 0,
|
|
739
|
+
heading: ae,
|
|
740
|
+
limits: i.projectLimits,
|
|
741
|
+
previewCount: T,
|
|
742
|
+
rendering: r === "mermaid" ? "diagram" : "tree",
|
|
743
|
+
result: i.result
|
|
744
|
+
}), s = this.explainVerdict(a);
|
|
745
|
+
return {
|
|
746
|
+
ok: a.ok,
|
|
747
|
+
report: s === void 0 ? o : `${o}\n${s}`
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
X = A([r(), k("design:paramtypes", [
|
|
752
|
+
f === void 0 ? Object : f,
|
|
753
|
+
C === void 0 ? Object : C,
|
|
754
|
+
h === void 0 ? Object : h,
|
|
755
|
+
y === void 0 ? Object : y,
|
|
756
|
+
U === void 0 ? Object : U,
|
|
757
|
+
x === void 0 ? Object : x,
|
|
758
|
+
G === void 0 ? Object : G,
|
|
759
|
+
q === void 0 ? Object : q
|
|
760
|
+
])], X);
|
|
761
|
+
//#endregion
|
|
762
|
+
//#region packages/ic-suite/callidescope/callidescope-nx/src/modules/plugin/plugin.module.ts
|
|
763
|
+
var Z = class {};
|
|
764
|
+
Z = A([i({
|
|
765
|
+
controllers: [],
|
|
766
|
+
exports: [X],
|
|
767
|
+
imports: [
|
|
768
|
+
te,
|
|
769
|
+
S,
|
|
770
|
+
N,
|
|
771
|
+
W,
|
|
772
|
+
b,
|
|
773
|
+
K,
|
|
774
|
+
re,
|
|
775
|
+
J,
|
|
776
|
+
ne
|
|
777
|
+
],
|
|
778
|
+
providers: [X]
|
|
779
|
+
})], Z);
|
|
780
|
+
//#endregion
|
|
781
|
+
//#region packages/ic-suite/callidescope/callidescope-nx/src/main.module.ts
|
|
782
|
+
var Q = class {};
|
|
783
|
+
Q = A([i({
|
|
784
|
+
controllers: [],
|
|
785
|
+
exports: [F, Z],
|
|
786
|
+
imports: [
|
|
787
|
+
F,
|
|
788
|
+
N,
|
|
789
|
+
Z
|
|
790
|
+
],
|
|
791
|
+
providers: []
|
|
792
|
+
})], Q);
|
|
793
|
+
//#endregion
|
|
794
|
+
//#region packages/ic-suite/callidescope/callidescope-nx/src/modules/plugin/plugin-context.utilities.ts
|
|
795
|
+
async function me() {
|
|
796
|
+
return (await $()).get(P);
|
|
797
|
+
}
|
|
798
|
+
async function he() {
|
|
799
|
+
return (await $()).get(U);
|
|
800
|
+
}
|
|
801
|
+
async function ge() {
|
|
802
|
+
return (await $()).get(X);
|
|
803
|
+
}
|
|
804
|
+
async function _e() {
|
|
805
|
+
return (await $()).get(G);
|
|
806
|
+
}
|
|
807
|
+
async function $() {
|
|
808
|
+
let t = globalThis;
|
|
809
|
+
return t[Y] ??= e.createApplicationContext(Q, {
|
|
810
|
+
abortOnError: !1,
|
|
811
|
+
logger: !1
|
|
812
|
+
}), await t[Y];
|
|
813
|
+
}
|
|
814
|
+
//#endregion
|
|
815
|
+
export { B as _, Q as a, P as b, pe as c, G as d, W as f, R as g, z as h, _e as i, le as l, I as m, he as n, Z as o, U as p, ge as r, X as s, me as t, K as u, L as v, F as y };
|