@codometer/configuration 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 +900 -0
- package/dist/src/index.d.ts +1204 -0
- package/dist/src/index.js +450 -0
- package/package.json +64 -0
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
import { CODOMETER_SEVERITIES as e, CODOMETER_STATISTIC_GROUPS as t, CODOMETER_SYMBOL_KINDS as n, CODOMETER_SYMBOL_MODIFIERS as r, ConfigurationFileNotFoundError as i, InvalidConfigurationError as a, InvalidLimitValueError as o, UnknownConfigurationFileTypeError as s } from "@codometer/core";
|
|
2
|
+
import { z as c } from "zod";
|
|
3
|
+
import { Injectable as l, Module as u } from "@nestjs/common";
|
|
4
|
+
import { existsSync as d } from "node:fs";
|
|
5
|
+
import { readFile as f } from "node:fs/promises";
|
|
6
|
+
import p from "node:path";
|
|
7
|
+
import { fileURLToPath as m } from "node:url";
|
|
8
|
+
import { createJiti as h } from "jiti";
|
|
9
|
+
import { parse as g } from "jsonc-parser";
|
|
10
|
+
//#region packages/ic-suite/codometer/codometer-configuration/src/modules/configuration/configuration-flags.constants.ts
|
|
11
|
+
var _ = "limits", v = "reports", y = [_, v], b = ",", x = "json", S = "markdown", C = [x, S], w = /* @__PURE__ */ new Set([
|
|
12
|
+
".cjs",
|
|
13
|
+
".cts",
|
|
14
|
+
".js",
|
|
15
|
+
".json",
|
|
16
|
+
".jsonc",
|
|
17
|
+
".mjs",
|
|
18
|
+
".mts",
|
|
19
|
+
".ts"
|
|
20
|
+
]), T = [
|
|
21
|
+
"codometer.config.ts",
|
|
22
|
+
"codometer.config.mts",
|
|
23
|
+
"codometer.config.cts",
|
|
24
|
+
"codometer.config.js",
|
|
25
|
+
"codometer.config.mjs",
|
|
26
|
+
"codometer.config.cjs",
|
|
27
|
+
"codometer.config.json",
|
|
28
|
+
"codometer.config.jsonc"
|
|
29
|
+
], E = [
|
|
30
|
+
"**/.nx/**",
|
|
31
|
+
"**/build/**",
|
|
32
|
+
"**/coverage/**",
|
|
33
|
+
"**/dist/**",
|
|
34
|
+
"**/node_modules/**"
|
|
35
|
+
], D = [
|
|
36
|
+
"7c3aed",
|
|
37
|
+
"0284c7",
|
|
38
|
+
"16a34a",
|
|
39
|
+
"ea580c",
|
|
40
|
+
"db2777",
|
|
41
|
+
"0ea5e9",
|
|
42
|
+
"059669",
|
|
43
|
+
"ca8a04"
|
|
44
|
+
], O = "conventions", k = "codebase", A = {
|
|
45
|
+
analyses: ["language"],
|
|
46
|
+
include: ["**/*"],
|
|
47
|
+
name: k
|
|
48
|
+
}, ee = "gzip", te = ".", ne = "fail", re = /* @__PURE__ */ new Map([
|
|
49
|
+
["b", 1],
|
|
50
|
+
["gb", 1e9],
|
|
51
|
+
["kb", 1e3],
|
|
52
|
+
["mb", 1e6],
|
|
53
|
+
["tb", 0xe8d4a51000]
|
|
54
|
+
]), ie = /^(\d+(?:\.\d+)?)\s*([a-z]*)$/i, ae = 2, oe = "<!-- codometer:end -->", j = "<!-- codometer:start -->", M = "python3", N = [".git", "pnpm-workspace.yaml"], P = ["language", "size"], F = [
|
|
55
|
+
"css",
|
|
56
|
+
"hcl",
|
|
57
|
+
"python",
|
|
58
|
+
"shell",
|
|
59
|
+
"sql",
|
|
60
|
+
"toml",
|
|
61
|
+
"typescript",
|
|
62
|
+
"yaml"
|
|
63
|
+
], I = [
|
|
64
|
+
"brotli",
|
|
65
|
+
"gzip",
|
|
66
|
+
"none"
|
|
67
|
+
], L = "A codometer configuration must name a `format` of \"json\" or \"markdown\", and nothing supplies one for it. Set it in this file, or spread a shared default object that sets it — every run has to be told which report shape it produces, and a directory with no configuration file anywhere above it fails here rather than measuring with a format nobody chose.", R = ["json", "markdown"], z = [
|
|
68
|
+
"characters",
|
|
69
|
+
"lines",
|
|
70
|
+
"words"
|
|
71
|
+
], B = () => c.custom((e) => typeof e == "function", { message: "Expected a function" }), V = c.object({
|
|
72
|
+
kind: c.enum(n).optional(),
|
|
73
|
+
language: c.enum(F).optional(),
|
|
74
|
+
maximumCharacters: c.number().int().min(1).optional(),
|
|
75
|
+
maximumLines: c.number().int().min(1).optional(),
|
|
76
|
+
maximumWords: c.number().int().min(1).optional(),
|
|
77
|
+
severity: c.enum(e).optional()
|
|
78
|
+
}), H = c.object({
|
|
79
|
+
color: c.string().optional(),
|
|
80
|
+
comment: V.optional(),
|
|
81
|
+
group: c.enum(t).optional(),
|
|
82
|
+
label: c.string(),
|
|
83
|
+
patterns: c.array(c.string()).min(1).optional(),
|
|
84
|
+
symbols: c.object({
|
|
85
|
+
kinds: c.array(c.enum(n)).min(1),
|
|
86
|
+
modifiers: c.array(c.enum(r)).optional()
|
|
87
|
+
}).optional()
|
|
88
|
+
}).refine((e) => e.patterns !== void 0 || e.symbols !== void 0 || e.comment !== void 0, { message: "A statistic needs patterns to match files, symbols to match declarations, or a comment selector to match a budget — otherwise it counts nothing." }), U = c.object({
|
|
89
|
+
analyses: c.array(c.enum(P)).min(1),
|
|
90
|
+
compression: c.enum(I).optional(),
|
|
91
|
+
directory: c.string().min(1).optional(),
|
|
92
|
+
exclude: c.array(c.string().refine((e) => !e.startsWith("!"), { message: "An exclude glob already removes files, so a leading `!` has nothing to negate — write the glob without it." })).optional(),
|
|
93
|
+
include: c.array(c.string()).min(1),
|
|
94
|
+
name: c.string().min(1)
|
|
95
|
+
}).superRefine((e, t) => {
|
|
96
|
+
e.include.some((e) => !e.startsWith("!")) || t.addIssue({
|
|
97
|
+
code: "custom",
|
|
98
|
+
message: `Input "${e.name}" has no include glob that adds files — every pattern in its include list starts with "!", so it would hold nothing to measure.`
|
|
99
|
+
});
|
|
100
|
+
}), W = c.object({
|
|
101
|
+
custom: c.array(c.string().min(1)).optional(),
|
|
102
|
+
indentation: c.number().int().min(0).optional(),
|
|
103
|
+
path: c.string(),
|
|
104
|
+
type: c.literal("json")
|
|
105
|
+
}), G = c.object({
|
|
106
|
+
custom: c.array(c.string().min(1)).optional(),
|
|
107
|
+
description: c.string().optional(),
|
|
108
|
+
endMarker: c.string().optional(),
|
|
109
|
+
path: c.string().optional(),
|
|
110
|
+
startMarker: c.string().optional(),
|
|
111
|
+
type: c.literal("markdown"),
|
|
112
|
+
write: B().optional()
|
|
113
|
+
}).refine((e) => e.path !== void 0 || e.write !== void 0, { message: "Markdown output needs a path, a write function, or both — otherwise nothing names the file to write." }), K = c.object({
|
|
114
|
+
custom: c.array(H).refine((e) => new Set(e.map((e) => e.label)).size === e.length, { message: "Every custom statistic needs its own label." }).optional(),
|
|
115
|
+
defaultInput: c.string().min(1).optional(),
|
|
116
|
+
exclude: c.array(c.string()).optional(),
|
|
117
|
+
excludeFrom: c.array(c.string()).optional(),
|
|
118
|
+
format: c.enum(R, { error: L }),
|
|
119
|
+
inputs: c.array(U).refine((e) => new Set(e.map((e) => e.name)).size === e.length, { message: "Every input needs its own name." }).optional(),
|
|
120
|
+
limits: c.array(c.object({
|
|
121
|
+
label: c.string().min(1).optional(),
|
|
122
|
+
metric: c.string().min(1),
|
|
123
|
+
severity: c.enum(e).optional(),
|
|
124
|
+
value: c.union([c.number(), c.string()])
|
|
125
|
+
})).optional(),
|
|
126
|
+
outputs: c.array(c.union([W, G])).superRefine((e, t) => {
|
|
127
|
+
let n = e.find((t, n) => e.findIndex((e) => e.type === t.type) < n);
|
|
128
|
+
n !== void 0 && t.addIssue({
|
|
129
|
+
code: "custom",
|
|
130
|
+
message: `A configuration may declare at most one output per type, and this one declares more than one "${n.type}" output. Nothing on the command line could address the second, so write the one destination this repository means.`
|
|
131
|
+
});
|
|
132
|
+
}).optional(),
|
|
133
|
+
python: c.object({ command: c.string().optional() }).optional()
|
|
134
|
+
}).superRefine((e, t) => {
|
|
135
|
+
let n = new Set((e.custom ?? []).map((e) => e.label));
|
|
136
|
+
for (let r of e.outputs ?? []) for (let e of r.custom ?? []) n.has(e) || t.addIssue({
|
|
137
|
+
code: "custom",
|
|
138
|
+
message: `The "${r.type}" output selects the custom statistic "${e}", but no top-level "custom" entry declares that label. Declare it in "custom", or select a label that is.`
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region \0@oxc-project+runtime@0.151.0/helpers/esm/decorateMetadata.js
|
|
143
|
+
function q(e, t) {
|
|
144
|
+
if (typeof Reflect == "object" && typeof Reflect.metadata == "function") return Reflect.metadata(e, t);
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region \0@oxc-project+runtime@0.151.0/helpers/esm/decorate.js
|
|
148
|
+
function J(e, t, n, r) {
|
|
149
|
+
var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
|
|
150
|
+
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
|
|
151
|
+
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);
|
|
152
|
+
return i > 3 && a && Object.defineProperty(t, n, a), a;
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region packages/ic-suite/codometer/codometer-configuration/src/modules/configuration/configuration-flags.service.ts
|
|
156
|
+
var Y = class {
|
|
157
|
+
constructor() {}
|
|
158
|
+
describeAcceptedCheckNames(e) {
|
|
159
|
+
return `${e}. It takes a comma-separated set drawn from ${y.map((e) => `"${e}"`).join(" and ")}, as in "--check ${y.join(",")}".`;
|
|
160
|
+
}
|
|
161
|
+
readCheckNames(e, t) {
|
|
162
|
+
if (e === void 0) return /* @__PURE__ */ new Set();
|
|
163
|
+
if (e === !0) return t.push(this.describeAcceptedCheckNames("--check needs a value")), /* @__PURE__ */ new Set();
|
|
164
|
+
let n = e.split(",").map((e) => e.trim()).filter((e) => e !== "");
|
|
165
|
+
return n.length === 0 ? (t.push(this.describeAcceptedCheckNames("--check needs a value")), /* @__PURE__ */ new Set()) : this.validateCheckNames(n, t);
|
|
166
|
+
}
|
|
167
|
+
validateCheckNames(e, t) {
|
|
168
|
+
let n = /* @__PURE__ */ new Set();
|
|
169
|
+
for (let r of e) {
|
|
170
|
+
if (y.includes(r)) {
|
|
171
|
+
n.add(r);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
t.push(this.describeAcceptedCheckNames(`--check does not accept "${r}"`));
|
|
175
|
+
}
|
|
176
|
+
return n;
|
|
177
|
+
}
|
|
178
|
+
parseDefaultedOption(e, t) {
|
|
179
|
+
return this.parseOptionalOption(e) ?? t;
|
|
180
|
+
}
|
|
181
|
+
parseDirectoryOption(e) {
|
|
182
|
+
return this.parseDefaultedOption(e, process.cwd());
|
|
183
|
+
}
|
|
184
|
+
parseOptionalOption(e) {
|
|
185
|
+
return typeof e == "string" && e !== "" ? e : void 0;
|
|
186
|
+
}
|
|
187
|
+
resolveFormat(e, t, n) {
|
|
188
|
+
if (e === void 0) return t;
|
|
189
|
+
let r = C.find((t) => t === e);
|
|
190
|
+
return r === void 0 && n.push(`--format does not accept "${e}". It takes one of ${C.map((e) => `"${e}"`).join(" and ")}, as in "--format ${S}".`), r;
|
|
191
|
+
}
|
|
192
|
+
selectMode(e) {
|
|
193
|
+
let t = [], n = this.readCheckNames(e.check, t), r = {
|
|
194
|
+
checksLimits: n.has(_),
|
|
195
|
+
checksReports: n.has(v),
|
|
196
|
+
writesJson: e.outputJson !== void 0,
|
|
197
|
+
writesMarkdown: e.outputMarkdown !== void 0
|
|
198
|
+
};
|
|
199
|
+
return r.checksReports && (r.writesJson || r.writesMarkdown) && t.push(`--output-json or --output-markdown cannot be combined with --check ${v}: a report cannot be stale in the run that just wrote it. Drop --check ${v}, or run it separately from the run that writes.`), {
|
|
200
|
+
errors: t,
|
|
201
|
+
mode: r
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
Y = J([l(), q("design:paramtypes", [])], Y);
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region packages/ic-suite/codometer/codometer-configuration/src/modules/configuration/configuration-loader.service.ts
|
|
208
|
+
var X = class {
|
|
209
|
+
constructor() {}
|
|
210
|
+
findConfigurationFile(e) {
|
|
211
|
+
let t = p.resolve(e);
|
|
212
|
+
for (;;) {
|
|
213
|
+
for (let e of T) {
|
|
214
|
+
let n = p.join(t, e);
|
|
215
|
+
if (d(n)) return n;
|
|
216
|
+
}
|
|
217
|
+
let e = p.dirname(t);
|
|
218
|
+
if (e === t) return;
|
|
219
|
+
t = e;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
findRepositoryRoot() {
|
|
223
|
+
let e = p.resolve(process.cwd());
|
|
224
|
+
for (;;) {
|
|
225
|
+
let t = e;
|
|
226
|
+
if (N.some((e) => d(p.join(t, e)))) return e;
|
|
227
|
+
let n = p.dirname(e);
|
|
228
|
+
if (n === e) return;
|
|
229
|
+
e = n;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
async loadConfigurationModule(e) {
|
|
233
|
+
if (e.extension === ".json" || e.extension === ".jsonc") return this.loadJsonConfiguration(e);
|
|
234
|
+
let t = h(m(import.meta.url));
|
|
235
|
+
return this.readDefaultExport(await t.import(e.configurationPath, { default: !0 }));
|
|
236
|
+
}
|
|
237
|
+
async loadJsonConfiguration(e) {
|
|
238
|
+
let t = await f(e.configurationPath, "utf8");
|
|
239
|
+
return e.extension === ".jsonc" ? g(t) : JSON.parse(t);
|
|
240
|
+
}
|
|
241
|
+
readDefaultExport(e) {
|
|
242
|
+
if (typeof e != "object" || !e) return {};
|
|
243
|
+
let t = e.default;
|
|
244
|
+
return typeof t == "object" && t ? t : e;
|
|
245
|
+
}
|
|
246
|
+
resolveConfigurationPath(e) {
|
|
247
|
+
let t = p.resolve(e);
|
|
248
|
+
if (d(t)) return t;
|
|
249
|
+
let n = this.findRepositoryRoot();
|
|
250
|
+
if (n === void 0) throw new i(t);
|
|
251
|
+
let r = p.resolve(n, e);
|
|
252
|
+
if (!d(r)) throw new i(t);
|
|
253
|
+
return r;
|
|
254
|
+
}
|
|
255
|
+
async load(e = {}) {
|
|
256
|
+
let t = p.resolve(e.searchDirectory ?? process.cwd()), n = e.configurationPath === void 0 ? this.findConfigurationFile(t) : this.resolveConfigurationPath(e.configurationPath);
|
|
257
|
+
if (n === void 0) return;
|
|
258
|
+
let r = p.extname(n).toLowerCase();
|
|
259
|
+
if (!w.has(r)) throw new s(n);
|
|
260
|
+
return {
|
|
261
|
+
configuration: await this.loadConfigurationModule({
|
|
262
|
+
configurationPath: n,
|
|
263
|
+
extension: r
|
|
264
|
+
}),
|
|
265
|
+
path: n
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
X = J([l(), q("design:paramtypes", [])], X);
|
|
270
|
+
//#endregion
|
|
271
|
+
//#region packages/ic-suite/codometer/codometer-configuration/src/modules/configuration/configuration-resolver.service.ts
|
|
272
|
+
var Z = class {
|
|
273
|
+
constructor() {}
|
|
274
|
+
parseConfigurationInternal(e) {
|
|
275
|
+
let t = K.safeParse(e);
|
|
276
|
+
if (!t.success) throw new a(c.prettifyError(t.error));
|
|
277
|
+
return t.data;
|
|
278
|
+
}
|
|
279
|
+
parseLimitValue(e) {
|
|
280
|
+
if (typeof e.value != "number") return this.parseLimitValueText(e.metric, e.value);
|
|
281
|
+
if (!Number.isFinite(e.value) || e.value < 0) throw new o(e.metric, String(e.value));
|
|
282
|
+
return e.value;
|
|
283
|
+
}
|
|
284
|
+
parseLimitValueText(e, t) {
|
|
285
|
+
let [, n, r] = ie.exec(t.trim()) ?? [];
|
|
286
|
+
if (n === void 0 || r === void 0) throw new o(e, t);
|
|
287
|
+
if (r === "") return Number(n);
|
|
288
|
+
let i = re.get(r.toLowerCase());
|
|
289
|
+
if (i === void 0) throw new o(e, t);
|
|
290
|
+
return Math.round(Number(n) * i);
|
|
291
|
+
}
|
|
292
|
+
resolveCustomStatistics(e) {
|
|
293
|
+
let t = /* @__PURE__ */ new Map();
|
|
294
|
+
return (e ?? []).map((e) => {
|
|
295
|
+
let n = e.group ?? "conventions", r = t.get(n) ?? 0;
|
|
296
|
+
t.set(n, r + 1);
|
|
297
|
+
let { comment: i } = e;
|
|
298
|
+
return {
|
|
299
|
+
color: e.color ?? D[r % D.length] ?? "7c3aed",
|
|
300
|
+
comment: i === void 0 ? void 0 : {
|
|
301
|
+
kind: i.kind,
|
|
302
|
+
language: i.language,
|
|
303
|
+
maximumCharacters: i.maximumCharacters,
|
|
304
|
+
maximumLines: i.maximumLines,
|
|
305
|
+
maximumWords: i.maximumWords,
|
|
306
|
+
severity: i.severity ?? "fail"
|
|
307
|
+
},
|
|
308
|
+
group: n,
|
|
309
|
+
label: e.label,
|
|
310
|
+
patterns: e.patterns ?? [],
|
|
311
|
+
symbols: e.symbols
|
|
312
|
+
};
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
resolveInput(e) {
|
|
316
|
+
return {
|
|
317
|
+
analyses: [...e.analyses],
|
|
318
|
+
compression: e.compression ?? "gzip",
|
|
319
|
+
directory: e.directory ?? ".",
|
|
320
|
+
exclude: [.../* @__PURE__ */ new Set([...e.include.filter((e) => e.startsWith("!")).map((e) => e.slice(1)), ...e.exclude ?? []])],
|
|
321
|
+
include: e.include.filter((e) => !e.startsWith("!")),
|
|
322
|
+
name: e.name
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
resolveInputs(e) {
|
|
326
|
+
let t = e ?? [];
|
|
327
|
+
return (t.some((e) => e.name === "codebase") ? t : [A, ...t]).map((e) => this.resolveInput(e));
|
|
328
|
+
}
|
|
329
|
+
resolveJsonOutput(e, t) {
|
|
330
|
+
return {
|
|
331
|
+
custom: this.selectCustomStatistics(e.custom, t),
|
|
332
|
+
indentation: e.indentation ?? 2,
|
|
333
|
+
path: e.path,
|
|
334
|
+
type: "json"
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
resolveLimits(e) {
|
|
338
|
+
return (e ?? []).map((e) => ({
|
|
339
|
+
label: e.label,
|
|
340
|
+
metric: e.metric,
|
|
341
|
+
severity: e.severity ?? "fail",
|
|
342
|
+
value: this.parseLimitValue(e)
|
|
343
|
+
}));
|
|
344
|
+
}
|
|
345
|
+
resolveMarkdownOutput(e, t) {
|
|
346
|
+
return {
|
|
347
|
+
custom: this.selectCustomStatistics(e.custom, t),
|
|
348
|
+
description: e.description,
|
|
349
|
+
endMarker: e.endMarker ?? "<!-- codometer:end -->",
|
|
350
|
+
path: e.path,
|
|
351
|
+
startMarker: e.startMarker ?? "<!-- codometer:start -->",
|
|
352
|
+
type: "markdown",
|
|
353
|
+
write: e.write
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
resolveOutputs(e, t) {
|
|
357
|
+
return (e ?? []).map((e) => e.type === "json" ? this.resolveJsonOutput(e, t) : this.resolveMarkdownOutput(e, t));
|
|
358
|
+
}
|
|
359
|
+
selectCustomStatistics(e, t) {
|
|
360
|
+
let n = new Map(t.map((e) => [e.label, e]));
|
|
361
|
+
return (e ?? []).flatMap((e) => {
|
|
362
|
+
let t = n.get(e);
|
|
363
|
+
return t === void 0 ? [] : [t];
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
parseConfiguration(e) {
|
|
367
|
+
return this.parseConfigurationInternal(e);
|
|
368
|
+
}
|
|
369
|
+
resolveConfiguration(e) {
|
|
370
|
+
let t = this.resolveCustomStatistics(e.custom);
|
|
371
|
+
return {
|
|
372
|
+
custom: t,
|
|
373
|
+
defaultInput: e.defaultInput,
|
|
374
|
+
exclude: [.../* @__PURE__ */ new Set([...E, ...e.exclude ?? []])],
|
|
375
|
+
excludeFrom: e.excludeFrom ?? [],
|
|
376
|
+
format: e.format,
|
|
377
|
+
inputs: this.resolveInputs(e.inputs),
|
|
378
|
+
limits: this.resolveLimits(e.limits),
|
|
379
|
+
outputs: this.resolveOutputs(e.outputs, t),
|
|
380
|
+
python: { command: e.python?.command ?? "python3" }
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
Z = J([l(), q("design:paramtypes", [])], Z);
|
|
385
|
+
//#endregion
|
|
386
|
+
//#region packages/ic-suite/codometer/codometer-configuration/src/modules/configuration/configuration.service.ts
|
|
387
|
+
var Q = class {
|
|
388
|
+
configurationLoaderService;
|
|
389
|
+
configurationResolverService;
|
|
390
|
+
configurationFlagsService;
|
|
391
|
+
constructor(e, t, n) {
|
|
392
|
+
this.configurationLoaderService = e, this.configurationResolverService = t, this.configurationFlagsService = n;
|
|
393
|
+
}
|
|
394
|
+
async loadConfiguration(e = {}) {
|
|
395
|
+
let { configuration: t } = await this.loadConfigurationFile(e);
|
|
396
|
+
return t;
|
|
397
|
+
}
|
|
398
|
+
async loadConfigurationFile(e = {}) {
|
|
399
|
+
let t = await this.configurationLoaderService.load(e);
|
|
400
|
+
return t === void 0 ? {
|
|
401
|
+
configuration: this.resolveConfiguration(this.parseConfiguration({})),
|
|
402
|
+
path: void 0
|
|
403
|
+
} : {
|
|
404
|
+
configuration: this.resolveConfiguration(this.parseConfiguration(t.configuration)),
|
|
405
|
+
path: t.path
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
parseConfiguration(e) {
|
|
409
|
+
return this.configurationResolverService.parseConfiguration(e);
|
|
410
|
+
}
|
|
411
|
+
parseDefaultedOption(e, t) {
|
|
412
|
+
return this.configurationFlagsService.parseDefaultedOption(e, t);
|
|
413
|
+
}
|
|
414
|
+
parseDirectoryOption(e) {
|
|
415
|
+
return this.configurationFlagsService.parseDirectoryOption(e);
|
|
416
|
+
}
|
|
417
|
+
parseOptionalOption(e) {
|
|
418
|
+
return this.configurationFlagsService.parseOptionalOption(e);
|
|
419
|
+
}
|
|
420
|
+
resolveConfiguration(e) {
|
|
421
|
+
return this.configurationResolverService.resolveConfiguration(e);
|
|
422
|
+
}
|
|
423
|
+
resolveFormat(e, t, n) {
|
|
424
|
+
return this.configurationFlagsService.resolveFormat(e, t, n);
|
|
425
|
+
}
|
|
426
|
+
selectMode(e) {
|
|
427
|
+
return this.configurationFlagsService.selectMode(e);
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
Q = J([l(), q("design:paramtypes", [
|
|
431
|
+
X === void 0 ? Object : X,
|
|
432
|
+
Z === void 0 ? Object : Z,
|
|
433
|
+
Y === void 0 ? Object : Y
|
|
434
|
+
])], Q);
|
|
435
|
+
//#endregion
|
|
436
|
+
//#region packages/ic-suite/codometer/codometer-configuration/src/modules/configuration/configuration.module.ts
|
|
437
|
+
var $ = class {};
|
|
438
|
+
$ = J([u({
|
|
439
|
+
controllers: [],
|
|
440
|
+
exports: [Q],
|
|
441
|
+
imports: [],
|
|
442
|
+
providers: [
|
|
443
|
+
Y,
|
|
444
|
+
X,
|
|
445
|
+
Z,
|
|
446
|
+
Q
|
|
447
|
+
]
|
|
448
|
+
})], $);
|
|
449
|
+
//#endregion
|
|
450
|
+
export { _ as CHECK_LIMITS, y as CHECK_NAMES, v as CHECK_REPORTS, b as CHECK_SEPARATOR, P as CODOMETER_ANALYSES, F as CODOMETER_COMMENT_LANGUAGES, I as CODOMETER_COMPRESSIONS, z as CODOMETER_DOCUMENTATION_UNITS, R as CODOMETER_FORMATS, T as CONFIGURATION_FILE_NAMES, $ as ConfigurationModule, Q as ConfigurationService, A as DEFAULT_CODEBASE_INPUT, D as DEFAULT_CUSTOM_STATISTIC_COLORS, O as DEFAULT_CUSTOM_STATISTIC_GROUP, E as DEFAULT_EXCLUDE_GLOBS, ee as DEFAULT_INPUT_COMPRESSION, te as DEFAULT_INPUT_DIRECTORY, k as DEFAULT_INPUT_NAME, ae as DEFAULT_JSON_INDENTATION, ne as DEFAULT_LIMIT_SEVERITY, oe as DEFAULT_MARKDOWN_END_MARKER, j as DEFAULT_MARKDOWN_START_MARKER, M as DEFAULT_PYTHON_COMMAND, x as FORMAT_JSON, S as FORMAT_MARKDOWN, C as FORMAT_NAMES, L as MISSING_FORMAT_MESSAGE, N as REPOSITORY_ROOT_MARKERS, K as codometerConfigurationSchema };
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"author": "Jimmy Paolini",
|
|
3
|
+
"bugs": {
|
|
4
|
+
"url": "https://github.com/Organizzolini/codebase/issues"
|
|
5
|
+
},
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@codometer/core": "0.0.1",
|
|
8
|
+
"@nestjs/common": "^11.1.21 || ^12.0.1",
|
|
9
|
+
"jiti": "^2.7.0",
|
|
10
|
+
"jsonc-parser": "^3.3.1",
|
|
11
|
+
"reflect-metadata": "^0.2.2",
|
|
12
|
+
"zod": "^4.4.3"
|
|
13
|
+
},
|
|
14
|
+
"description": "Configuration loader, limit definitions, and counter resolution for Codometer",
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@golevelup/ts-vitest": "^4.0.0",
|
|
17
|
+
"@nestjs/testing": "^12.0.1",
|
|
18
|
+
"@nx/eslint-plugin": "^23.0.0",
|
|
19
|
+
"@swc/helpers": "^0.5.21",
|
|
20
|
+
"@types/node": "^26.5.1",
|
|
21
|
+
"@vitest/coverage-v8": "^5.0.0",
|
|
22
|
+
"typescript": "^6.0.3",
|
|
23
|
+
"vitest": "^5.0.0"
|
|
24
|
+
},
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/src/index.d.ts",
|
|
28
|
+
"default": "./dist/src/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"LICENSE",
|
|
35
|
+
"README.md"
|
|
36
|
+
],
|
|
37
|
+
"homepage": "https://github.com/Organizzolini/codebase/tree/main/packages/ic-suite/codometer/codometer-configuration#readme",
|
|
38
|
+
"keywords": [
|
|
39
|
+
"codometer",
|
|
40
|
+
"configuration",
|
|
41
|
+
"counters",
|
|
42
|
+
"limits",
|
|
43
|
+
"thresholds"
|
|
44
|
+
],
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"main": "./dist/src/index.js",
|
|
47
|
+
"name": "@codometer/configuration",
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public",
|
|
50
|
+
"registry": "https://registry.npmjs.org"
|
|
51
|
+
},
|
|
52
|
+
"repository": {
|
|
53
|
+
"directory": "packages/ic-suite/codometer/codometer-configuration",
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "git+https://github.com/Organizzolini/codebase.git"
|
|
56
|
+
},
|
|
57
|
+
"type": "module",
|
|
58
|
+
"typeCoverage": {
|
|
59
|
+
"atLeast": 100,
|
|
60
|
+
"strict": true
|
|
61
|
+
},
|
|
62
|
+
"types": "./dist/src/index.d.ts",
|
|
63
|
+
"version": "0.0.1"
|
|
64
|
+
}
|