@conformetry/cli 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 +1301 -0
- package/dist/main.module-BIsov6qb.js +709 -0
- package/dist/src/index.d.ts +662 -0
- package/dist/src/index.js +2 -0
- package/dist/src/main.d.ts +1 -0
- package/dist/src/main.js +20 -0
- package/package.json +78 -0
|
@@ -0,0 +1,709 @@
|
|
|
1
|
+
import { ConsoleLogger as e, Global as t, Injectable as n, Module as r, Scope as i } from "@nestjs/common";
|
|
2
|
+
import { ConfigModule as a } from "@nestjs/config";
|
|
3
|
+
import { DiscoveryModule as o } from "@nestjs/core";
|
|
4
|
+
import { existsSync as s, mkdirSync as c } from "node:fs";
|
|
5
|
+
import l from "node:path";
|
|
6
|
+
import u from "pino";
|
|
7
|
+
import { z as ee } from "zod";
|
|
8
|
+
import { ALL_TEMPLATES_SELECTION as d, ConfigurationModule as f, ConfigurationService as p, InputError as m } from "@conformetry/configuration";
|
|
9
|
+
import { GenerationModule as h, GenerationService as g } from "@conformetry/generation";
|
|
10
|
+
import { Command as _, CommandRunner as v, Option as y } from "nest-commander";
|
|
11
|
+
import { InventoryModule as b, InventoryService as x, ReportingModule as te, ReportingService as S } from "@conformetry/output";
|
|
12
|
+
import { ValidationModule as C, ValidationService as w } from "@conformetry/validation";
|
|
13
|
+
//#region packages/logger/src/modules/logger/logger.constants.ts
|
|
14
|
+
var T = /^(\p{Extended_Pictographic}️?(?:\p{Extended_Pictographic}️?)*)\s+/u, E = /^([A-Za-z]+)/, D = /* @__PURE__ */ new Set([
|
|
15
|
+
"built",
|
|
16
|
+
"cut",
|
|
17
|
+
"found",
|
|
18
|
+
"got",
|
|
19
|
+
"kept",
|
|
20
|
+
"left",
|
|
21
|
+
"lost",
|
|
22
|
+
"made",
|
|
23
|
+
"put",
|
|
24
|
+
"ran",
|
|
25
|
+
"read",
|
|
26
|
+
"rebuilt",
|
|
27
|
+
"sent",
|
|
28
|
+
"set",
|
|
29
|
+
"split",
|
|
30
|
+
"took",
|
|
31
|
+
"wrote"
|
|
32
|
+
]), O = /* @__PURE__ */ new Set([
|
|
33
|
+
"CommandFactory",
|
|
34
|
+
"ExceptionHandler",
|
|
35
|
+
"GraphQLModule",
|
|
36
|
+
"InstanceLoader",
|
|
37
|
+
"NestApplication",
|
|
38
|
+
"NestFactory",
|
|
39
|
+
"RouterExplorer",
|
|
40
|
+
"RoutesResolver",
|
|
41
|
+
"TypeOrmModule"
|
|
42
|
+
]);
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region \0@oxc-project+runtime@0.151.0/helpers/esm/decorateMetadata.js
|
|
45
|
+
function k(e, t) {
|
|
46
|
+
if (typeof Reflect == "object" && typeof Reflect.metadata == "function") return Reflect.metadata(e, t);
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region \0@oxc-project+runtime@0.151.0/helpers/esm/decorate.js
|
|
50
|
+
function A(e, t, n, r) {
|
|
51
|
+
var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
|
|
52
|
+
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
|
|
53
|
+
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);
|
|
54
|
+
return i > 3 && a && Object.defineProperty(t, n, a), a;
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region packages/logger/src/modules/logger/logger.service.ts
|
|
58
|
+
var j, M = class extends e {
|
|
59
|
+
static {
|
|
60
|
+
j = this;
|
|
61
|
+
}
|
|
62
|
+
constructor() {
|
|
63
|
+
super();
|
|
64
|
+
}
|
|
65
|
+
static isProduction = process.env.NODE_ENV === "production";
|
|
66
|
+
static rootLogger;
|
|
67
|
+
static writesToStandardError = !1;
|
|
68
|
+
child = j.root;
|
|
69
|
+
static createRootLogger() {
|
|
70
|
+
let e = process.env.LOG_LEVEL ?? "info";
|
|
71
|
+
return j.isProduction ? j.writesToStandardError ? u({ level: e }, u.destination(2)) : u({ level: e }) : u({
|
|
72
|
+
level: e,
|
|
73
|
+
transport: {
|
|
74
|
+
options: {
|
|
75
|
+
colorize: !0,
|
|
76
|
+
destination: j.writesToStandardError ? 2 : 1,
|
|
77
|
+
ignore: "pid,hostname,emoji",
|
|
78
|
+
messageFormat: "{emoji} {msg}",
|
|
79
|
+
singleLine: !0
|
|
80
|
+
},
|
|
81
|
+
target: "pino-pretty"
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
static logToStandardError() {
|
|
86
|
+
if (j.rootLogger !== void 0) {
|
|
87
|
+
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.");
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
j.writesToStandardError = !0;
|
|
91
|
+
}
|
|
92
|
+
assertConventionalMessage(e) {
|
|
93
|
+
if (j.isProduction || this.shouldSkipConventionalMessageValidation(e.context)) return;
|
|
94
|
+
let t = this.getConventionalMessageViolation(e.parsed);
|
|
95
|
+
if (t !== void 0) throw Error(t);
|
|
96
|
+
}
|
|
97
|
+
buildBindings(e) {
|
|
98
|
+
return this.assertConventionalMessage({
|
|
99
|
+
context: e.context,
|
|
100
|
+
parsed: e.parsed
|
|
101
|
+
}), {
|
|
102
|
+
...e.data,
|
|
103
|
+
context: e.context,
|
|
104
|
+
...j.isProduction ? {} : { emoji: e.parsed.emoji }
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
getConventionalMessageViolation(e) {
|
|
108
|
+
let t = e.emoji, n = e.text;
|
|
109
|
+
if (t === void 0) return `Log message must start with an emoji naming its subject, then a verb: "${n}"`;
|
|
110
|
+
let r = E.exec(n)?.[1];
|
|
111
|
+
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}"`;
|
|
112
|
+
}
|
|
113
|
+
isConventionalVerb(e) {
|
|
114
|
+
let t = e.toLowerCase();
|
|
115
|
+
return t.endsWith("ing") || t.endsWith("ed") || D.has(t);
|
|
116
|
+
}
|
|
117
|
+
parseMessage(e) {
|
|
118
|
+
let t = String(e), n = T.exec(t), r = n?.[1];
|
|
119
|
+
return r === void 0 ? {
|
|
120
|
+
emoji: void 0,
|
|
121
|
+
text: t
|
|
122
|
+
} : {
|
|
123
|
+
emoji: r,
|
|
124
|
+
text: t.slice(n?.[0].length)
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
shouldSkipConventionalMessageValidation(e) {
|
|
128
|
+
return e !== void 0 && O.has(e);
|
|
129
|
+
}
|
|
130
|
+
static get root() {
|
|
131
|
+
return j.rootLogger ??= j.createRootLogger(), j.rootLogger;
|
|
132
|
+
}
|
|
133
|
+
buildErrorLogEntry(e, t) {
|
|
134
|
+
let n = t instanceof Error ? t.stack || t.message : String(t);
|
|
135
|
+
return {
|
|
136
|
+
errorMessage: n,
|
|
137
|
+
logLine: `[${(/* @__PURE__ */ new Date()).toISOString()}] ${e}: ${n}\n`
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
createTimestampedOutputLogFilePath(e) {
|
|
141
|
+
let t = l.join(process.cwd(), "output");
|
|
142
|
+
return s(t) || c(t, { recursive: !0 }), l.join(t, `${e}-${(/* @__PURE__ */ new Date()).toISOString().replaceAll(/[:.]/g, "-")}.log`);
|
|
143
|
+
}
|
|
144
|
+
debug(e, t, n) {
|
|
145
|
+
let r = this.parseMessage(e);
|
|
146
|
+
this.child.debug(this.buildBindings({
|
|
147
|
+
context: t ?? this.context,
|
|
148
|
+
data: n,
|
|
149
|
+
parsed: r
|
|
150
|
+
}), r.text);
|
|
151
|
+
}
|
|
152
|
+
error(e, t, n) {
|
|
153
|
+
let r = this.parseMessage(e), i = typeof n == "object" ? n : void 0, a = typeof n == "string" ? n : this.context;
|
|
154
|
+
this.child.error({
|
|
155
|
+
...this.buildBindings({
|
|
156
|
+
context: a,
|
|
157
|
+
data: i,
|
|
158
|
+
parsed: r
|
|
159
|
+
}),
|
|
160
|
+
stack: t
|
|
161
|
+
}, r.text);
|
|
162
|
+
}
|
|
163
|
+
info(e, t, n) {
|
|
164
|
+
let r = this.parseMessage(e);
|
|
165
|
+
this.child.info(this.buildBindings({
|
|
166
|
+
context: t ?? this.context,
|
|
167
|
+
data: n,
|
|
168
|
+
parsed: r
|
|
169
|
+
}), r.text);
|
|
170
|
+
}
|
|
171
|
+
log(e, t, n) {
|
|
172
|
+
this.info(e, t, n);
|
|
173
|
+
}
|
|
174
|
+
setContext(e) {
|
|
175
|
+
super.setContext(e), this.child = j.root.child({ context: e });
|
|
176
|
+
}
|
|
177
|
+
verbose(e, t, n) {
|
|
178
|
+
let r = this.parseMessage(e);
|
|
179
|
+
this.child.trace(this.buildBindings({
|
|
180
|
+
context: t ?? this.context,
|
|
181
|
+
data: n,
|
|
182
|
+
parsed: r
|
|
183
|
+
}), r.text);
|
|
184
|
+
}
|
|
185
|
+
warn(e, t, n) {
|
|
186
|
+
let r = this.parseMessage(e);
|
|
187
|
+
this.child.warn(this.buildBindings({
|
|
188
|
+
context: t ?? this.context,
|
|
189
|
+
data: n,
|
|
190
|
+
parsed: r
|
|
191
|
+
}), r.text);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
M = j = A([n({ scope: i.TRANSIENT }), k("design:paramtypes", [])], M);
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region packages/logger/src/modules/logger/logger.module.ts
|
|
197
|
+
var N = class {};
|
|
198
|
+
N = A([t(), r({
|
|
199
|
+
controllers: [],
|
|
200
|
+
exports: [M],
|
|
201
|
+
imports: [],
|
|
202
|
+
providers: [M]
|
|
203
|
+
})], N);
|
|
204
|
+
var P = (e) => /* @__PURE__ */ Error(`Unknown template "${e.templateName}". Available: ${e.availableTemplateNames.join(", ")}`), F = () => /* @__PURE__ */ Error("--generator was removed. Pass --template instead: it is the word the configuration, the templates command, and the conformance report already use."), I = ee.object({}), L = (e) => new m(`No template was selected. Pass --template. Available: ${e.join(", ")}`), R, z = R = class extends v {
|
|
205
|
+
configurationService;
|
|
206
|
+
generationService;
|
|
207
|
+
logger;
|
|
208
|
+
constructor(e, t, n) {
|
|
209
|
+
super(), this.configurationService = e, this.generationService = t, this.logger = n, this.logger.setContext(R.name);
|
|
210
|
+
}
|
|
211
|
+
async generate(e, t) {
|
|
212
|
+
let n = [...e, ...process.argv.slice(2)];
|
|
213
|
+
this.rejectRemovedGeneratorOption(n);
|
|
214
|
+
let r = await this.configurationService.loadConformetryConfiguration(t.config ?? "configuration/conformetry.config.ts"), i = await this.resolveTemplateName({
|
|
215
|
+
configuration: r,
|
|
216
|
+
templateName: t.template
|
|
217
|
+
});
|
|
218
|
+
this.logger.debug("🏗 Generating a conformetry instance", void 0, { template: i });
|
|
219
|
+
let a = r.find((e) => e.name === i);
|
|
220
|
+
if (a === void 0) throw this.logger.error("🚫 Rejected an unknown template", void 0, { template: i }), P({
|
|
221
|
+
availableTemplateNames: r.map((e) => e.name),
|
|
222
|
+
templateName: i
|
|
223
|
+
});
|
|
224
|
+
let o = {
|
|
225
|
+
properties: a.inputs,
|
|
226
|
+
required: Object.keys(a.inputs)
|
|
227
|
+
}, s = await this.configurationService.resolveGeneratorInputs({
|
|
228
|
+
rawArguments: n,
|
|
229
|
+
schema: o
|
|
230
|
+
}), c = await this.generationService.runGenerator({
|
|
231
|
+
definition: {
|
|
232
|
+
name: a.name,
|
|
233
|
+
templateDirectoryPath: a.templatePath
|
|
234
|
+
},
|
|
235
|
+
inputs: s,
|
|
236
|
+
instancePath: t.directory ?? `generated/${a.name}`
|
|
237
|
+
});
|
|
238
|
+
process.stdout.write(`${c.generatedFilePaths.map((e) => ` ${e}`).join("\n")}\n`), this.logger.info("✨ Generated instance files", void 0, {
|
|
239
|
+
count: c.generatedFilePaths.length,
|
|
240
|
+
outputDirectoryPath: c.outputDirectoryPath
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
rejectCommandLine(e) {
|
|
244
|
+
this.logger.error("🚫 Rejected the command line", void 0, { reason: e.message }), process.exitCode = 1;
|
|
245
|
+
}
|
|
246
|
+
rejectRemovedGeneratorOption(e) {
|
|
247
|
+
if (e.some((e) => e === "--generator" || e.startsWith("--generator="))) throw this.logger.error("🚫 Rejected a removed option", void 0, { option: "--generator" }), F();
|
|
248
|
+
}
|
|
249
|
+
async resolveTemplateName(e) {
|
|
250
|
+
if (e.templateName !== void 0) return e.templateName;
|
|
251
|
+
let t = e.configuration.map((e) => e.name);
|
|
252
|
+
if (!this.configurationService.isAtTerminal()) throw L(t);
|
|
253
|
+
let n = await this.configurationService.promptForTemplate(e.configuration);
|
|
254
|
+
if (n === void 0) throw L(t);
|
|
255
|
+
return n;
|
|
256
|
+
}
|
|
257
|
+
parseConfig(e) {
|
|
258
|
+
return this.configurationService.parseOptionalOption(e);
|
|
259
|
+
}
|
|
260
|
+
parseDirectory(e) {
|
|
261
|
+
return this.configurationService.parseOptionalOption(e);
|
|
262
|
+
}
|
|
263
|
+
parseTemplate(e) {
|
|
264
|
+
return this.configurationService.parseOptionalOption(e);
|
|
265
|
+
}
|
|
266
|
+
async run(e, t) {
|
|
267
|
+
try {
|
|
268
|
+
await this.generate(e, t);
|
|
269
|
+
} catch (e) {
|
|
270
|
+
if (!(e instanceof m)) throw e;
|
|
271
|
+
this.rejectCommandLine(e);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
A([
|
|
276
|
+
y({
|
|
277
|
+
description: "Path to the conformetry configuration file",
|
|
278
|
+
flags: "--config [path]"
|
|
279
|
+
}),
|
|
280
|
+
k("design:type", Function),
|
|
281
|
+
k("design:paramtypes", [Object]),
|
|
282
|
+
k("design:returntype", Object)
|
|
283
|
+
], z.prototype, "parseConfig", null), A([
|
|
284
|
+
y({
|
|
285
|
+
description: "Directory to write generated files into",
|
|
286
|
+
flags: "--directory [path]"
|
|
287
|
+
}),
|
|
288
|
+
k("design:type", Function),
|
|
289
|
+
k("design:paramtypes", [Object]),
|
|
290
|
+
k("design:returntype", Object)
|
|
291
|
+
], z.prototype, "parseDirectory", null), A([
|
|
292
|
+
y({
|
|
293
|
+
description: "Name of the template to render",
|
|
294
|
+
flags: "--template [name]"
|
|
295
|
+
}),
|
|
296
|
+
k("design:type", Function),
|
|
297
|
+
k("design:paramtypes", [Object]),
|
|
298
|
+
k("design:returntype", Object)
|
|
299
|
+
], z.prototype, "parseTemplate", null), z = R = A([
|
|
300
|
+
_({
|
|
301
|
+
allowUnknownOptions: !0,
|
|
302
|
+
description: "Render a template into a new instance",
|
|
303
|
+
name: "generate"
|
|
304
|
+
}),
|
|
305
|
+
n(),
|
|
306
|
+
k("design:paramtypes", [
|
|
307
|
+
p === void 0 ? Object : p,
|
|
308
|
+
g === void 0 ? Object : g,
|
|
309
|
+
M === void 0 ? Object : M
|
|
310
|
+
])
|
|
311
|
+
], z);
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region packages/ic-suite/conformetry/conformetry-cli/src/modules/generate/generate.module.ts
|
|
314
|
+
var B = class {};
|
|
315
|
+
B = A([r({
|
|
316
|
+
controllers: [],
|
|
317
|
+
exports: [z],
|
|
318
|
+
imports: [
|
|
319
|
+
f,
|
|
320
|
+
h,
|
|
321
|
+
N
|
|
322
|
+
],
|
|
323
|
+
providers: [z]
|
|
324
|
+
})], B);
|
|
325
|
+
//#endregion
|
|
326
|
+
//#region packages/ic-suite/conformetry/conformetry-cli/src/modules/instances/instances.constants.ts
|
|
327
|
+
var ne = "No instances were found. Check the instance globs in the configuration.", V = "No instance is explained by those templates.", H, U = H = class extends v {
|
|
328
|
+
configurationService;
|
|
329
|
+
inventoryService;
|
|
330
|
+
logger;
|
|
331
|
+
constructor(e, t, n) {
|
|
332
|
+
super(), this.configurationService = e, this.inventoryService = t, this.logger = n, this.logger.setContext(H.name);
|
|
333
|
+
}
|
|
334
|
+
parseConfig(e) {
|
|
335
|
+
return this.configurationService.parseOptionalOption(e);
|
|
336
|
+
}
|
|
337
|
+
parseJson() {
|
|
338
|
+
return !0;
|
|
339
|
+
}
|
|
340
|
+
parseTemplates(e) {
|
|
341
|
+
return this.configurationService.parseCommaDelimitedOption(e);
|
|
342
|
+
}
|
|
343
|
+
async run(e, t) {
|
|
344
|
+
this.logger.debug("📋 Listing conformetry instances", void 0, { templateFilter: t.templates });
|
|
345
|
+
let n = process.cwd(), r = await this.configurationService.loadConformetryConfiguration(t.config ?? "configuration/conformetry.config.ts"), i = this.inventoryService.shortenInstancePaths({
|
|
346
|
+
instances: this.configurationService.resolveInventoriedInstances({
|
|
347
|
+
configuration: r,
|
|
348
|
+
...t.templates === void 0 ? {} : { templateNames: t.templates },
|
|
349
|
+
workingDirectory: n
|
|
350
|
+
}),
|
|
351
|
+
workingDirectory: n
|
|
352
|
+
});
|
|
353
|
+
if (t.json === !0) {
|
|
354
|
+
console.info(JSON.stringify(i, void 0, 2));
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
if (i.length === 0) {
|
|
358
|
+
console.info(t.templates === void 0 ? ne : V);
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
console.info(this.inventoryService.describeInstances(i).join("\n"));
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
A([
|
|
365
|
+
y({
|
|
366
|
+
description: "Path to the conformetry configuration file",
|
|
367
|
+
flags: "--config [path]"
|
|
368
|
+
}),
|
|
369
|
+
k("design:type", Function),
|
|
370
|
+
k("design:paramtypes", [Object]),
|
|
371
|
+
k("design:returntype", Object)
|
|
372
|
+
], U.prototype, "parseConfig", null), A([
|
|
373
|
+
y({
|
|
374
|
+
description: "Write the listing as JSON",
|
|
375
|
+
flags: "--json"
|
|
376
|
+
}),
|
|
377
|
+
k("design:type", Function),
|
|
378
|
+
k("design:paramtypes", []),
|
|
379
|
+
k("design:returntype", Boolean)
|
|
380
|
+
], U.prototype, "parseJson", null), A([
|
|
381
|
+
y({
|
|
382
|
+
description: "Comma-separated template names; report only the instances they explain",
|
|
383
|
+
flags: "--templates [names]"
|
|
384
|
+
}),
|
|
385
|
+
k("design:type", Function),
|
|
386
|
+
k("design:paramtypes", [Object]),
|
|
387
|
+
k("design:returntype", Object)
|
|
388
|
+
], U.prototype, "parseTemplates", null), U = H = A([
|
|
389
|
+
_({
|
|
390
|
+
description: "List the generated code the configuration finds, and what explains it",
|
|
391
|
+
name: "instances"
|
|
392
|
+
}),
|
|
393
|
+
n(),
|
|
394
|
+
k("design:paramtypes", [
|
|
395
|
+
p === void 0 ? Object : p,
|
|
396
|
+
x === void 0 ? Object : x,
|
|
397
|
+
M === void 0 ? Object : M
|
|
398
|
+
])
|
|
399
|
+
], U);
|
|
400
|
+
//#endregion
|
|
401
|
+
//#region packages/ic-suite/conformetry/conformetry-cli/src/modules/instances/instances.module.ts
|
|
402
|
+
var W = class {};
|
|
403
|
+
W = A([r({
|
|
404
|
+
controllers: [],
|
|
405
|
+
exports: [U],
|
|
406
|
+
imports: [
|
|
407
|
+
f,
|
|
408
|
+
b,
|
|
409
|
+
N
|
|
410
|
+
],
|
|
411
|
+
providers: [U]
|
|
412
|
+
})], W);
|
|
413
|
+
//#endregion
|
|
414
|
+
//#region packages/ic-suite/conformetry/conformetry-cli/src/modules/templates/templates.constants.ts
|
|
415
|
+
var G = "No templates are declared in the configuration.", K = "No template explains those paths. Either they are not generated code, or they have drifted past recognition.", q, J = q = class extends v {
|
|
416
|
+
configurationService;
|
|
417
|
+
inventoryService;
|
|
418
|
+
logger;
|
|
419
|
+
constructor(e, t, n) {
|
|
420
|
+
super(), this.configurationService = e, this.inventoryService = t, this.logger = n, this.logger.setContext(q.name);
|
|
421
|
+
}
|
|
422
|
+
parseConfig(e) {
|
|
423
|
+
return this.configurationService.parseOptionalOption(e);
|
|
424
|
+
}
|
|
425
|
+
parseInstances(e) {
|
|
426
|
+
return this.configurationService.parseCommaDelimitedOption(e);
|
|
427
|
+
}
|
|
428
|
+
parseJson() {
|
|
429
|
+
return !0;
|
|
430
|
+
}
|
|
431
|
+
async run(e, t) {
|
|
432
|
+
this.logger.debug("📋 Listing conformetry templates", void 0, { instanceFilter: t.instances });
|
|
433
|
+
let n = process.cwd(), r = await this.configurationService.loadConformetryConfiguration(t.config ?? "configuration/conformetry.config.ts"), i = this.inventoryService.shortenTemplatePairings({
|
|
434
|
+
templates: this.configurationService.resolveInventoriedTemplates({
|
|
435
|
+
configuration: r,
|
|
436
|
+
...t.instances === void 0 ? {} : { instancePatterns: t.instances },
|
|
437
|
+
workingDirectory: n
|
|
438
|
+
}),
|
|
439
|
+
workingDirectory: n
|
|
440
|
+
});
|
|
441
|
+
if (t.json === !0) {
|
|
442
|
+
console.info(JSON.stringify(i, void 0, 2));
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
if (i.length === 0) {
|
|
446
|
+
console.info(t.instances === void 0 ? G : K);
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
console.info(this.inventoryService.describeTemplates({
|
|
450
|
+
showInstances: t.instances !== void 0,
|
|
451
|
+
templates: i
|
|
452
|
+
}).join("\n"));
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
A([
|
|
456
|
+
y({
|
|
457
|
+
description: "Path to the conformetry configuration file",
|
|
458
|
+
flags: "--config [path]"
|
|
459
|
+
}),
|
|
460
|
+
k("design:type", Function),
|
|
461
|
+
k("design:paramtypes", [Object]),
|
|
462
|
+
k("design:returntype", Object)
|
|
463
|
+
], J.prototype, "parseConfig", null), A([
|
|
464
|
+
y({
|
|
465
|
+
description: "Comma-separated paths or globs; report only the templates that explain them",
|
|
466
|
+
flags: "--instances [globs]"
|
|
467
|
+
}),
|
|
468
|
+
k("design:type", Function),
|
|
469
|
+
k("design:paramtypes", [Object]),
|
|
470
|
+
k("design:returntype", Object)
|
|
471
|
+
], J.prototype, "parseInstances", null), A([
|
|
472
|
+
y({
|
|
473
|
+
description: "Write the listing as JSON",
|
|
474
|
+
flags: "--json"
|
|
475
|
+
}),
|
|
476
|
+
k("design:type", Function),
|
|
477
|
+
k("design:paramtypes", []),
|
|
478
|
+
k("design:returntype", Boolean)
|
|
479
|
+
], J.prototype, "parseJson", null), J = q = A([
|
|
480
|
+
_({
|
|
481
|
+
description: "Name the templates the configuration declares, or which ones explain a path",
|
|
482
|
+
name: "templates"
|
|
483
|
+
}),
|
|
484
|
+
n(),
|
|
485
|
+
k("design:paramtypes", [
|
|
486
|
+
p === void 0 ? Object : p,
|
|
487
|
+
x === void 0 ? Object : x,
|
|
488
|
+
M === void 0 ? Object : M
|
|
489
|
+
])
|
|
490
|
+
], J);
|
|
491
|
+
//#endregion
|
|
492
|
+
//#region packages/ic-suite/conformetry/conformetry-cli/src/modules/templates/templates.module.ts
|
|
493
|
+
var Y = class {};
|
|
494
|
+
Y = A([r({
|
|
495
|
+
controllers: [],
|
|
496
|
+
exports: [J],
|
|
497
|
+
imports: [
|
|
498
|
+
f,
|
|
499
|
+
b,
|
|
500
|
+
N
|
|
501
|
+
],
|
|
502
|
+
providers: [J]
|
|
503
|
+
})], Y);
|
|
504
|
+
//#endregion
|
|
505
|
+
//#region packages/ic-suite/conformetry/conformetry-cli/src/modules/validate/validate.command.ts
|
|
506
|
+
var X, Z = X = class extends v {
|
|
507
|
+
configurationService;
|
|
508
|
+
reportingService;
|
|
509
|
+
validationService;
|
|
510
|
+
logger;
|
|
511
|
+
constructor(e, t, n, r) {
|
|
512
|
+
super(), this.configurationService = e, this.reportingService = t, this.validationService = n, this.logger = r, this.logger.setContext(X.name);
|
|
513
|
+
}
|
|
514
|
+
describeFailure(e) {
|
|
515
|
+
return `Validation failed: ${[...e.scores.filter((e) => !e.ok).map((e) => `${e.instancePath} scored ${this.reportingService.formatPercentage(e.score)} against ${e.templateName} (threshold ${this.reportingService.formatPercentage(e.threshold)})`), ...e.unmatched.length === 0 ? [] : [`${String(e.unmatched.length)} instance(s) matched no template`]].join("; ")}.`;
|
|
516
|
+
}
|
|
517
|
+
findInstances(e) {
|
|
518
|
+
return this.configurationService.readWorkspaceGroups(e.groups).flatMap((t) => this.configurationService.findInstances({
|
|
519
|
+
patterns: t.patterns ?? [],
|
|
520
|
+
...t.substitutions === void 0 ? {} : { substitutions: t.substitutions },
|
|
521
|
+
...t.threshold === void 0 ? {} : { threshold: t.threshold },
|
|
522
|
+
workingDirectory: e.workingDirectory
|
|
523
|
+
}));
|
|
524
|
+
}
|
|
525
|
+
async promptForTemplateNames(e) {
|
|
526
|
+
if (this.configurationService.isAtTerminal()) return this.configurationService.promptForTemplates(e);
|
|
527
|
+
}
|
|
528
|
+
reportEmptySelection(e) {
|
|
529
|
+
let t = e.map((e) => e.name), n = e.filter((e) => e.instances.length > 0 && this.configurationService.readWorkspaceGroups(e.instances).length === 0).map((e) => e.name);
|
|
530
|
+
process.stdout.write([
|
|
531
|
+
`No instances belong to ${t.join(", ")}, so nothing was checked.`,
|
|
532
|
+
...n.length === 0 ? [] : [`${n.join(", ")} locates instances by project tag, which this host cannot resolve. Run validation through @conformetry/nx, or pass --instances with the paths to check.`],
|
|
533
|
+
""
|
|
534
|
+
].join("\n")), this.logger.info("🫙 Validated nothing", void 0, {
|
|
535
|
+
tagScopedNames: n,
|
|
536
|
+
templateNames: t
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
reportResult(e) {
|
|
540
|
+
process.stdout.write(`${this.reportingService.formatReport({
|
|
541
|
+
fileResults: e.result.fileResults,
|
|
542
|
+
scores: e.result.scores,
|
|
543
|
+
workingDirectory: e.workingDirectory
|
|
544
|
+
})}\n`);
|
|
545
|
+
let t = e.result.scores.filter((e) => !e.ok).length, n = e.result.unmatched.length;
|
|
546
|
+
if (this.logger.info("👔 Validated conformetry instances", void 0, {
|
|
547
|
+
count: e.result.checkedPaths.length,
|
|
548
|
+
failedCount: t,
|
|
549
|
+
unmatchedCount: n
|
|
550
|
+
}), !e.result.ok) throw process.exitCode = 1, this.logger.warn("⚠️ Rejected non-conforming instances", void 0, {
|
|
551
|
+
failedCount: t,
|
|
552
|
+
unmatchedCount: n
|
|
553
|
+
}), Error(this.describeFailure(e.result));
|
|
554
|
+
}
|
|
555
|
+
selectInstances(e) {
|
|
556
|
+
let t = this.findInstances({
|
|
557
|
+
groups: (e.selectedTemplates ?? e.configuration).flatMap((e) => e.instances),
|
|
558
|
+
workingDirectory: e.workingDirectory
|
|
559
|
+
});
|
|
560
|
+
if (e.instanceGlobs === void 0) return t;
|
|
561
|
+
let n = this.findInstances({
|
|
562
|
+
groups: [{ patterns: e.instanceGlobs }],
|
|
563
|
+
workingDirectory: e.workingDirectory
|
|
564
|
+
});
|
|
565
|
+
if (e.selectedTemplates === void 0) return n;
|
|
566
|
+
let r = new Set(t.map((e) => e.path));
|
|
567
|
+
return n.filter((e) => r.has(e.path));
|
|
568
|
+
}
|
|
569
|
+
async selectTemplates(e) {
|
|
570
|
+
let t = e.templateNames ?? await this.promptForTemplateNames(e.configuration);
|
|
571
|
+
if (!(t === void 0 || t.includes(d))) return t.map((t) => {
|
|
572
|
+
let n = e.configuration.find((e) => e.name === t);
|
|
573
|
+
if (n === void 0) throw this.logger.error("🚫 Rejected an unknown template", void 0, { template: t }), P({
|
|
574
|
+
availableTemplateNames: e.configuration.map((e) => e.name),
|
|
575
|
+
templateName: t
|
|
576
|
+
});
|
|
577
|
+
return n;
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
parseConfig(e) {
|
|
581
|
+
return this.configurationService.parseOptionalOption(e);
|
|
582
|
+
}
|
|
583
|
+
parseInstances(e) {
|
|
584
|
+
return this.configurationService.parseCommaDelimitedOption(e);
|
|
585
|
+
}
|
|
586
|
+
parseLanguages(e) {
|
|
587
|
+
return this.configurationService.parseCommaDelimitedOption(e);
|
|
588
|
+
}
|
|
589
|
+
parseTemplates(e) {
|
|
590
|
+
return this.configurationService.parseCommaDelimitedOption(e);
|
|
591
|
+
}
|
|
592
|
+
parseThreshold(e) {
|
|
593
|
+
return this.configurationService.parseThresholdOption(e);
|
|
594
|
+
}
|
|
595
|
+
async run(e, t) {
|
|
596
|
+
this.logger.debug("🔍 Validating conformetry instances", void 0, { instanceFilter: t.instances });
|
|
597
|
+
let n = process.cwd(), r = await this.configurationService.loadConformetryConfiguration(t.config ?? "configuration/conformetry.config.ts"), i = await this.selectTemplates({
|
|
598
|
+
configuration: r,
|
|
599
|
+
templateNames: t.templates
|
|
600
|
+
}), a = this.selectInstances({
|
|
601
|
+
configuration: r,
|
|
602
|
+
instanceGlobs: t.instances,
|
|
603
|
+
selectedTemplates: i,
|
|
604
|
+
workingDirectory: n
|
|
605
|
+
});
|
|
606
|
+
if (i !== void 0 && a.length === 0) {
|
|
607
|
+
this.reportEmptySelection(i);
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
let o = this.validationService.validate({
|
|
611
|
+
instances: a,
|
|
612
|
+
...t.threshold === void 0 ? {} : { threshold: t.threshold },
|
|
613
|
+
...t.languages === void 0 ? {} : { languageNames: t.languages },
|
|
614
|
+
templates: this.configurationService.collectTemplates({
|
|
615
|
+
configuration: i ?? r,
|
|
616
|
+
workingDirectory: n
|
|
617
|
+
})
|
|
618
|
+
});
|
|
619
|
+
this.reportResult({
|
|
620
|
+
result: o,
|
|
621
|
+
workingDirectory: n
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
A([
|
|
626
|
+
y({
|
|
627
|
+
description: "Path to the conformetry configuration file",
|
|
628
|
+
flags: "--config [path]"
|
|
629
|
+
}),
|
|
630
|
+
k("design:type", Function),
|
|
631
|
+
k("design:paramtypes", [Object]),
|
|
632
|
+
k("design:returntype", Object)
|
|
633
|
+
], Z.prototype, "parseConfig", null), A([
|
|
634
|
+
y({
|
|
635
|
+
description: "Comma-separated glob patterns to validate, overriding the configuration",
|
|
636
|
+
flags: "--instances [globs]"
|
|
637
|
+
}),
|
|
638
|
+
k("design:type", Function),
|
|
639
|
+
k("design:paramtypes", [Object]),
|
|
640
|
+
k("design:returntype", Object)
|
|
641
|
+
], Z.prototype, "parseInstances", null), A([
|
|
642
|
+
y({
|
|
643
|
+
description: "Comma-separated language names to run",
|
|
644
|
+
flags: "--languages [languages]"
|
|
645
|
+
}),
|
|
646
|
+
k("design:type", Function),
|
|
647
|
+
k("design:paramtypes", [Object]),
|
|
648
|
+
k("design:returntype", Object)
|
|
649
|
+
], Z.prototype, "parseLanguages", null), A([
|
|
650
|
+
y({
|
|
651
|
+
description: `Comma-separated template names to validate, or "${d}" for every one`,
|
|
652
|
+
flags: "--templates [names]"
|
|
653
|
+
}),
|
|
654
|
+
k("design:type", Function),
|
|
655
|
+
k("design:paramtypes", [Object]),
|
|
656
|
+
k("design:returntype", Object)
|
|
657
|
+
], Z.prototype, "parseTemplates", null), A([
|
|
658
|
+
y({
|
|
659
|
+
description: "Lowest conformance score an instance may have, from 0 to 1. Overridden by a generator's own threshold and by an instance group's",
|
|
660
|
+
flags: "--threshold [ratio]"
|
|
661
|
+
}),
|
|
662
|
+
k("design:type", Function),
|
|
663
|
+
k("design:paramtypes", [Object]),
|
|
664
|
+
k("design:returntype", Object)
|
|
665
|
+
], Z.prototype, "parseThreshold", null), Z = X = A([
|
|
666
|
+
_({
|
|
667
|
+
description: "Measure instances against their templates and report every difference",
|
|
668
|
+
name: "validate"
|
|
669
|
+
}),
|
|
670
|
+
n(),
|
|
671
|
+
k("design:paramtypes", [
|
|
672
|
+
p === void 0 ? Object : p,
|
|
673
|
+
S === void 0 ? Object : S,
|
|
674
|
+
w === void 0 ? Object : w,
|
|
675
|
+
M === void 0 ? Object : M
|
|
676
|
+
])
|
|
677
|
+
], Z);
|
|
678
|
+
//#endregion
|
|
679
|
+
//#region packages/ic-suite/conformetry/conformetry-cli/src/modules/validate/validate.module.ts
|
|
680
|
+
var Q = class {};
|
|
681
|
+
Q = A([r({
|
|
682
|
+
controllers: [],
|
|
683
|
+
exports: [Z],
|
|
684
|
+
imports: [
|
|
685
|
+
f,
|
|
686
|
+
N,
|
|
687
|
+
te,
|
|
688
|
+
C
|
|
689
|
+
],
|
|
690
|
+
providers: [Z]
|
|
691
|
+
})], Q);
|
|
692
|
+
//#endregion
|
|
693
|
+
//#region packages/ic-suite/conformetry/conformetry-cli/src/main.module.ts
|
|
694
|
+
var $ = class {};
|
|
695
|
+
$ = A([r({ imports: [
|
|
696
|
+
a.forRoot({
|
|
697
|
+
envFilePath: ".env",
|
|
698
|
+
isGlobal: !0,
|
|
699
|
+
validate: (e) => I.parse(e)
|
|
700
|
+
}),
|
|
701
|
+
o,
|
|
702
|
+
N,
|
|
703
|
+
B,
|
|
704
|
+
W,
|
|
705
|
+
Y,
|
|
706
|
+
Q
|
|
707
|
+
] })], $);
|
|
708
|
+
//#endregion
|
|
709
|
+
export { J as a, B as c, Y as i, z as l, Q as n, W as o, Z as r, U as s, $ as t, M as u };
|