@conformetry/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.
@@ -0,0 +1,973 @@
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 o, { existsSync as s, mkdirSync as c, readFileSync as l, readdirSync as u } from "node:fs";
5
+ import d from "node:path";
6
+ import f from "pino";
7
+ import { ConfigurationModule as p, ConfigurationService as m } from "@conformetry/configuration";
8
+ import { GenerationModule as h, GenerationService as g } from "@conformetry/generation";
9
+ import { ReportingModule as _, ReportingService as v } from "@conformetry/output";
10
+ import { ValidationModule as y, ValidationService as b } from "@conformetry/validation";
11
+ import { formatFiles as ee, getProjects as te, readProjectConfiguration as ne } from "@nx/devkit";
12
+ //#region packages/logger/src/modules/logger/logger.constants.ts
13
+ var re = /^(\p{Extended_Pictographic}️?(?:‍\p{Extended_Pictographic}️?)*)\s+/u, ie = /^([A-Za-z]+)/, ae = /* @__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
+ ]), oe = /* @__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 x(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 S(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 C, w = class extends t {
58
+ static {
59
+ C = this;
60
+ }
61
+ constructor() {
62
+ super();
63
+ }
64
+ static isProduction = process.env.NODE_ENV === "production";
65
+ static rootLogger;
66
+ static writesToStandardError = !1;
67
+ child = C.root;
68
+ static createRootLogger() {
69
+ let e = process.env.LOG_LEVEL ?? "info";
70
+ return C.isProduction ? C.writesToStandardError ? f({ level: e }, f.destination(2)) : f({ level: e }) : f({
71
+ level: e,
72
+ transport: {
73
+ options: {
74
+ colorize: !0,
75
+ destination: C.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 (C.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
+ C.writesToStandardError = !0;
90
+ }
91
+ assertConventionalMessage(e) {
92
+ if (C.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
+ ...C.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 = ie.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") || ae.has(t);
115
+ }
116
+ parseMessage(e) {
117
+ let t = String(e), n = re.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 && oe.has(e);
128
+ }
129
+ static get root() {
130
+ return C.rootLogger ??= C.createRootLogger(), C.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 = d.join(process.cwd(), "output");
141
+ return s(t) || c(t, { recursive: !0 }), d.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 = C.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
+ w = C = S([r({ scope: a.TRANSIENT }), x("design:paramtypes", [])], w);
194
+ //#endregion
195
+ //#region packages/logger/src/modules/logger/logger.module.ts
196
+ var T = class {};
197
+ T = S([n(), i({
198
+ controllers: [],
199
+ exports: [w],
200
+ imports: [],
201
+ providers: [w]
202
+ })], T);
203
+ //#endregion
204
+ //#region packages/ic-suite/conformetry/conformetry-nx/src/modules/scope/scope.service.ts
205
+ var E = class {
206
+ configurationService;
207
+ constructor(e) {
208
+ this.configurationService = e;
209
+ }
210
+ isProjectGroup(e) {
211
+ return this.configurationService.isProjectScoped(e);
212
+ }
213
+ matchesProject(e) {
214
+ return !this.isProjectGroup(e.group) || (e.group.tags ?? []).every((t) => e.project.tags.includes(t));
215
+ }
216
+ resolveGroup(e) {
217
+ let t = e.group.patterns;
218
+ return !this.matchesProject(e) || t === void 0 || t.length === 0 ? [] : this.isProjectGroup(e.group) ? [{
219
+ ...e.group,
220
+ patterns: t.map((t) => d.posix.join(e.project.root, t))
221
+ }] : [e.group];
222
+ }
223
+ resolveScopedDirectory(e) {
224
+ let [t] = e.find((e) => this.isProjectGroup(e))?.patterns ?? [];
225
+ if (t === void 0 || t === ".") return;
226
+ let n = t.split("/"), r = n.findIndex((e) => e.includes("*")), i = r === -1 ? n : n.slice(0, r);
227
+ return i.length === 0 ? void 0 : i.join("/");
228
+ }
229
+ resolveScopedProjectNames(e) {
230
+ let t = e.groups.filter((e) => this.isProjectGroup(e));
231
+ return t.length === 0 ? [] : e.projects.filter((e) => t.some((t) => this.matchesProject({
232
+ group: t,
233
+ project: e
234
+ }))).map((e) => e.name).toSorted((e, t) => e.localeCompare(t));
235
+ }
236
+ };
237
+ E = S([r(), x("design:paramtypes", [m === void 0 ? Object : m])], E);
238
+ //#endregion
239
+ //#region packages/ic-suite/conformetry/conformetry-nx/src/modules/scope/scope.module.ts
240
+ var D = class {};
241
+ D = S([i({
242
+ controllers: [],
243
+ exports: [E],
244
+ imports: [p],
245
+ providers: [E]
246
+ })], D);
247
+ //#endregion
248
+ //#region packages/ic-suite/conformetry/conformetry-nx/src/modules/paths/paths.constants.ts
249
+ var O = "project", se = "module", k = "type", A = "directory", j = ".conformetry/nx-generators", ce = "// Generated from the conformetry configuration. Do not edit.", le = "The conformetry generator plugin is out of sync with the conformetry configuration.", M = "conformetry", ue = "node_modules/@nx/devkit/src/generators/generators-schema.json", N = class {
250
+ configurationService;
251
+ scopeService;
252
+ constructor(e, t) {
253
+ this.configurationService = e, this.scopeService = t;
254
+ }
255
+ buildGeneratorModule(e) {
256
+ return [
257
+ ce,
258
+ "",
259
+ "import { runConformetryGenerator } from \"@conformetry/nx\";",
260
+ "",
261
+ "import type { Tree } from \"@nx/devkit\";",
262
+ "",
263
+ "/**",
264
+ ` * Runs the \`${e.name}\` conformetry generator.`,
265
+ " */",
266
+ "export async function generate(",
267
+ " tree: Tree,",
268
+ " options?: Record<string, unknown>,",
269
+ "): Promise<void> {",
270
+ " await runConformetryGenerator({",
271
+ ` generatorName: "${e.name}",`,
272
+ " ...(options === undefined ? {} : { options }),",
273
+ " tree,",
274
+ " });",
275
+ "}",
276
+ ""
277
+ ].join("\n");
278
+ }
279
+ buildGeneratorsManifest(e) {
280
+ let t = {};
281
+ for (let n of e.definitions) t[n.name] = {
282
+ ...n.description === void 0 ? {} : { description: n.description },
283
+ factory: `./src/generators/${n.name}#generate`,
284
+ schema: `./src/schemas/${n.name}.json`
285
+ };
286
+ return this.stringify({
287
+ $schema: d.relative(e.outputPath, ue).split(d.sep).join("/"),
288
+ generators: t
289
+ });
290
+ }
291
+ buildSchema(e) {
292
+ return this.stringify({
293
+ $schema: "http://json-schema.org/schema",
294
+ ...e.definition.description === void 0 ? {} : { description: e.definition.description },
295
+ properties: this.buildSchemaProperties(e),
296
+ required: Object.keys(e.definition.inputs),
297
+ title: e.definition.name,
298
+ type: "object"
299
+ });
300
+ }
301
+ buildSchemaProperties(e) {
302
+ let t = e.definition.inputs[O];
303
+ return t === void 0 || e.scopedProjectNames === void 0 || e.scopedProjectNames.length === 0 ? e.definition.inputs : {
304
+ ...e.definition.inputs,
305
+ [O]: {
306
+ ...t,
307
+ enum: e.scopedProjectNames,
308
+ "x-prompt": {
309
+ items: e.scopedProjectNames,
310
+ message: `Which project should this ${e.definition.name} go in?`,
311
+ type: "list"
312
+ }
313
+ }
314
+ };
315
+ }
316
+ resolveScopedProjectNames(e) {
317
+ if (e.projects === void 0) return;
318
+ let t = this.scopeService.resolveScopedProjectNames({
319
+ groups: e.definition.instances,
320
+ projects: [...e.projects]
321
+ });
322
+ return t.length === 0 ? void 0 : t;
323
+ }
324
+ stringify(e) {
325
+ return `${JSON.stringify(e, void 0, 2)}\n`;
326
+ }
327
+ async emitPlugin(e) {
328
+ let t = (await this.configurationService.loadConformetryConfiguration(e.configurationPath)).toSorted((e, t) => e.name.localeCompare(t.name));
329
+ return [
330
+ {
331
+ content: this.buildGeneratorsManifest({
332
+ definitions: t,
333
+ outputPath: e.outputPath
334
+ }),
335
+ filePath: d.join(e.outputPath, "generators.json")
336
+ },
337
+ ...t.map((t) => ({
338
+ content: this.buildGeneratorModule(t),
339
+ filePath: d.join(e.outputPath, `src/generators/${t.name}.ts`)
340
+ })),
341
+ ...t.map((t) => ({
342
+ content: this.buildSchema({
343
+ definition: t,
344
+ scopedProjectNames: this.resolveScopedProjectNames({
345
+ definition: t,
346
+ projects: e.projects
347
+ })
348
+ }),
349
+ filePath: d.join(e.outputPath, `src/schemas/${t.name}.json`)
350
+ })),
351
+ {
352
+ content: this.stringify({
353
+ dependencies: {
354
+ "@conformetry/nx": "workspace:*",
355
+ "@nx/devkit": "catalog:"
356
+ },
357
+ generators: "./generators.json",
358
+ name: e.packageName,
359
+ nx: { generators: "./generators.json" },
360
+ private: !0,
361
+ type: "module",
362
+ version: "0.0.1"
363
+ }),
364
+ filePath: d.join(e.outputPath, "package.json")
365
+ }
366
+ ];
367
+ }
368
+ };
369
+ N = S([r(), x("design:paramtypes", [m === void 0 ? Object : m, E === void 0 ? Object : E])], N);
370
+ //#endregion
371
+ //#region packages/ic-suite/conformetry/conformetry-nx/src/modules/generator/generator.module.ts
372
+ var P = class {};
373
+ P = S([i({
374
+ controllers: [],
375
+ exports: [
376
+ p,
377
+ N,
378
+ D
379
+ ],
380
+ imports: [p, D],
381
+ providers: [N]
382
+ })], P);
383
+ //#endregion
384
+ //#region packages/ic-suite/conformetry/conformetry-nx/src/modules/adapter/adapter.constants.ts
385
+ var de = "utf8", F = class {
386
+ constructor() {}
387
+ async listDirectory(e) {
388
+ let t = this.resolveTreePath(e);
389
+ return t === void 0 ? o.readdirSync(e.directoryPath, { withFileTypes: !0 }).map((e) => ({
390
+ isDirectory: e.isDirectory(),
391
+ name: e.name
392
+ })) : await Promise.resolve(e.tree.children(t).map((n) => ({
393
+ isDirectory: !e.tree.isFile([t, n].join("/")),
394
+ name: n
395
+ })));
396
+ }
397
+ async readFile(e) {
398
+ let t = this.resolveTreePath({
399
+ directoryPath: e.filePath,
400
+ workspaceRoot: e.workspaceRoot
401
+ }), n = t === void 0 ? null : e.tree.read(t, de);
402
+ return await Promise.resolve(n ?? o.readFileSync(e.filePath, "utf8"));
403
+ }
404
+ resolveTreePath(e) {
405
+ let t = d.relative(e.workspaceRoot, e.directoryPath);
406
+ if (!(t.startsWith("..") || d.isAbsolute(t))) return t.split(d.sep).join("/");
407
+ }
408
+ createAdapters(e) {
409
+ return {
410
+ filesystem: {
411
+ listDirectory: async (t) => await this.listDirectory({
412
+ directoryPath: t,
413
+ tree: e.tree,
414
+ workspaceRoot: e.workspaceRoot
415
+ }),
416
+ makeDirectory: async () => {
417
+ await Promise.resolve();
418
+ },
419
+ readFile: async (t) => await this.readFile({
420
+ filePath: t,
421
+ tree: e.tree,
422
+ workspaceRoot: e.workspaceRoot
423
+ }),
424
+ writeFile: async (t, n) => {
425
+ let r = this.resolveTreePath({
426
+ directoryPath: t,
427
+ workspaceRoot: e.workspaceRoot
428
+ });
429
+ e.tree.write(r ?? t, n), await Promise.resolve();
430
+ }
431
+ },
432
+ formatter: { formatFiles: async () => {
433
+ await ee(e.tree);
434
+ } }
435
+ };
436
+ }
437
+ };
438
+ F = S([r(), x("design:paramtypes", [])], F);
439
+ //#endregion
440
+ //#region packages/ic-suite/conformetry/conformetry-nx/src/modules/adapter/adapter.module.ts
441
+ var I = class {};
442
+ I = S([i({
443
+ controllers: [],
444
+ exports: [F],
445
+ imports: [],
446
+ providers: [F]
447
+ })], I);
448
+ //#endregion
449
+ //#region packages/ic-suite/conformetry/conformetry-nx/src/modules/instances/instances.service.ts
450
+ var L = class {
451
+ configurationService;
452
+ scopeService;
453
+ constructor(e, t) {
454
+ this.configurationService = e, this.scopeService = t;
455
+ }
456
+ isInsideProject(e) {
457
+ let t = d.relative(e.projectRootPath, d.join(e.instance.path, e.instance.nameStem));
458
+ return t !== ".." && !t.startsWith(`..${d.sep}`) && !d.isAbsolute(t);
459
+ }
460
+ async findProjectInstances(e) {
461
+ let t = await this.configurationService.loadConformetryConfiguration(e.configurationPath), n = d.resolve(e.workspaceRoot, e.project.root), r = t.flatMap((e) => e.instances).flatMap((t) => this.scopeService.resolveGroup({
462
+ group: t,
463
+ project: e.project
464
+ })).flatMap((t) => this.configurationService.findInstances({
465
+ patterns: t.patterns ?? [],
466
+ ...t.substitutions === void 0 ? {} : { substitutions: t.substitutions },
467
+ ...t.threshold === void 0 ? {} : { threshold: t.threshold },
468
+ workingDirectory: e.workspaceRoot
469
+ })).filter((e) => this.isInsideProject({
470
+ instance: e,
471
+ projectRootPath: n
472
+ })), i = /* @__PURE__ */ new Set();
473
+ return r.filter((e) => {
474
+ let t = [
475
+ e.path,
476
+ e.nameStem,
477
+ (e.fileScope ?? []).join(",")
478
+ ].join(":");
479
+ return !i.has(t) && (i.add(t), !0);
480
+ });
481
+ }
482
+ };
483
+ L = S([r(), x("design:paramtypes", [m === void 0 ? Object : m, E === void 0 ? Object : E])], L);
484
+ //#endregion
485
+ //#region packages/ic-suite/conformetry/conformetry-nx/src/modules/instances/instances.module.ts
486
+ var R = class {};
487
+ R = S([i({
488
+ controllers: [],
489
+ exports: [L, D],
490
+ imports: [p, D],
491
+ providers: [L]
492
+ })], R);
493
+ //#endregion
494
+ //#region packages/ic-suite/conformetry/conformetry-nx/src/modules/options/options.constants.ts
495
+ var fe = "@conformetry/nx", z = [
496
+ "conformetry.config.ts",
497
+ "conformetry.config.mts",
498
+ "conformetry.config.cts",
499
+ "conformetry.config.js",
500
+ "conformetry.config.mjs",
501
+ "conformetry.config.cjs",
502
+ "conformetry.config.json",
503
+ "conformetry.config.jsonc",
504
+ "conformetry.json",
505
+ "conformetry.jsonc",
506
+ ".conformetryrc.ts",
507
+ ".conformetryrc.js",
508
+ ".conformetryrc.json",
509
+ "conformetryrc.ts",
510
+ "conformetryrc.js",
511
+ "conformetryrc.json"
512
+ ], B = "nx.json", pe = "conformetry-validate", me = ["configurationPath", "validateTargetName"], V = class {
513
+ constructor() {}
514
+ isUnknownArray(e) {
515
+ return Array.isArray(e);
516
+ }
517
+ readRegisteredConfigurationPath(e) {
518
+ if (typeof e != "object" || !e) return;
519
+ let { plugins: t } = { ...e };
520
+ if (this.isUnknownArray(t)) for (let e of t) {
521
+ if (typeof e != "object" || !e) continue;
522
+ let { options: t, plugin: n } = { ...e };
523
+ if (n === "@conformetry/nx") return typeof t == "object" && t ? this.readString({
524
+ key: "configurationPath",
525
+ options: { ...t }
526
+ }) : void 0;
527
+ }
528
+ }
529
+ readString(e) {
530
+ let t = e.options[e.key];
531
+ return typeof t == "string" && t !== "" ? t : void 0;
532
+ }
533
+ resolveConfigurationPath(e) {
534
+ return this.readRegisteredConfigurationPath(e.nxConfiguration) ?? z.find((t) => e.exists(t)) ?? z[0];
535
+ }
536
+ resolveGeneratorInputs(e) {
537
+ if (typeof e != "object" || !e) return {};
538
+ let t = {};
539
+ for (let [n, r] of Object.entries({ ...e })) me.includes(n) || typeof r != "string" || (t[n] = r);
540
+ return t;
541
+ }
542
+ resolvePluginOptions(e) {
543
+ if (typeof e != "object" || !e) return {
544
+ configurationPath: z[0],
545
+ validateTargetName: pe
546
+ };
547
+ let t = { ...e };
548
+ return {
549
+ configurationPath: this.readString({
550
+ key: "configurationPath",
551
+ options: t
552
+ }) ?? z[0],
553
+ validateTargetName: this.readString({
554
+ key: "validateTargetName",
555
+ options: t
556
+ }) ?? "conformetry-validate"
557
+ };
558
+ }
559
+ };
560
+ V = S([r(), x("design:paramtypes", [])], V);
561
+ //#endregion
562
+ //#region packages/ic-suite/conformetry/conformetry-nx/src/modules/options/options.module.ts
563
+ var H = class {};
564
+ H = S([i({
565
+ controllers: [],
566
+ exports: [V],
567
+ imports: [],
568
+ providers: [V]
569
+ })], H);
570
+ //#endregion
571
+ //#region packages/ic-suite/conformetry/conformetry-nx/src/modules/paths/paths.service.ts
572
+ var U = class {
573
+ instancesService;
574
+ configurationService;
575
+ scopeService;
576
+ constructor(e, t, n) {
577
+ this.instancesService = e, this.configurationService = t, this.scopeService = n;
578
+ }
579
+ requireModulePath(e) {
580
+ let t = this.resolveModulePath({
581
+ instances: e.instances,
582
+ moduleName: e.moduleName
583
+ });
584
+ if (t === void 0) throw Error(`Project ${e.projectName} has no module named ${e.moduleName}. Generate the module first, or name one of its existing modules.`);
585
+ return t;
586
+ }
587
+ resolveModuleParentPath(e) {
588
+ let t = /* @__PURE__ */ new Map();
589
+ console.log("instances", e.instances);
590
+ for (let n of e.instances) {
591
+ let r = n.path;
592
+ r.startsWith(e.projectRootPath + d.sep) && t.set(r, (t.get(r) ?? 0) + 1);
593
+ }
594
+ return console.log("countsByParent", [...t.entries()]), [...t.entries()].toSorted(([e, t], [n, r]) => r - t || e.localeCompare(n))[0]?.[0];
595
+ }
596
+ resolveModulePath(e) {
597
+ let t = e.instances.find((t) => t.nameStem === e.moduleName);
598
+ return t === void 0 ? void 0 : d.join(t.path, t.nameStem);
599
+ }
600
+ resolveNewProjectPath(e) {
601
+ return e.type === void 0 ? e.workspaceRoot : d.resolve(e.workspaceRoot, this.resolveTypeDirectoryPath({
602
+ tree: e.tree,
603
+ type: e.type
604
+ }) ?? e.type);
605
+ }
606
+ async resolveScopedDirectory(e) {
607
+ if (e.generatorName === void 0) return;
608
+ let t = (await this.configurationService.loadConformetryConfiguration(e.configurationPath)).find((t) => t.name === e.generatorName);
609
+ return t === void 0 ? void 0 : this.scopeService.resolveScopedDirectory(t.instances);
610
+ }
611
+ resolveTypeDirectoryPath(e) {
612
+ for (let [, t] of te(e.tree)) {
613
+ let [n] = t.root.split("/");
614
+ if (n === e.type) return n;
615
+ }
616
+ }
617
+ async resolveGenerationPath(e) {
618
+ let t = e.inputs[A];
619
+ if (t !== void 0) return d.resolve(e.workspaceRoot, t);
620
+ let n = e.inputs[O];
621
+ if (n === void 0) return this.resolveNewProjectPath({
622
+ tree: e.tree,
623
+ type: e.inputs[k],
624
+ workspaceRoot: e.workspaceRoot
625
+ });
626
+ let r = ne(e.tree, n), i = d.resolve(e.workspaceRoot, r.root), a = await this.instancesService.findProjectInstances({
627
+ configurationPath: e.configurationPath,
628
+ project: {
629
+ name: n,
630
+ root: r.root,
631
+ tags: r.tags ?? []
632
+ },
633
+ workspaceRoot: e.workspaceRoot
634
+ }), o = e.inputs[se];
635
+ if (o !== void 0) return this.requireModulePath({
636
+ instances: a,
637
+ moduleName: o,
638
+ projectName: e.inputs.project ?? ""
639
+ });
640
+ let s = await this.resolveScopedDirectory({
641
+ configurationPath: e.configurationPath,
642
+ generatorName: e.generatorName
643
+ });
644
+ return s === void 0 ? this.resolveModuleParentPath({
645
+ instances: a,
646
+ projectRootPath: i
647
+ }) ?? i : d.join(i, s);
648
+ }
649
+ };
650
+ U = S([r(), x("design:paramtypes", [
651
+ L === void 0 ? Object : L,
652
+ m === void 0 ? Object : m,
653
+ E === void 0 ? Object : E
654
+ ])], U);
655
+ //#endregion
656
+ //#region packages/ic-suite/conformetry/conformetry-nx/src/modules/paths/paths.module.ts
657
+ var W = class {};
658
+ W = S([i({
659
+ controllers: [],
660
+ exports: [
661
+ R,
662
+ p,
663
+ U,
664
+ D
665
+ ],
666
+ imports: [
667
+ R,
668
+ p,
669
+ D
670
+ ],
671
+ providers: [U]
672
+ })], W);
673
+ var he = ".nxignore", G = class {
674
+ constructor() {}
675
+ isUnknownArray(e) {
676
+ return Array.isArray(e);
677
+ }
678
+ listProjectConfigurationFiles(e) {
679
+ let t = [];
680
+ for (let n of u(e.directoryPath, { withFileTypes: !0 })) {
681
+ let r = d.join(e.directoryPath, n.name), i = d.relative(e.workspaceRoot, r).split(d.sep).join("/");
682
+ if (n.isFile() && n.name === "project.json") {
683
+ t.push(i);
684
+ continue;
685
+ }
686
+ n.isDirectory() && !n.name.startsWith(".") && n.name !== "node_modules" && !e.ignoredPaths.includes(i) && t.push(...this.listProjectConfigurationFiles({
687
+ directoryPath: r,
688
+ ignoredPaths: e.ignoredPaths,
689
+ workspaceRoot: e.workspaceRoot
690
+ }));
691
+ }
692
+ return t;
693
+ }
694
+ readIgnoredPaths(e) {
695
+ let t = d.resolve(e, he);
696
+ return s(t) ? l(t, "utf8").split("\n").map((e) => e.trim()).filter((e) => e !== "" && !e.startsWith("#")) : [];
697
+ }
698
+ listWorkspaceProjects(e) {
699
+ return this.listProjectConfigurationFiles({
700
+ directoryPath: e,
701
+ ignoredPaths: this.readIgnoredPaths(e),
702
+ workspaceRoot: e
703
+ }).map((t) => this.readProjectScope({
704
+ projectConfigurationFile: t,
705
+ workspaceRoot: e
706
+ })).toSorted((e, t) => e.name.localeCompare(t.name));
707
+ }
708
+ readProjectScope(e) {
709
+ let t = d.dirname(e.projectConfigurationFile), n = JSON.parse(l(d.resolve(e.workspaceRoot, e.projectConfigurationFile), "utf8")), r = typeof n == "object" && n ? { ...n } : {}, i = this.isUnknownArray(r.tags) ? r.tags : [], a = typeof r.name == "string" ? r.name : t;
710
+ return {
711
+ name: a,
712
+ root: t,
713
+ tags: [...i.filter((e) => typeof e == "string"), `name:${a}`]
714
+ };
715
+ }
716
+ };
717
+ G = S([r(), x("design:paramtypes", [])], G);
718
+ //#endregion
719
+ //#region packages/ic-suite/conformetry/conformetry-nx/src/modules/projects/projects.module.ts
720
+ var K = class {};
721
+ K = S([i({
722
+ controllers: [],
723
+ exports: [G],
724
+ imports: [],
725
+ providers: [G]
726
+ })], K);
727
+ //#endregion
728
+ //#region packages/ic-suite/conformetry/conformetry-nx/src/modules/plugin/plugin.constants.ts
729
+ var ge = "**/{project.json,conformetry.config.*}", _e = "project.json", q = "__conformetryPluginContext", J, Y = J = class {
730
+ adapterService;
731
+ instancesService;
732
+ configurationService;
733
+ generatorService;
734
+ generationService;
735
+ optionsService;
736
+ pathsService;
737
+ projectsService;
738
+ reportingService;
739
+ validationService;
740
+ logger;
741
+ constructor(e, t, n, r, i, a, o, s, c, l, u) {
742
+ this.adapterService = e, this.instancesService = t, this.configurationService = n, this.generatorService = r, this.generationService = i, this.optionsService = a, this.pathsService = o, this.projectsService = s, this.reportingService = c, this.validationService = l, this.logger = u, this.logger.setContext(J.name);
743
+ }
744
+ async assertEmittedPluginCurrent(e) {
745
+ let t = await this.generatorService.emitPlugin({
746
+ configurationPath: e.configurationPath,
747
+ outputPath: j,
748
+ packageName: M,
749
+ projects: this.projectsService.listWorkspaceProjects(e.workspaceRoot)
750
+ });
751
+ for (let n of t) {
752
+ let t = d.resolve(e.workspaceRoot, n.filePath);
753
+ if ((s(t) ? l(t, "utf8") : void 0) !== n.content) throw this.logger.warn("🚫 Rejected a stale conformetry generator plugin", void 0, { filePath: n.filePath }), Error(`${n.filePath} is out of date with ${e.configurationPath}. Run \`nx sync\` to regenerate the conformetry generator plugin.`);
754
+ }
755
+ }
756
+ async assertPluginInSync(e) {
757
+ await this.assertTemplatesExist(e), await this.assertEmittedPluginCurrent(e);
758
+ }
759
+ async assertTemplatesExist(e) {
760
+ let t = await this.configurationService.loadConformetryConfiguration(e.configurationPath);
761
+ for (let n of t) {
762
+ let t = d.resolve(e.workspaceRoot, n.templatePath);
763
+ if (!s(t)) throw this.logger.warn("🚫 Rejected a generator with a missing template", void 0, {
764
+ generator: n.name,
765
+ templatePath: n.templatePath
766
+ }), Error(`Generator ${n.name} names a template at ${n.templatePath}, which does not exist.`);
767
+ }
768
+ }
769
+ readNxConfiguration(e) {
770
+ let t = d.resolve(e, B);
771
+ if (s(t)) return JSON.parse(l(t, "utf8"));
772
+ }
773
+ resolveOptions(e) {
774
+ let t = this.optionsService.resolveConfigurationPath({
775
+ exists: (t) => s(d.resolve(e.workspaceRoot, t)),
776
+ nxConfiguration: this.readNxConfiguration(e.workspaceRoot)
777
+ }), n = typeof e.options == "object" && e.options !== null ? { ...e.options } : {};
778
+ return this.optionsService.resolvePluginOptions({
779
+ configurationPath: t,
780
+ ...n
781
+ });
782
+ }
783
+ async resolveTemplateInputs(e) {
784
+ let t = await this.configurationService.loadConformetryConfiguration(e.configurationPath);
785
+ return [...new Set(t.map((e) => e.templatePath))].map((e) => `{workspaceRoot}/${e}/**/*`);
786
+ }
787
+ async resolveTemplates(e) {
788
+ return (await this.configurationService.loadConformetryConfiguration(e.configurationPath)).map((t) => this.configurationService.collectTemplate({
789
+ name: t.name,
790
+ templatePath: d.resolve(e.workspaceRoot, t.templatePath),
791
+ threshold: t.threshold
792
+ }));
793
+ }
794
+ async inferTargets(e) {
795
+ let t = this.resolveOptions({
796
+ options: e.options,
797
+ workspaceRoot: e.workspaceRoot
798
+ }), n = await this.resolveTemplateInputs({ configurationPath: t.configurationPath }), r = /* @__PURE__ */ new Map();
799
+ for (let i of e.projectConfigurationFiles.filter((e) => d.basename(e) === _e)) {
800
+ let a = this.projectsService.readProjectScope({
801
+ projectConfigurationFile: i,
802
+ workspaceRoot: e.workspaceRoot
803
+ });
804
+ a.root !== "." && (await this.instancesService.findProjectInstances({
805
+ configurationPath: t.configurationPath,
806
+ project: a,
807
+ workspaceRoot: e.workspaceRoot
808
+ })).length !== 0 && r.set(a.root, { [t.validateTargetName]: {
809
+ cache: !0,
810
+ executor: `${fe}:validate`,
811
+ inputs: [
812
+ "default",
813
+ `{workspaceRoot}/${t.configurationPath}`,
814
+ `{workspaceRoot}/${j}/**/*`,
815
+ ...n
816
+ ],
817
+ options: {}
818
+ } });
819
+ }
820
+ return r;
821
+ }
822
+ async runGenerator(e) {
823
+ let t = this.resolveOptions({
824
+ options: e.options,
825
+ workspaceRoot: e.workspaceRoot
826
+ });
827
+ await this.assertPluginInSync({
828
+ configurationPath: t.configurationPath,
829
+ workspaceRoot: e.workspaceRoot
830
+ });
831
+ let n = await this.configurationService.loadConformetryConfiguration(t.configurationPath), r = n.find((t) => t.name === e.generatorName);
832
+ if (r === void 0) throw this.logger.error("🚫 Rejected an unknown generator", void 0, { generator: e.generatorName }), Error(`Unknown conformetry generator: ${e.generatorName}. Configured generators: ${n.map((e) => e.name).join(", ")}.`);
833
+ let i = this.adapterService.createAdapters({
834
+ tree: e.tree,
835
+ workspaceRoot: e.workspaceRoot
836
+ }), a = this.optionsService.resolveGeneratorInputs(e.options), { generatedFilePaths: o } = await this.generationService.runGenerator({
837
+ definition: {
838
+ name: r.name,
839
+ templateDirectoryPath: d.resolve(e.workspaceRoot, r.templatePath)
840
+ },
841
+ filesystem: i.filesystem,
842
+ formatter: i.formatter,
843
+ inputs: a,
844
+ instancePath: await this.pathsService.resolveGenerationPath({
845
+ configurationPath: t.configurationPath,
846
+ generatorName: e.generatorName,
847
+ inputs: a,
848
+ tree: e.tree,
849
+ workspaceRoot: e.workspaceRoot
850
+ })
851
+ });
852
+ return this.logger.info("✨ Generated instance files", void 0, {
853
+ count: o.length,
854
+ generator: e.generatorName
855
+ }), o;
856
+ }
857
+ async runValidation(e) {
858
+ let t = this.resolveOptions({
859
+ options: e.options,
860
+ workspaceRoot: e.workspaceRoot
861
+ });
862
+ await this.assertPluginInSync({
863
+ configurationPath: t.configurationPath,
864
+ workspaceRoot: e.workspaceRoot
865
+ });
866
+ let n = this.validationService.validate({
867
+ instances: await this.instancesService.findProjectInstances({
868
+ configurationPath: t.configurationPath,
869
+ project: e.project,
870
+ workspaceRoot: e.workspaceRoot
871
+ }),
872
+ ...e.languageNames === void 0 ? {} : { languageNames: e.languageNames },
873
+ templates: await this.resolveTemplates({
874
+ configurationPath: t.configurationPath,
875
+ workspaceRoot: e.workspaceRoot
876
+ }),
877
+ ...e.threshold === void 0 ? {} : { threshold: e.threshold }
878
+ });
879
+ return this.logger.info("👔 Validated conformetry instances", void 0, { ok: n.ok }), {
880
+ ok: n.ok,
881
+ report: this.reportingService.formatReport({
882
+ fileResults: n.fileResults,
883
+ scores: n.scores,
884
+ workingDirectory: e.workspaceRoot
885
+ })
886
+ };
887
+ }
888
+ };
889
+ Y = J = S([r(), x("design:paramtypes", [
890
+ F === void 0 ? Object : F,
891
+ L === void 0 ? Object : L,
892
+ m === void 0 ? Object : m,
893
+ N === void 0 ? Object : N,
894
+ g === void 0 ? Object : g,
895
+ V === void 0 ? Object : V,
896
+ U === void 0 ? Object : U,
897
+ G === void 0 ? Object : G,
898
+ v === void 0 ? Object : v,
899
+ b === void 0 ? Object : b,
900
+ w === void 0 ? Object : w
901
+ ])], Y);
902
+ //#endregion
903
+ //#region packages/ic-suite/conformetry/conformetry-nx/src/modules/plugin/plugin.module.ts
904
+ var X = class {};
905
+ X = S([i({
906
+ controllers: [],
907
+ exports: [
908
+ I,
909
+ R,
910
+ p,
911
+ P,
912
+ h,
913
+ T,
914
+ H,
915
+ W,
916
+ Y,
917
+ K,
918
+ _,
919
+ D,
920
+ y
921
+ ],
922
+ imports: [
923
+ I,
924
+ R,
925
+ p,
926
+ P,
927
+ h,
928
+ T,
929
+ H,
930
+ W,
931
+ K,
932
+ _,
933
+ D,
934
+ y
935
+ ],
936
+ providers: [Y]
937
+ })], X);
938
+ //#endregion
939
+ //#region packages/ic-suite/conformetry/conformetry-nx/src/main.module.ts
940
+ var Z = class {};
941
+ Z = S([i({
942
+ controllers: [],
943
+ exports: [P, X],
944
+ imports: [
945
+ P,
946
+ T,
947
+ X
948
+ ],
949
+ providers: []
950
+ })], Z);
951
+ //#endregion
952
+ //#region packages/ic-suite/conformetry/conformetry-nx/src/modules/plugin/plugin-context.utilities.ts
953
+ async function Q() {
954
+ return (await $()).get(N);
955
+ }
956
+ async function ve() {
957
+ return (await $()).get(V);
958
+ }
959
+ async function ye() {
960
+ return (await $()).get(Y);
961
+ }
962
+ async function be() {
963
+ return (await $()).get(G);
964
+ }
965
+ async function $() {
966
+ let t = globalThis;
967
+ return t[q] ??= e.createApplicationContext(Z, {
968
+ abortOnError: !1,
969
+ logger: !1
970
+ }), await t[q];
971
+ }
972
+ //#endregion
973
+ export { M as _, Z as a, E as b, ge as c, B as d, R as f, j as g, F as h, be as i, H as l, I as m, ve as n, X as o, L as p, ye as r, Y as s, Q as t, V as u, le as v, D as y };