@codometer/languages 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 +964 -0
- package/dist/src/index.d.ts +1697 -0
- package/dist/src/index.js +1985 -0
- package/package.json +74 -0
|
@@ -0,0 +1,1985 @@
|
|
|
1
|
+
import { ConsoleLogger as e, Global as t, Injectable as n, Module as r, Scope as i } from "@nestjs/common";
|
|
2
|
+
import { existsSync as a, mkdirSync as o, mkdtempSync as s, readFileSync as c, rmSync as l, writeFileSync as ee } from "node:fs";
|
|
3
|
+
import u from "node:path";
|
|
4
|
+
import d from "pino";
|
|
5
|
+
import te from "postcss";
|
|
6
|
+
import { CODOMETER_COMMENT_LANGUAGES as ne } from "@codometer/configuration";
|
|
7
|
+
import f from "typescript";
|
|
8
|
+
import { LineCounter as re, Parser as ie, isAlias as ae, isMap as oe, isPair as se, isScalar as ce, isSeq as le, parseAllDocuments as ue } from "yaml";
|
|
9
|
+
import { remark as de } from "remark";
|
|
10
|
+
import fe from "remark-frontmatter";
|
|
11
|
+
import pe from "remark-gfm";
|
|
12
|
+
import { execSync as me } from "node:child_process";
|
|
13
|
+
import { tmpdir as he } from "node:os";
|
|
14
|
+
import { fileURLToPath as ge } from "node:url";
|
|
15
|
+
import { z as p } from "zod";
|
|
16
|
+
//#region packages/logger/src/modules/logger/logger.constants.ts
|
|
17
|
+
var _e = /^(\p{Extended_Pictographic}️?(?:\p{Extended_Pictographic}️?)*)\s+/u, ve = /^([A-Za-z]+)/, ye = /* @__PURE__ */ new Set([
|
|
18
|
+
"built",
|
|
19
|
+
"cut",
|
|
20
|
+
"found",
|
|
21
|
+
"got",
|
|
22
|
+
"kept",
|
|
23
|
+
"left",
|
|
24
|
+
"lost",
|
|
25
|
+
"made",
|
|
26
|
+
"put",
|
|
27
|
+
"ran",
|
|
28
|
+
"read",
|
|
29
|
+
"rebuilt",
|
|
30
|
+
"sent",
|
|
31
|
+
"set",
|
|
32
|
+
"split",
|
|
33
|
+
"took",
|
|
34
|
+
"wrote"
|
|
35
|
+
]), be = /* @__PURE__ */ new Set([
|
|
36
|
+
"CommandFactory",
|
|
37
|
+
"ExceptionHandler",
|
|
38
|
+
"GraphQLModule",
|
|
39
|
+
"InstanceLoader",
|
|
40
|
+
"NestApplication",
|
|
41
|
+
"NestFactory",
|
|
42
|
+
"RouterExplorer",
|
|
43
|
+
"RoutesResolver",
|
|
44
|
+
"TypeOrmModule"
|
|
45
|
+
]);
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region \0@oxc-project+runtime@0.151.0/helpers/esm/decorateMetadata.js
|
|
48
|
+
function m(e, t) {
|
|
49
|
+
if (typeof Reflect == "object" && typeof Reflect.metadata == "function") return Reflect.metadata(e, t);
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region \0@oxc-project+runtime@0.151.0/helpers/esm/decorate.js
|
|
53
|
+
function h(e, t, n, r) {
|
|
54
|
+
var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
|
|
55
|
+
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
|
|
56
|
+
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);
|
|
57
|
+
return i > 3 && a && Object.defineProperty(t, n, a), a;
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region packages/logger/src/modules/logger/logger.service.ts
|
|
61
|
+
var g, _ = class extends e {
|
|
62
|
+
static {
|
|
63
|
+
g = this;
|
|
64
|
+
}
|
|
65
|
+
constructor() {
|
|
66
|
+
super();
|
|
67
|
+
}
|
|
68
|
+
static isProduction = process.env.NODE_ENV === "production";
|
|
69
|
+
static rootLogger;
|
|
70
|
+
static writesToStandardError = !1;
|
|
71
|
+
child = g.root;
|
|
72
|
+
static createRootLogger() {
|
|
73
|
+
let e = process.env.LOG_LEVEL ?? "info";
|
|
74
|
+
return g.isProduction ? g.writesToStandardError ? d({ level: e }, d.destination(2)) : d({ level: e }) : d({
|
|
75
|
+
level: e,
|
|
76
|
+
transport: {
|
|
77
|
+
options: {
|
|
78
|
+
colorize: !0,
|
|
79
|
+
destination: g.writesToStandardError ? 2 : 1,
|
|
80
|
+
ignore: "pid,hostname,emoji",
|
|
81
|
+
messageFormat: "{emoji} {msg}",
|
|
82
|
+
singleLine: !0
|
|
83
|
+
},
|
|
84
|
+
target: "pino-pretty"
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
static logToStandardError() {
|
|
89
|
+
if (g.rootLogger !== void 0) {
|
|
90
|
+
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.");
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
g.writesToStandardError = !0;
|
|
94
|
+
}
|
|
95
|
+
assertConventionalMessage(e) {
|
|
96
|
+
if (g.isProduction || this.shouldSkipConventionalMessageValidation(e.context)) return;
|
|
97
|
+
let t = this.getConventionalMessageViolation(e.parsed);
|
|
98
|
+
if (t !== void 0) throw Error(t);
|
|
99
|
+
}
|
|
100
|
+
buildBindings(e) {
|
|
101
|
+
return this.assertConventionalMessage({
|
|
102
|
+
context: e.context,
|
|
103
|
+
parsed: e.parsed
|
|
104
|
+
}), {
|
|
105
|
+
...e.data,
|
|
106
|
+
context: e.context,
|
|
107
|
+
...g.isProduction ? {} : { emoji: e.parsed.emoji }
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
getConventionalMessageViolation(e) {
|
|
111
|
+
let t = e.emoji, n = e.text;
|
|
112
|
+
if (t === void 0) return `Log message must start with an emoji naming its subject, then a verb: "${n}"`;
|
|
113
|
+
let r = ve.exec(n)?.[1];
|
|
114
|
+
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}"`;
|
|
115
|
+
}
|
|
116
|
+
isConventionalVerb(e) {
|
|
117
|
+
let t = e.toLowerCase();
|
|
118
|
+
return t.endsWith("ing") || t.endsWith("ed") || ye.has(t);
|
|
119
|
+
}
|
|
120
|
+
parseMessage(e) {
|
|
121
|
+
let t = String(e), n = _e.exec(t), r = n?.[1];
|
|
122
|
+
return r === void 0 ? {
|
|
123
|
+
emoji: void 0,
|
|
124
|
+
text: t
|
|
125
|
+
} : {
|
|
126
|
+
emoji: r,
|
|
127
|
+
text: t.slice(n?.[0].length)
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
shouldSkipConventionalMessageValidation(e) {
|
|
131
|
+
return e !== void 0 && be.has(e);
|
|
132
|
+
}
|
|
133
|
+
static get root() {
|
|
134
|
+
return g.rootLogger ??= g.createRootLogger(), g.rootLogger;
|
|
135
|
+
}
|
|
136
|
+
buildErrorLogEntry(e, t) {
|
|
137
|
+
let n = t instanceof Error ? t.stack || t.message : String(t);
|
|
138
|
+
return {
|
|
139
|
+
errorMessage: n,
|
|
140
|
+
logLine: `[${(/* @__PURE__ */ new Date()).toISOString()}] ${e}: ${n}\n`
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
createTimestampedOutputLogFilePath(e) {
|
|
144
|
+
let t = u.join(process.cwd(), "output");
|
|
145
|
+
return a(t) || o(t, { recursive: !0 }), u.join(t, `${e}-${(/* @__PURE__ */ new Date()).toISOString().replaceAll(/[:.]/g, "-")}.log`);
|
|
146
|
+
}
|
|
147
|
+
debug(e, t, n) {
|
|
148
|
+
let r = this.parseMessage(e);
|
|
149
|
+
this.child.debug(this.buildBindings({
|
|
150
|
+
context: t ?? this.context,
|
|
151
|
+
data: n,
|
|
152
|
+
parsed: r
|
|
153
|
+
}), r.text);
|
|
154
|
+
}
|
|
155
|
+
error(e, t, n) {
|
|
156
|
+
let r = this.parseMessage(e), i = typeof n == "object" ? n : void 0, a = typeof n == "string" ? n : this.context;
|
|
157
|
+
this.child.error({
|
|
158
|
+
...this.buildBindings({
|
|
159
|
+
context: a,
|
|
160
|
+
data: i,
|
|
161
|
+
parsed: r
|
|
162
|
+
}),
|
|
163
|
+
stack: t
|
|
164
|
+
}, r.text);
|
|
165
|
+
}
|
|
166
|
+
info(e, t, n) {
|
|
167
|
+
let r = this.parseMessage(e);
|
|
168
|
+
this.child.info(this.buildBindings({
|
|
169
|
+
context: t ?? this.context,
|
|
170
|
+
data: n,
|
|
171
|
+
parsed: r
|
|
172
|
+
}), r.text);
|
|
173
|
+
}
|
|
174
|
+
log(e, t, n) {
|
|
175
|
+
this.info(e, t, n);
|
|
176
|
+
}
|
|
177
|
+
setContext(e) {
|
|
178
|
+
super.setContext(e), this.child = g.root.child({ context: e });
|
|
179
|
+
}
|
|
180
|
+
verbose(e, t, n) {
|
|
181
|
+
let r = this.parseMessage(e);
|
|
182
|
+
this.child.trace(this.buildBindings({
|
|
183
|
+
context: t ?? this.context,
|
|
184
|
+
data: n,
|
|
185
|
+
parsed: r
|
|
186
|
+
}), r.text);
|
|
187
|
+
}
|
|
188
|
+
warn(e, t, n) {
|
|
189
|
+
let r = this.parseMessage(e);
|
|
190
|
+
this.child.warn(this.buildBindings({
|
|
191
|
+
context: t ?? this.context,
|
|
192
|
+
data: n,
|
|
193
|
+
parsed: r
|
|
194
|
+
}), r.text);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
_ = g = h([n({ scope: i.TRANSIENT }), m("design:paramtypes", [])], _);
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region packages/logger/src/modules/logger/logger.module.ts
|
|
200
|
+
var v = class {};
|
|
201
|
+
v = h([t(), r({
|
|
202
|
+
controllers: [],
|
|
203
|
+
exports: [_],
|
|
204
|
+
imports: [],
|
|
205
|
+
providers: [_]
|
|
206
|
+
})], v);
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/comments/comments.constants.ts
|
|
209
|
+
var xe = "comment", Se = /#[^\n]*/g, Ce = /\/\/[^\n]*/g, we = /^\s*#+\s?/u, y = class {
|
|
210
|
+
constructor() {}
|
|
211
|
+
countWords(e) {
|
|
212
|
+
let t = e.trim();
|
|
213
|
+
return t === "" ? 0 : t.split(/\s+/u).length;
|
|
214
|
+
}
|
|
215
|
+
declaredLimits(e, t) {
|
|
216
|
+
let n = [];
|
|
217
|
+
return t.maximumCharacters !== void 0 && n.push({
|
|
218
|
+
limit: t.maximumCharacters,
|
|
219
|
+
measured: e.source.length,
|
|
220
|
+
unit: "characters"
|
|
221
|
+
}), t.maximumLines !== void 0 && n.push({
|
|
222
|
+
limit: t.maximumLines,
|
|
223
|
+
measured: e.source.split("\n").length,
|
|
224
|
+
unit: "lines"
|
|
225
|
+
}), t.maximumWords !== void 0 && n.push({
|
|
226
|
+
limit: t.maximumWords,
|
|
227
|
+
measured: this.countWords(e.prose),
|
|
228
|
+
unit: "words"
|
|
229
|
+
}), n;
|
|
230
|
+
}
|
|
231
|
+
readProse(e) {
|
|
232
|
+
return e.map((e) => e.prose).join(" ").trim();
|
|
233
|
+
}
|
|
234
|
+
readSource(e) {
|
|
235
|
+
return e.map((e) => e.source).join("\n");
|
|
236
|
+
}
|
|
237
|
+
toExcerpt(e) {
|
|
238
|
+
return e.length > 48 ? `${e.slice(0, 48)}…` : e;
|
|
239
|
+
}
|
|
240
|
+
groupIntoBlocks(e) {
|
|
241
|
+
let t = [];
|
|
242
|
+
for (let n of e) {
|
|
243
|
+
let e = t.at(-1), r = e?.tokens.at(-1);
|
|
244
|
+
if (e !== void 0 && r !== void 0 && n.ownLine && r.ownLine && n.line === r.line + 1) {
|
|
245
|
+
e.tokens.push(n);
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
t.push({ tokens: [n] });
|
|
249
|
+
}
|
|
250
|
+
return t;
|
|
251
|
+
}
|
|
252
|
+
measure(e) {
|
|
253
|
+
return this.groupIntoBlocks(e.tokens).flatMap((t) => {
|
|
254
|
+
let n = this.readProse(t.tokens);
|
|
255
|
+
return this.measureText({
|
|
256
|
+
comments: e.comments,
|
|
257
|
+
declaration: this.toExcerpt(n),
|
|
258
|
+
filePath: e.filePath,
|
|
259
|
+
kind: xe,
|
|
260
|
+
line: t.tokens[0]?.line ?? 1,
|
|
261
|
+
prose: n,
|
|
262
|
+
source: this.readSource(t.tokens)
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
measureText(e) {
|
|
267
|
+
return this.declaredLimits(e, e.comments).map(({ limit: t, measured: n, unit: r }) => ({
|
|
268
|
+
breached: n > t,
|
|
269
|
+
declaration: e.declaration,
|
|
270
|
+
file: e.filePath,
|
|
271
|
+
kind: e.kind,
|
|
272
|
+
limit: t,
|
|
273
|
+
line: e.line,
|
|
274
|
+
measured: n,
|
|
275
|
+
severity: e.comments.severity,
|
|
276
|
+
unit: r
|
|
277
|
+
}));
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
y = h([n(), m("design:paramtypes", [])], y);
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/comments/css-comments.service.ts
|
|
283
|
+
var b = class {
|
|
284
|
+
constructor() {}
|
|
285
|
+
toBody(e) {
|
|
286
|
+
/* v8 ignore next -- postcss always sets both after a real parse */
|
|
287
|
+
let t = e.raws.left ?? "", n = e.raws.right ?? "";
|
|
288
|
+
return `${t}${e.text}${n}`;
|
|
289
|
+
}
|
|
290
|
+
toOwnLine(e, t) {
|
|
291
|
+
/* v8 ignore next -- unreachable: this reader only sees parsed comments */
|
|
292
|
+
let { column: n, line: r } = t.source?.start ?? {
|
|
293
|
+
column: 1,
|
|
294
|
+
line: 1
|
|
295
|
+
};
|
|
296
|
+
return (e.split("\n")[r - 1] ?? "").slice(0, n - 1).trim() === "";
|
|
297
|
+
}
|
|
298
|
+
read(e) {
|
|
299
|
+
let t = [];
|
|
300
|
+
try {
|
|
301
|
+
te.parse(e).walkComments((n) => {
|
|
302
|
+
let r = this.toBody(n);
|
|
303
|
+
t.push({
|
|
304
|
+
/* v8 ignore next -- unreachable: this reader only sees parsed comments */
|
|
305
|
+
line: n.source?.start?.line ?? 1,
|
|
306
|
+
ownLine: this.toOwnLine(e, n),
|
|
307
|
+
prose: r,
|
|
308
|
+
source: `/*${r}*/`
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
} catch {
|
|
312
|
+
return [];
|
|
313
|
+
}
|
|
314
|
+
return t;
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
b = h([n(), m("design:paramtypes", [])], b);
|
|
318
|
+
//#endregion
|
|
319
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/comments/hash-comments.service.ts
|
|
320
|
+
var x = class {
|
|
321
|
+
constructor() {}
|
|
322
|
+
isShebang(e, t, n) {
|
|
323
|
+
return e === 0 && t === 0 && n.startsWith("#!");
|
|
324
|
+
}
|
|
325
|
+
read(e) {
|
|
326
|
+
let t = [];
|
|
327
|
+
for (let [n, r] of e.split("\n").entries()) {
|
|
328
|
+
let e = r.indexOf("#");
|
|
329
|
+
if (e !== -1 && !this.isShebang(n, e, r)) {
|
|
330
|
+
let i = r.slice(e);
|
|
331
|
+
t.push({
|
|
332
|
+
line: n + 1,
|
|
333
|
+
ownLine: r.slice(0, e).trim() === "",
|
|
334
|
+
prose: i.replace(we, ""),
|
|
335
|
+
source: i
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return t;
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
x = h([n(), m("design:paramtypes", [])], x);
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/comments/hcl-comments.service.ts
|
|
345
|
+
var S = class {
|
|
346
|
+
constructor() {}
|
|
347
|
+
findBlockComments(e) {
|
|
348
|
+
let t = [], n = 0;
|
|
349
|
+
for (let r = e.indexOf("/*", n); r !== -1; r = e.indexOf("/*", n)) {
|
|
350
|
+
let i = e.indexOf("*/", r + 2);
|
|
351
|
+
if (i === -1) break;
|
|
352
|
+
let a = i + 2;
|
|
353
|
+
t.push({
|
|
354
|
+
end: a,
|
|
355
|
+
start: r
|
|
356
|
+
}), n = a;
|
|
357
|
+
}
|
|
358
|
+
return t;
|
|
359
|
+
}
|
|
360
|
+
isOwnLine(e, t) {
|
|
361
|
+
let n = e.lastIndexOf("\n", t - 1) + 1;
|
|
362
|
+
return e.slice(n, t).trim() === "";
|
|
363
|
+
}
|
|
364
|
+
lineOf(e, t) {
|
|
365
|
+
return e.slice(0, t).split("\n").length;
|
|
366
|
+
}
|
|
367
|
+
readBlocks(e) {
|
|
368
|
+
return this.findBlockComments(e).map(({ end: t, start: n }) => ({
|
|
369
|
+
end: t,
|
|
370
|
+
start: n,
|
|
371
|
+
token: {
|
|
372
|
+
line: this.lineOf(e, n),
|
|
373
|
+
ownLine: this.isOwnLine(e, n),
|
|
374
|
+
prose: e.slice(n + 2, t - 2),
|
|
375
|
+
source: e.slice(n, t)
|
|
376
|
+
}
|
|
377
|
+
}));
|
|
378
|
+
}
|
|
379
|
+
readMatches(e, t, n) {
|
|
380
|
+
return [...e.matchAll(t)].map((t) => {
|
|
381
|
+
let r = t[0], i = t.index;
|
|
382
|
+
return {
|
|
383
|
+
end: i + r.length,
|
|
384
|
+
start: i,
|
|
385
|
+
token: {
|
|
386
|
+
line: this.lineOf(e, i),
|
|
387
|
+
ownLine: this.isOwnLine(e, i),
|
|
388
|
+
prose: n(r),
|
|
389
|
+
source: r
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
read(e) {
|
|
395
|
+
let t = this.readBlocks(e), n = (e) => t.some((t) => e >= t.start && e < t.end), r = this.readMatches(e, Se, (e) => e.slice(1)).filter((e) => !n(e.start)), i = this.readMatches(e, Ce, (e) => e.slice(2)).filter((e) => !n(e.start));
|
|
396
|
+
return [
|
|
397
|
+
...t,
|
|
398
|
+
...r,
|
|
399
|
+
...i
|
|
400
|
+
].toSorted((e, t) => e.start - t.start).map(({ token: e }) => e);
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
S = h([n(), m("design:paramtypes", [])], S);
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/sql/sql.constants.ts
|
|
406
|
+
var Te = /\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g, Ee = /--[^\n]*/g, De = [
|
|
407
|
+
["commonTableExpressions", /\bWITH\b/gi],
|
|
408
|
+
["creates", /\bCREATE\b/gi],
|
|
409
|
+
["deletes", /\bDELETE\b/gi],
|
|
410
|
+
["inserts", /\bINSERT\b/gi],
|
|
411
|
+
["joins", /\b(?:CROSS|FULL|INNER|LEFT|NATURAL|OUTER|RIGHT)?\s*JOIN\b/gi],
|
|
412
|
+
["selects", /\bSELECT\b/gi],
|
|
413
|
+
["updates", /\bUPDATE\b/gi]
|
|
414
|
+
], Oe = {
|
|
415
|
+
comments: 0,
|
|
416
|
+
commonTableExpressions: 0,
|
|
417
|
+
creates: 0,
|
|
418
|
+
deletes: 0,
|
|
419
|
+
files: 0,
|
|
420
|
+
inserts: 0,
|
|
421
|
+
joins: 0,
|
|
422
|
+
lines: 0,
|
|
423
|
+
selects: 0,
|
|
424
|
+
statements: 0,
|
|
425
|
+
updates: 0
|
|
426
|
+
}, C = class {
|
|
427
|
+
constructor() {}
|
|
428
|
+
findBlockComments(e) {
|
|
429
|
+
let t = [], n = 0;
|
|
430
|
+
for (let r = e.indexOf("/*", n); r !== -1; r = e.indexOf("/*", n)) {
|
|
431
|
+
let i = e.indexOf("*/", r + 2);
|
|
432
|
+
if (i === -1) break;
|
|
433
|
+
let a = i + 2;
|
|
434
|
+
t.push({
|
|
435
|
+
end: a,
|
|
436
|
+
start: r
|
|
437
|
+
}), n = a;
|
|
438
|
+
}
|
|
439
|
+
return t;
|
|
440
|
+
}
|
|
441
|
+
isOwnLine(e, t) {
|
|
442
|
+
let n = e.lastIndexOf("\n", t - 1) + 1;
|
|
443
|
+
return e.slice(n, t).trim() === "";
|
|
444
|
+
}
|
|
445
|
+
lineOf(e, t) {
|
|
446
|
+
return e.slice(0, t).split("\n").length;
|
|
447
|
+
}
|
|
448
|
+
readBlocks(e) {
|
|
449
|
+
return this.findBlockComments(e).map(({ end: t, start: n }) => ({
|
|
450
|
+
end: t,
|
|
451
|
+
start: n,
|
|
452
|
+
token: {
|
|
453
|
+
line: this.lineOf(e, n),
|
|
454
|
+
ownLine: this.isOwnLine(e, n),
|
|
455
|
+
prose: e.slice(n + 2, t - 2),
|
|
456
|
+
source: e.slice(n, t)
|
|
457
|
+
}
|
|
458
|
+
}));
|
|
459
|
+
}
|
|
460
|
+
readMatches(e, t, n) {
|
|
461
|
+
return [...e.matchAll(t)].map((t) => {
|
|
462
|
+
let r = t[0], i = t.index;
|
|
463
|
+
return {
|
|
464
|
+
end: i + r.length,
|
|
465
|
+
start: i,
|
|
466
|
+
token: {
|
|
467
|
+
line: this.lineOf(e, i),
|
|
468
|
+
ownLine: this.isOwnLine(e, i),
|
|
469
|
+
prose: n(r),
|
|
470
|
+
source: r
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
read(e) {
|
|
476
|
+
let t = this.readBlocks(e), n = this.readMatches(e, Ee, (e) => e.slice(2)).filter((e) => !t.some((t) => e.start >= t.start && e.start < t.end));
|
|
477
|
+
return [...t, ...n].toSorted((e, t) => e.start - t.start).map(({ token: e }) => e);
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
C = h([n(), m("design:paramtypes", [])], C);
|
|
481
|
+
//#endregion
|
|
482
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/comments/typescript-comments.constants.ts
|
|
483
|
+
var ke = /* @__PURE__ */ new Set([
|
|
484
|
+
".cjs",
|
|
485
|
+
".js",
|
|
486
|
+
".jsx",
|
|
487
|
+
".mjs"
|
|
488
|
+
]), Ae = /* @__PURE__ */ new Set([".jsx", ".tsx"]), w = class {
|
|
489
|
+
constructor() {}
|
|
490
|
+
collectComments(e, t, n) {
|
|
491
|
+
if (e.getChildCount(t) === 0) {
|
|
492
|
+
for (let t of [...f.getLeadingCommentRanges(n.content, e.getFullStart()) ?? [], ...f.getTrailingCommentRanges(n.content, e.getEnd()) ?? []]) n.ranges.set(t.pos, t);
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
for (let r of e.getChildren(t)) this.collectComments(r, t, n);
|
|
496
|
+
}
|
|
497
|
+
getScriptKind(e) {
|
|
498
|
+
let t = u.extname(e);
|
|
499
|
+
return Ae.has(t) ? f.ScriptKind.TSX : ke.has(t) ? f.ScriptKind.JS : f.ScriptKind.TS;
|
|
500
|
+
}
|
|
501
|
+
isJsDoc(e, t) {
|
|
502
|
+
return e.kind === f.SyntaxKind.MultiLineCommentTrivia && t.startsWith("/**");
|
|
503
|
+
}
|
|
504
|
+
isOwnLine(e, t) {
|
|
505
|
+
let n = e.lastIndexOf("\n", t - 1) + 1;
|
|
506
|
+
return e.slice(n, t).trim() === "";
|
|
507
|
+
}
|
|
508
|
+
lineOf(e, t) {
|
|
509
|
+
return e.slice(0, t).split("\n").length;
|
|
510
|
+
}
|
|
511
|
+
toProse(e) {
|
|
512
|
+
return e.startsWith("//") ? e.slice(2) : e.replace(/^\/\*/u, "").replace(/\*\/$/u, "");
|
|
513
|
+
}
|
|
514
|
+
toToken(e, t) {
|
|
515
|
+
let n = t.slice(e.pos, e.end);
|
|
516
|
+
if (!this.isJsDoc(e, n)) return {
|
|
517
|
+
line: this.lineOf(t, e.pos),
|
|
518
|
+
ownLine: this.isOwnLine(t, e.pos),
|
|
519
|
+
prose: this.toProse(n),
|
|
520
|
+
source: n
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
read(e, t) {
|
|
524
|
+
let n = {
|
|
525
|
+
content: e,
|
|
526
|
+
ranges: /* @__PURE__ */ new Map()
|
|
527
|
+
}, r = f.createSourceFile(t, e, f.ScriptTarget.Latest, !1, this.getScriptKind(t));
|
|
528
|
+
return this.collectComments(r, r, n), [...n.ranges.values()].toSorted((e, t) => e.pos - t.pos).flatMap((t) => {
|
|
529
|
+
let n = this.toToken(t, e);
|
|
530
|
+
return n === void 0 ? [] : [n];
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
w = h([n(), m("design:paramtypes", [])], w);
|
|
535
|
+
//#endregion
|
|
536
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/comments/yaml-comments.service.ts
|
|
537
|
+
var T = class {
|
|
538
|
+
constructor() {}
|
|
539
|
+
collectComments(e, t) {
|
|
540
|
+
if (typeof e != "object" || !e) return;
|
|
541
|
+
if (Array.isArray(e)) {
|
|
542
|
+
for (let n of e) this.collectComments(n, t);
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
let n = { ...e };
|
|
546
|
+
this.isCommentToken(n) && t.tokens.push(this.toToken(t, n.offset, n.source));
|
|
547
|
+
for (let e of Object.values(n)) this.collectComments(e, t);
|
|
548
|
+
}
|
|
549
|
+
isCommentToken(e) {
|
|
550
|
+
return e.type === "comment" && typeof e.offset == "number" && typeof e.source == "string";
|
|
551
|
+
}
|
|
552
|
+
toToken(e, t, n) {
|
|
553
|
+
let { col: r, line: i } = e.lineCounter.linePos(t);
|
|
554
|
+
return {
|
|
555
|
+
offset: t,
|
|
556
|
+
token: {
|
|
557
|
+
line: i,
|
|
558
|
+
ownLine: e.content.slice(t - (r - 1), t).trim() === "",
|
|
559
|
+
prose: n.replace(we, ""),
|
|
560
|
+
source: n
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
read(e) {
|
|
565
|
+
let t = {
|
|
566
|
+
content: e,
|
|
567
|
+
lineCounter: new re(),
|
|
568
|
+
tokens: []
|
|
569
|
+
};
|
|
570
|
+
for (let n of new ie(t.lineCounter.addNewLine).parse(e)) this.collectComments(n, t);
|
|
571
|
+
return t.tokens.toSorted((e, t) => e.offset - t.offset).map((e) => e.token);
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
T = h([n(), m("design:paramtypes", [])], T);
|
|
575
|
+
//#endregion
|
|
576
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/comments/language-comments.service.ts
|
|
577
|
+
var je, E = je = class {
|
|
578
|
+
comments;
|
|
579
|
+
cssComments;
|
|
580
|
+
hashComments;
|
|
581
|
+
hclComments;
|
|
582
|
+
logger;
|
|
583
|
+
sqlComments;
|
|
584
|
+
typescriptComments;
|
|
585
|
+
yamlComments;
|
|
586
|
+
constructor(e, t, n, r, i, a, o, s) {
|
|
587
|
+
this.comments = e, this.cssComments = t, this.hashComments = n, this.hclComments = r, this.logger = i, this.sqlComments = a, this.typescriptComments = o, this.yamlComments = s, this.logger.setContext(je.name);
|
|
588
|
+
}
|
|
589
|
+
measureLanguage(e) {
|
|
590
|
+
let t = [];
|
|
591
|
+
for (let n of e.files) {
|
|
592
|
+
let r = this.readFile(e.workingDirectory, n);
|
|
593
|
+
r !== void 0 && t.push(...this.comments.measure({
|
|
594
|
+
comments: e.budget,
|
|
595
|
+
filePath: n,
|
|
596
|
+
tokens: e.read(r, n)
|
|
597
|
+
}));
|
|
598
|
+
}
|
|
599
|
+
return t;
|
|
600
|
+
}
|
|
601
|
+
measureOneLanguage(e) {
|
|
602
|
+
let { counter: t, files: n, language: r, pythonComments: i, workingDirectory: a } = e;
|
|
603
|
+
if (r === "python") return this.measurePython(t.budget, i);
|
|
604
|
+
let o = (e) => this.hashComments.read(e), { files: s, read: c } = {
|
|
605
|
+
css: {
|
|
606
|
+
files: n.cssFiles,
|
|
607
|
+
read: (e) => this.cssComments.read(e)
|
|
608
|
+
},
|
|
609
|
+
hcl: {
|
|
610
|
+
files: n.hclFiles,
|
|
611
|
+
read: (e) => this.hclComments.read(e)
|
|
612
|
+
},
|
|
613
|
+
python: {
|
|
614
|
+
files: [],
|
|
615
|
+
read: o
|
|
616
|
+
},
|
|
617
|
+
shell: {
|
|
618
|
+
files: n.shellFiles,
|
|
619
|
+
read: o
|
|
620
|
+
},
|
|
621
|
+
sql: {
|
|
622
|
+
files: n.sqlFiles,
|
|
623
|
+
read: (e) => this.sqlComments.read(e)
|
|
624
|
+
},
|
|
625
|
+
toml: {
|
|
626
|
+
files: n.tomlFiles,
|
|
627
|
+
read: o
|
|
628
|
+
},
|
|
629
|
+
typescript: {
|
|
630
|
+
files: n.sourceFiles,
|
|
631
|
+
read: (e, t) => this.typescriptComments.read(e, t)
|
|
632
|
+
},
|
|
633
|
+
yaml: {
|
|
634
|
+
files: n.yamlFiles,
|
|
635
|
+
read: (e) => this.yamlComments.read(e)
|
|
636
|
+
}
|
|
637
|
+
}[r];
|
|
638
|
+
return this.measureLanguage({
|
|
639
|
+
budget: t.budget,
|
|
640
|
+
files: s,
|
|
641
|
+
read: c,
|
|
642
|
+
workingDirectory: a
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
measurePython(e, t) {
|
|
646
|
+
let n = /* @__PURE__ */ new Map();
|
|
647
|
+
for (let { file: e, ...r } of t) {
|
|
648
|
+
let t = n.get(e) ?? [];
|
|
649
|
+
t.push(r), n.set(e, t);
|
|
650
|
+
}
|
|
651
|
+
return [...n].flatMap(([t, n]) => this.comments.measure({
|
|
652
|
+
comments: e,
|
|
653
|
+
filePath: t,
|
|
654
|
+
tokens: n
|
|
655
|
+
}));
|
|
656
|
+
}
|
|
657
|
+
readFile(e, t) {
|
|
658
|
+
try {
|
|
659
|
+
return c(u.resolve(e, t), "utf8");
|
|
660
|
+
} catch (e) {
|
|
661
|
+
let n = e instanceof Error ? e.message : String(e);
|
|
662
|
+
this.logger.warn("🗒️ Skipped comment measurement", void 0, {
|
|
663
|
+
filePath: t,
|
|
664
|
+
reason: n
|
|
665
|
+
});
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
measure(e) {
|
|
670
|
+
let { counters: t, files: n, pythonComments: r, workingDirectory: i } = e, a = {};
|
|
671
|
+
for (let e of t) {
|
|
672
|
+
if (e.kind !== void 0) continue;
|
|
673
|
+
let t = e.language === void 0 ? ne : [e.language];
|
|
674
|
+
a[e.label] = t.flatMap((t) => this.measureOneLanguage({
|
|
675
|
+
counter: e,
|
|
676
|
+
files: n,
|
|
677
|
+
language: t,
|
|
678
|
+
pythonComments: r,
|
|
679
|
+
workingDirectory: i
|
|
680
|
+
}));
|
|
681
|
+
}
|
|
682
|
+
return a;
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
E = je = h([n(), m("design:paramtypes", [
|
|
686
|
+
y === void 0 ? Object : y,
|
|
687
|
+
b === void 0 ? Object : b,
|
|
688
|
+
x === void 0 ? Object : x,
|
|
689
|
+
S === void 0 ? Object : S,
|
|
690
|
+
_ === void 0 ? Object : _,
|
|
691
|
+
C === void 0 ? Object : C,
|
|
692
|
+
w === void 0 ? Object : w,
|
|
693
|
+
T === void 0 ? Object : T
|
|
694
|
+
])], E);
|
|
695
|
+
//#endregion
|
|
696
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/comments/comments.module.ts
|
|
697
|
+
var D = class {};
|
|
698
|
+
D = h([r({
|
|
699
|
+
controllers: [],
|
|
700
|
+
exports: [
|
|
701
|
+
y,
|
|
702
|
+
b,
|
|
703
|
+
x,
|
|
704
|
+
S,
|
|
705
|
+
E,
|
|
706
|
+
C,
|
|
707
|
+
w,
|
|
708
|
+
T
|
|
709
|
+
],
|
|
710
|
+
imports: [v],
|
|
711
|
+
providers: [
|
|
712
|
+
y,
|
|
713
|
+
b,
|
|
714
|
+
x,
|
|
715
|
+
S,
|
|
716
|
+
E,
|
|
717
|
+
C,
|
|
718
|
+
w,
|
|
719
|
+
T
|
|
720
|
+
]
|
|
721
|
+
})], D);
|
|
722
|
+
var Me = {
|
|
723
|
+
atRules: 0,
|
|
724
|
+
comments: 0,
|
|
725
|
+
customProperties: 0,
|
|
726
|
+
declarations: 0,
|
|
727
|
+
files: 0,
|
|
728
|
+
lines: 0,
|
|
729
|
+
mediaQueries: 0,
|
|
730
|
+
rules: 0,
|
|
731
|
+
selectors: 0
|
|
732
|
+
}, Ne, O = Ne = class {
|
|
733
|
+
logger;
|
|
734
|
+
constructor(e) {
|
|
735
|
+
this.logger = e, this.logger.setContext(Ne.name);
|
|
736
|
+
}
|
|
737
|
+
countNode(e, t) {
|
|
738
|
+
if (e.type === "comment") {
|
|
739
|
+
t.comments++;
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
if (e.type === "decl") {
|
|
743
|
+
t.declarations++, e.prop.startsWith("--") && t.customProperties++;
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
if (e.type === "atrule") {
|
|
747
|
+
t.atRules++, e.name === "media" && t.mediaQueries++;
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
t.rules++, t.selectors += e.selectors.length;
|
|
751
|
+
}
|
|
752
|
+
analyze({ cssFiles: e, workingDirectory: t }) {
|
|
753
|
+
let n = { ...Me };
|
|
754
|
+
for (let r of e) try {
|
|
755
|
+
let e = c(u.resolve(t, r), "utf8"), i = te.parse(e);
|
|
756
|
+
n.files++, n.lines += e.split("\n").length, i.walk((e) => {
|
|
757
|
+
this.countNode(e, n);
|
|
758
|
+
});
|
|
759
|
+
} catch (e) {
|
|
760
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
761
|
+
this.logger.warn("🎨 Skipped CSS analysis", void 0, {
|
|
762
|
+
filePath: r,
|
|
763
|
+
reason: t
|
|
764
|
+
});
|
|
765
|
+
continue;
|
|
766
|
+
}
|
|
767
|
+
return n;
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
O = Ne = h([n(), m("design:paramtypes", [_ === void 0 ? Object : _])], O);
|
|
771
|
+
//#endregion
|
|
772
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/css/css.module.ts
|
|
773
|
+
var k = class {};
|
|
774
|
+
k = h([r({
|
|
775
|
+
controllers: [],
|
|
776
|
+
exports: [O],
|
|
777
|
+
imports: [v],
|
|
778
|
+
providers: [O]
|
|
779
|
+
})], k);
|
|
780
|
+
//#endregion
|
|
781
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/hcl/hcl.constants.ts
|
|
782
|
+
var Pe = /^([A-Za-z_]\w*)\s+(?:"[^"]*"\s*)*\{/, Fe = /^[A-Za-z_]\w*\s*=/, Ie = /\$\{[^}]*\}/g, Le = {
|
|
783
|
+
attributes: 0,
|
|
784
|
+
blocks: 0,
|
|
785
|
+
comments: 0,
|
|
786
|
+
files: 0,
|
|
787
|
+
interpolations: 0,
|
|
788
|
+
lines: 0,
|
|
789
|
+
outputs: 0,
|
|
790
|
+
resources: 0,
|
|
791
|
+
variables: 0
|
|
792
|
+
}, Re, A = Re = class {
|
|
793
|
+
logger;
|
|
794
|
+
constructor(e) {
|
|
795
|
+
this.logger = e, this.logger.setContext(Re.name);
|
|
796
|
+
}
|
|
797
|
+
countBlock(e, t) {
|
|
798
|
+
if (t.blocks++, e === "resource" || e === "data") {
|
|
799
|
+
t.resources++;
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
if (e === "variable") {
|
|
803
|
+
t.variables++;
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
e === "output" && t.outputs++;
|
|
807
|
+
}
|
|
808
|
+
countLine(e, t) {
|
|
809
|
+
let n = e.trim();
|
|
810
|
+
if (n.startsWith("#") || n.startsWith("//")) {
|
|
811
|
+
t.comments++;
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
t.interpolations += (n.match(Ie) ?? []).length;
|
|
815
|
+
let r = Pe.exec(n)?.[1];
|
|
816
|
+
if (r !== void 0) {
|
|
817
|
+
this.countBlock(r, t);
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
Fe.test(n) && t.attributes++;
|
|
821
|
+
}
|
|
822
|
+
analyze({ hclFiles: e, workingDirectory: t }) {
|
|
823
|
+
let n = { ...Le };
|
|
824
|
+
for (let r of e) try {
|
|
825
|
+
let e = c(u.resolve(t, r), "utf8").split("\n");
|
|
826
|
+
n.files++, n.lines += e.length;
|
|
827
|
+
for (let t of e) this.countLine(t, n);
|
|
828
|
+
} catch (e) {
|
|
829
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
830
|
+
this.logger.warn("🏗️ Skipped HCL analysis", void 0, {
|
|
831
|
+
filePath: r,
|
|
832
|
+
reason: t
|
|
833
|
+
});
|
|
834
|
+
continue;
|
|
835
|
+
}
|
|
836
|
+
return n;
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
A = Re = h([n(), m("design:paramtypes", [_ === void 0 ? Object : _])], A);
|
|
840
|
+
//#endregion
|
|
841
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/hcl/hcl.module.ts
|
|
842
|
+
var j = class {};
|
|
843
|
+
j = h([r({
|
|
844
|
+
controllers: [],
|
|
845
|
+
exports: [A],
|
|
846
|
+
imports: [v],
|
|
847
|
+
providers: [A]
|
|
848
|
+
})], j);
|
|
849
|
+
//#endregion
|
|
850
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/json/json.constants.ts
|
|
851
|
+
var ze = {
|
|
852
|
+
arrays: 0,
|
|
853
|
+
booleans: 0,
|
|
854
|
+
files: 0,
|
|
855
|
+
items: 0,
|
|
856
|
+
lines: 0,
|
|
857
|
+
maxDepth: 0,
|
|
858
|
+
nulls: 0,
|
|
859
|
+
numbers: 0,
|
|
860
|
+
objects: 0,
|
|
861
|
+
properties: 0,
|
|
862
|
+
strings: 0,
|
|
863
|
+
totalNodes: 0
|
|
864
|
+
}, Be, M = Be = class {
|
|
865
|
+
logger;
|
|
866
|
+
constructor(e) {
|
|
867
|
+
this.logger = e, this.logger.setContext(Be.name);
|
|
868
|
+
}
|
|
869
|
+
consumeCharacterOutsideComments(e, t, n) {
|
|
870
|
+
return e === "\"" ? {
|
|
871
|
+
...n,
|
|
872
|
+
isInString: !0,
|
|
873
|
+
sanitizedContent: `${n.sanitizedContent}${e}`
|
|
874
|
+
} : e === "/" && t === "/" ? {
|
|
875
|
+
...n,
|
|
876
|
+
isInLineComment: !0,
|
|
877
|
+
shouldAdvanceIndex: !0
|
|
878
|
+
} : e === "/" && t === "*" ? {
|
|
879
|
+
...n,
|
|
880
|
+
isInBlockComment: !0,
|
|
881
|
+
shouldAdvanceIndex: !0
|
|
882
|
+
} : {
|
|
883
|
+
...n,
|
|
884
|
+
sanitizedContent: `${n.sanitizedContent}${e}`
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
consumeJsoncCharacter(e, t, n) {
|
|
888
|
+
return n.isInLineComment ? this.handleLineCommentState(e, n) : n.isInBlockComment ? this.handleBlockCommentState(e, t, n) : n.isInString ? this.handleStringState(e, t, n) : this.consumeCharacterOutsideComments(e, t, n);
|
|
889
|
+
}
|
|
890
|
+
countArrayNode(e, t, n) {
|
|
891
|
+
t.arrays++, t.items += e.length, t.totalNodes++, t.maxDepth = Math.max(t.maxDepth, n);
|
|
892
|
+
for (let r of e) this.countNode(r, t, n + 1);
|
|
893
|
+
}
|
|
894
|
+
countNode(e, t, n) {
|
|
895
|
+
if (this.isArrayNode(e)) {
|
|
896
|
+
this.countArrayNode(e, t, n);
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
if (this.isRecordNode(e)) {
|
|
900
|
+
this.countRecordNode(e, t, n);
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
this.countPrimitiveNode(e, t, n);
|
|
904
|
+
}
|
|
905
|
+
countPrimitiveNode(e, t, n) {
|
|
906
|
+
if (t.totalNodes++, t.maxDepth = Math.max(t.maxDepth, n), e === null) {
|
|
907
|
+
t.nulls++;
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
this.countPrimitiveValue(e, t);
|
|
911
|
+
}
|
|
912
|
+
countPrimitiveValue(e, t) {
|
|
913
|
+
let n = typeof e;
|
|
914
|
+
if (n === "boolean") {
|
|
915
|
+
t.booleans++;
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
if (n === "number") {
|
|
919
|
+
t.numbers++;
|
|
920
|
+
return;
|
|
921
|
+
}
|
|
922
|
+
n === "string" && t.strings++;
|
|
923
|
+
}
|
|
924
|
+
countRecordNode(e, t, n) {
|
|
925
|
+
t.objects++, t.totalNodes++, t.maxDepth = Math.max(t.maxDepth, n);
|
|
926
|
+
let r = Object.entries(e);
|
|
927
|
+
t.properties += r.length;
|
|
928
|
+
for (let [, e] of r) this.countNode(e, t, n + 1);
|
|
929
|
+
}
|
|
930
|
+
handleBlockCommentState(e, t, n) {
|
|
931
|
+
return e === "*" && t === "/" ? {
|
|
932
|
+
...n,
|
|
933
|
+
isInBlockComment: !1,
|
|
934
|
+
shouldAdvanceIndex: !0
|
|
935
|
+
} : {
|
|
936
|
+
...n,
|
|
937
|
+
isInBlockComment: !0,
|
|
938
|
+
shouldAdvanceIndex: !1
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
handleLineCommentState(e, t) {
|
|
942
|
+
return e === "\n" ? {
|
|
943
|
+
...t,
|
|
944
|
+
isInLineComment: !1,
|
|
945
|
+
sanitizedContent: `${t.sanitizedContent}${e}`
|
|
946
|
+
} : {
|
|
947
|
+
...t,
|
|
948
|
+
isInLineComment: !0
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
handleStringState(e, t, n) {
|
|
952
|
+
let r = `${n.sanitizedContent}${e}`;
|
|
953
|
+
return e === "\\" ? {
|
|
954
|
+
...n,
|
|
955
|
+
isInString: !0,
|
|
956
|
+
sanitizedContent: `${r}${t}`,
|
|
957
|
+
shouldAdvanceIndex: !0
|
|
958
|
+
} : e === "\"" ? {
|
|
959
|
+
...n,
|
|
960
|
+
isInString: !1,
|
|
961
|
+
sanitizedContent: r
|
|
962
|
+
} : {
|
|
963
|
+
...n,
|
|
964
|
+
isInString: !0,
|
|
965
|
+
sanitizedContent: r
|
|
966
|
+
};
|
|
967
|
+
}
|
|
968
|
+
isArrayNode(e) {
|
|
969
|
+
return Array.isArray(e);
|
|
970
|
+
}
|
|
971
|
+
isRecordNode(e) {
|
|
972
|
+
return typeof e == "object" && !!e;
|
|
973
|
+
}
|
|
974
|
+
parseDocuments(e, t) {
|
|
975
|
+
if (t === ".jsonl") return e.split(/\r?\n/).filter((e) => e.trim() !== "").map((e) => JSON.parse(e));
|
|
976
|
+
let n = t === ".jsonc" ? this.stripJsoncComments(e) : e;
|
|
977
|
+
return [JSON.parse(n)];
|
|
978
|
+
}
|
|
979
|
+
stripJsoncComments(e) {
|
|
980
|
+
let t = "", n = {
|
|
981
|
+
isInBlockComment: !1,
|
|
982
|
+
isInLineComment: !1,
|
|
983
|
+
isInString: !1,
|
|
984
|
+
sanitizedContent: "",
|
|
985
|
+
shouldAdvanceIndex: !1
|
|
986
|
+
};
|
|
987
|
+
for (let r = 0; r < e.length; r++) {
|
|
988
|
+
let i = e[r] ?? "", a = e[r + 1] ?? "";
|
|
989
|
+
n = this.consumeJsoncCharacter(i, a, n), t = n.sanitizedContent, n.shouldAdvanceIndex && (r++, n = {
|
|
990
|
+
...n,
|
|
991
|
+
shouldAdvanceIndex: !1
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
return t;
|
|
995
|
+
}
|
|
996
|
+
analyze(e) {
|
|
997
|
+
let { jsonFiles: t, workingDirectory: n } = e, r = {
|
|
998
|
+
...ze,
|
|
999
|
+
files: t.length
|
|
1000
|
+
};
|
|
1001
|
+
for (let e of t) {
|
|
1002
|
+
let t = u.resolve(n, e), i = u.extname(e).toLowerCase();
|
|
1003
|
+
try {
|
|
1004
|
+
let e = c(t, "utf8");
|
|
1005
|
+
r.lines += e.split(/\r?\n/).filter((e) => e.trim() !== "").length;
|
|
1006
|
+
let n = this.parseDocuments(e, i);
|
|
1007
|
+
for (let e of n) this.countNode(e, r, 1);
|
|
1008
|
+
} catch (e) {
|
|
1009
|
+
this.logger.warn("🧮 Skipped JSON analysis", void 0, {
|
|
1010
|
+
path: t,
|
|
1011
|
+
reason: e instanceof Error ? e.message : String(e)
|
|
1012
|
+
});
|
|
1013
|
+
continue;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
return r;
|
|
1017
|
+
}
|
|
1018
|
+
};
|
|
1019
|
+
M = Be = h([n(), m("design:paramtypes", [_ === void 0 ? Object : _])], M);
|
|
1020
|
+
//#endregion
|
|
1021
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/json/json.module.ts
|
|
1022
|
+
var N = class {};
|
|
1023
|
+
N = h([r({
|
|
1024
|
+
controllers: [],
|
|
1025
|
+
exports: [M],
|
|
1026
|
+
imports: [v],
|
|
1027
|
+
providers: [M]
|
|
1028
|
+
})], N);
|
|
1029
|
+
//#endregion
|
|
1030
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/markdown/markdown.constants.ts
|
|
1031
|
+
var Ve = {
|
|
1032
|
+
blockQuotes: 0,
|
|
1033
|
+
codeBlocks: 0,
|
|
1034
|
+
files: 0,
|
|
1035
|
+
headingLevel1: 0,
|
|
1036
|
+
headingLevel2: 0,
|
|
1037
|
+
headingLevel3: 0,
|
|
1038
|
+
headingLevel4: 0,
|
|
1039
|
+
headingLevel5: 0,
|
|
1040
|
+
headingLevel6: 0,
|
|
1041
|
+
images: 0,
|
|
1042
|
+
inlineCode: 0,
|
|
1043
|
+
lines: 0,
|
|
1044
|
+
links: 0,
|
|
1045
|
+
listItems: 0,
|
|
1046
|
+
lists: 0,
|
|
1047
|
+
paragraphs: 0,
|
|
1048
|
+
tableRows: 0,
|
|
1049
|
+
tables: 0,
|
|
1050
|
+
taskListItems: 0,
|
|
1051
|
+
thematicBreaks: 0
|
|
1052
|
+
}, He = {
|
|
1053
|
+
blockquote: "blockQuotes",
|
|
1054
|
+
code: "codeBlocks",
|
|
1055
|
+
image: "images",
|
|
1056
|
+
imageReference: "images",
|
|
1057
|
+
inlineCode: "inlineCode",
|
|
1058
|
+
link: "links",
|
|
1059
|
+
linkReference: "links",
|
|
1060
|
+
list: "lists",
|
|
1061
|
+
paragraph: "paragraphs",
|
|
1062
|
+
table: "tables",
|
|
1063
|
+
tableRow: "tableRows",
|
|
1064
|
+
thematicBreak: "thematicBreaks"
|
|
1065
|
+
}, Ue, P = Ue = class {
|
|
1066
|
+
logger;
|
|
1067
|
+
constructor(e) {
|
|
1068
|
+
this.logger = e, this.logger.setContext(Ue.name);
|
|
1069
|
+
}
|
|
1070
|
+
processor = de().use(pe).use(fe, ["yaml", "toml"]);
|
|
1071
|
+
countHeading(e, t) {
|
|
1072
|
+
t[`headingLevel${e.depth}`]++;
|
|
1073
|
+
}
|
|
1074
|
+
countListItem(e, t) {
|
|
1075
|
+
t.listItems++, typeof e.checked == "boolean" && t.taskListItems++;
|
|
1076
|
+
}
|
|
1077
|
+
countNode(e, t) {
|
|
1078
|
+
if (e.type === "heading") {
|
|
1079
|
+
this.countHeading(e, t);
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
if (e.type === "listItem") {
|
|
1083
|
+
this.countListItem(e, t);
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
let n = He[e.type];
|
|
1087
|
+
n !== void 0 && t[n]++;
|
|
1088
|
+
}
|
|
1089
|
+
walk(e, t) {
|
|
1090
|
+
if (this.countNode(e, t), "children" in e) for (let n of e.children) this.walk(n, t);
|
|
1091
|
+
}
|
|
1092
|
+
analyze({ markdownFiles: e, workingDirectory: t }) {
|
|
1093
|
+
let n = [];
|
|
1094
|
+
for (let r of e) try {
|
|
1095
|
+
n.push(c(u.resolve(t, r), "utf8"));
|
|
1096
|
+
} catch (e) {
|
|
1097
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
1098
|
+
this.logger.warn("📝 Skipped markdown analysis", void 0, {
|
|
1099
|
+
filePath: r,
|
|
1100
|
+
reason: t
|
|
1101
|
+
});
|
|
1102
|
+
continue;
|
|
1103
|
+
}
|
|
1104
|
+
return this.analyzeContents(n);
|
|
1105
|
+
}
|
|
1106
|
+
analyzeContents(e) {
|
|
1107
|
+
let t = { ...Ve };
|
|
1108
|
+
for (let n of e) {
|
|
1109
|
+
let e = this.processor.parse(n);
|
|
1110
|
+
t.files++, t.lines += n.split("\n").length;
|
|
1111
|
+
for (let n of e.children) this.walk(n, t);
|
|
1112
|
+
}
|
|
1113
|
+
return t;
|
|
1114
|
+
}
|
|
1115
|
+
};
|
|
1116
|
+
P = Ue = h([n(), m("design:paramtypes", [_ === void 0 ? Object : _])], P);
|
|
1117
|
+
//#endregion
|
|
1118
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/markdown/markdown.module.ts
|
|
1119
|
+
var F = class {};
|
|
1120
|
+
F = h([r({
|
|
1121
|
+
controllers: [],
|
|
1122
|
+
exports: [P],
|
|
1123
|
+
imports: [v],
|
|
1124
|
+
providers: [P]
|
|
1125
|
+
})], F);
|
|
1126
|
+
//#endregion
|
|
1127
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/python/python.constants.ts
|
|
1128
|
+
var I = {
|
|
1129
|
+
classes: 0,
|
|
1130
|
+
commentLines: 0,
|
|
1131
|
+
comments: 0,
|
|
1132
|
+
commentTokens: [],
|
|
1133
|
+
constants: 0,
|
|
1134
|
+
decorators: 0,
|
|
1135
|
+
docstringLines: 0,
|
|
1136
|
+
docstrings: 0,
|
|
1137
|
+
files: 0,
|
|
1138
|
+
functions: 0,
|
|
1139
|
+
imports: 0,
|
|
1140
|
+
lines: 0,
|
|
1141
|
+
protocols: 0
|
|
1142
|
+
}, L, R = L = class {
|
|
1143
|
+
logger;
|
|
1144
|
+
constructor(e) {
|
|
1145
|
+
this.logger = e, this.logger.setContext(L.name);
|
|
1146
|
+
}
|
|
1147
|
+
scriptPath = u.resolve(u.dirname(ge(import.meta.url)), "python.service.py");
|
|
1148
|
+
analyze(e) {
|
|
1149
|
+
if (e.pythonFiles.length === 0) return {
|
|
1150
|
+
...I,
|
|
1151
|
+
commentTokens: []
|
|
1152
|
+
};
|
|
1153
|
+
try {
|
|
1154
|
+
let t = me(`${e.command} "${this.scriptPath}"`, {
|
|
1155
|
+
cwd: e.workingDirectory,
|
|
1156
|
+
encoding: "utf8",
|
|
1157
|
+
input: e.pythonFiles.join("\n")
|
|
1158
|
+
});
|
|
1159
|
+
return JSON.parse(t.trim());
|
|
1160
|
+
} catch (e) {
|
|
1161
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
1162
|
+
return this.logger.warn("🐍 Skipped Python analysis", void 0, { reason: t }), {
|
|
1163
|
+
...I,
|
|
1164
|
+
commentTokens: []
|
|
1165
|
+
};
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
analyzeContents(e) {
|
|
1169
|
+
if (e.contents.length === 0) return {
|
|
1170
|
+
...I,
|
|
1171
|
+
commentTokens: []
|
|
1172
|
+
};
|
|
1173
|
+
let t = s(u.join(he(), "codometer-python-"));
|
|
1174
|
+
try {
|
|
1175
|
+
let n = e.contents.map((e, n) => {
|
|
1176
|
+
let r = u.join(t, `source-${n}.py`);
|
|
1177
|
+
return ee(r, e, "utf8"), r;
|
|
1178
|
+
});
|
|
1179
|
+
return this.analyze({
|
|
1180
|
+
command: e.command,
|
|
1181
|
+
pythonFiles: n,
|
|
1182
|
+
workingDirectory: e.workingDirectory
|
|
1183
|
+
});
|
|
1184
|
+
} finally {
|
|
1185
|
+
l(t, {
|
|
1186
|
+
force: !0,
|
|
1187
|
+
recursive: !0
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
};
|
|
1192
|
+
R = L = h([n(), m("design:paramtypes", [_ === void 0 ? Object : _])], R);
|
|
1193
|
+
//#endregion
|
|
1194
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/python/python.module.ts
|
|
1195
|
+
var z = class {};
|
|
1196
|
+
z = h([r({
|
|
1197
|
+
controllers: [],
|
|
1198
|
+
exports: [R],
|
|
1199
|
+
imports: [v],
|
|
1200
|
+
providers: [R]
|
|
1201
|
+
})], z);
|
|
1202
|
+
var We = p.object({
|
|
1203
|
+
cell_type: p.string().optional(),
|
|
1204
|
+
execution_count: p.number().nullish(),
|
|
1205
|
+
outputs: p.array(p.unknown()).optional(),
|
|
1206
|
+
source: p.union([p.string(), p.array(p.string())]).optional()
|
|
1207
|
+
}), Ge = p.object({ cells: p.array(We).optional() }), Ke = {
|
|
1208
|
+
cells: 0,
|
|
1209
|
+
classes: 0,
|
|
1210
|
+
codeBlocks: 0,
|
|
1211
|
+
codeCells: 0,
|
|
1212
|
+
codeLines: 0,
|
|
1213
|
+
decorators: 0,
|
|
1214
|
+
executedCells: 0,
|
|
1215
|
+
files: 0,
|
|
1216
|
+
functions: 0,
|
|
1217
|
+
headings: 0,
|
|
1218
|
+
images: 0,
|
|
1219
|
+
imports: 0,
|
|
1220
|
+
links: 0,
|
|
1221
|
+
markdownCells: 0,
|
|
1222
|
+
markdownLines: 0,
|
|
1223
|
+
maxDepth: 0,
|
|
1224
|
+
outputs: 0,
|
|
1225
|
+
properties: 0,
|
|
1226
|
+
rawCells: 0,
|
|
1227
|
+
totalNodes: 0
|
|
1228
|
+
}, qe, B = qe = class {
|
|
1229
|
+
jsonService;
|
|
1230
|
+
markdownService;
|
|
1231
|
+
pythonService;
|
|
1232
|
+
logger;
|
|
1233
|
+
constructor(e, t, n, r) {
|
|
1234
|
+
this.jsonService = e, this.markdownService = t, this.pythonService = n, this.logger = r, this.logger.setContext(qe.name);
|
|
1235
|
+
}
|
|
1236
|
+
collectCell(e, t) {
|
|
1237
|
+
if (t.cells++, t.outputs += e.outputs?.length ?? 0, e.cell_type === "code") {
|
|
1238
|
+
t.codeCells++, t.codeSources.push(this.readSource(e.source)), typeof e.execution_count == "number" && t.executedCells++;
|
|
1239
|
+
return;
|
|
1240
|
+
}
|
|
1241
|
+
if (e.cell_type === "markdown") {
|
|
1242
|
+
t.markdownCells++, t.markdownSources.push(this.readSource(e.source));
|
|
1243
|
+
return;
|
|
1244
|
+
}
|
|
1245
|
+
t.rawCells++;
|
|
1246
|
+
}
|
|
1247
|
+
collectParts(e) {
|
|
1248
|
+
let t = {
|
|
1249
|
+
cells: 0,
|
|
1250
|
+
codeCells: 0,
|
|
1251
|
+
codeSources: [],
|
|
1252
|
+
executedCells: 0,
|
|
1253
|
+
files: 0,
|
|
1254
|
+
markdownCells: 0,
|
|
1255
|
+
markdownSources: [],
|
|
1256
|
+
outputs: 0,
|
|
1257
|
+
rawCells: 0
|
|
1258
|
+
};
|
|
1259
|
+
for (let n of e.notebookFiles) {
|
|
1260
|
+
let r = this.readNotebook(n, e.workingDirectory);
|
|
1261
|
+
if (r !== void 0) {
|
|
1262
|
+
t.files++;
|
|
1263
|
+
for (let e of r) this.collectCell(e, t);
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
return t;
|
|
1267
|
+
}
|
|
1268
|
+
countHeadings(e) {
|
|
1269
|
+
return e.headingLevel1 + e.headingLevel2 + e.headingLevel3 + e.headingLevel4 + e.headingLevel5 + e.headingLevel6;
|
|
1270
|
+
}
|
|
1271
|
+
readNotebook(e, t) {
|
|
1272
|
+
try {
|
|
1273
|
+
let n = c(u.resolve(t, e), "utf8");
|
|
1274
|
+
return Ge.parse(JSON.parse(n)).cells ?? [];
|
|
1275
|
+
} catch (t) {
|
|
1276
|
+
let n = t instanceof Error ? t.message : String(t);
|
|
1277
|
+
this.logger.warn("📓 Skipped notebook analysis", void 0, {
|
|
1278
|
+
filePath: e,
|
|
1279
|
+
reason: n
|
|
1280
|
+
});
|
|
1281
|
+
return;
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
readSource(e) {
|
|
1285
|
+
return typeof e == "string" ? e : e?.join("") ?? "";
|
|
1286
|
+
}
|
|
1287
|
+
analyze(e) {
|
|
1288
|
+
if (e.notebookFiles.length === 0) return { ...Ke };
|
|
1289
|
+
let t = this.collectParts(e), n = this.jsonService.analyze({
|
|
1290
|
+
jsonFiles: e.notebookFiles,
|
|
1291
|
+
workingDirectory: e.workingDirectory
|
|
1292
|
+
}), r = this.pythonService.analyzeContents({
|
|
1293
|
+
command: e.pythonCommand,
|
|
1294
|
+
contents: t.codeSources,
|
|
1295
|
+
workingDirectory: e.workingDirectory
|
|
1296
|
+
}), i = this.markdownService.analyzeContents(t.markdownSources);
|
|
1297
|
+
return {
|
|
1298
|
+
cells: t.cells,
|
|
1299
|
+
classes: r.classes,
|
|
1300
|
+
codeBlocks: i.codeBlocks,
|
|
1301
|
+
codeCells: t.codeCells,
|
|
1302
|
+
codeLines: r.lines,
|
|
1303
|
+
decorators: r.decorators,
|
|
1304
|
+
executedCells: t.executedCells,
|
|
1305
|
+
files: t.files,
|
|
1306
|
+
functions: r.functions,
|
|
1307
|
+
headings: this.countHeadings(i),
|
|
1308
|
+
images: i.images,
|
|
1309
|
+
imports: r.imports,
|
|
1310
|
+
links: i.links,
|
|
1311
|
+
markdownCells: t.markdownCells,
|
|
1312
|
+
markdownLines: i.lines,
|
|
1313
|
+
maxDepth: n.maxDepth,
|
|
1314
|
+
outputs: t.outputs,
|
|
1315
|
+
properties: n.properties,
|
|
1316
|
+
rawCells: t.rawCells,
|
|
1317
|
+
totalNodes: n.totalNodes
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
};
|
|
1321
|
+
B = qe = h([n(), m("design:paramtypes", [
|
|
1322
|
+
M === void 0 ? Object : M,
|
|
1323
|
+
P === void 0 ? Object : P,
|
|
1324
|
+
R === void 0 ? Object : R,
|
|
1325
|
+
_ === void 0 ? Object : _
|
|
1326
|
+
])], B);
|
|
1327
|
+
//#endregion
|
|
1328
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/jupyter/jupyter.module.ts
|
|
1329
|
+
var V = class {};
|
|
1330
|
+
V = h([r({
|
|
1331
|
+
controllers: [],
|
|
1332
|
+
exports: [B],
|
|
1333
|
+
imports: [
|
|
1334
|
+
N,
|
|
1335
|
+
v,
|
|
1336
|
+
F,
|
|
1337
|
+
z
|
|
1338
|
+
],
|
|
1339
|
+
providers: [B]
|
|
1340
|
+
})], V);
|
|
1341
|
+
//#endregion
|
|
1342
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/shell/shell.constants.ts
|
|
1343
|
+
var Je = /^(?:function\s+)?[\w-]+\s*\(\s*\)|^function\s+[\w-]+/, Ye = /^(?:export|declare\s+-x)\s+[A-Za-z_]\w*=/, Xe = /^(?:local\s+|readonly\s+|declare\s+)?[A-Za-z_]\w*=/, Ze = /(?:^|;\s*)(?:if|elif|case)\s/, Qe = /(?:^|;\s*)(?:for|while|until)\s/, $e = /(?<!\|)\|(?!\|)/g, et = {
|
|
1344
|
+
commentLines: 0,
|
|
1345
|
+
comments: 0,
|
|
1346
|
+
conditionals: 0,
|
|
1347
|
+
exports: 0,
|
|
1348
|
+
files: 0,
|
|
1349
|
+
functions: 0,
|
|
1350
|
+
lines: 0,
|
|
1351
|
+
loops: 0,
|
|
1352
|
+
pipelines: 0,
|
|
1353
|
+
shebangs: 0,
|
|
1354
|
+
variables: 0
|
|
1355
|
+
}, tt, H = tt = class {
|
|
1356
|
+
logger;
|
|
1357
|
+
constructor(e) {
|
|
1358
|
+
this.logger = e, this.logger.setContext(tt.name);
|
|
1359
|
+
}
|
|
1360
|
+
countLine(e, t) {
|
|
1361
|
+
let n = e.trim();
|
|
1362
|
+
if (n.startsWith("#!")) {
|
|
1363
|
+
t.shebangs++;
|
|
1364
|
+
return;
|
|
1365
|
+
}
|
|
1366
|
+
if (n.startsWith("#")) {
|
|
1367
|
+
t.comments++, t.commentLines++;
|
|
1368
|
+
return;
|
|
1369
|
+
}
|
|
1370
|
+
n !== "" && this.countStatements(n, t);
|
|
1371
|
+
}
|
|
1372
|
+
countStatements(e, t) {
|
|
1373
|
+
Je.test(e) && t.functions++, Ye.test(e) ? t.exports++ : Xe.test(e) && t.variables++, Ze.test(e) && t.conditionals++, Qe.test(e) && t.loops++, t.pipelines += (e.match($e) ?? []).length;
|
|
1374
|
+
}
|
|
1375
|
+
analyze({ shellFiles: e, workingDirectory: t }) {
|
|
1376
|
+
let n = { ...et };
|
|
1377
|
+
for (let r of e) try {
|
|
1378
|
+
let e = c(u.resolve(t, r), "utf8").split("\n");
|
|
1379
|
+
n.files++, n.lines += e.length;
|
|
1380
|
+
for (let t of e) this.countLine(t, n);
|
|
1381
|
+
} catch (e) {
|
|
1382
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
1383
|
+
this.logger.warn("🐚 Skipped shell analysis", void 0, {
|
|
1384
|
+
filePath: r,
|
|
1385
|
+
reason: t
|
|
1386
|
+
});
|
|
1387
|
+
continue;
|
|
1388
|
+
}
|
|
1389
|
+
return n;
|
|
1390
|
+
}
|
|
1391
|
+
};
|
|
1392
|
+
H = tt = h([n(), m("design:paramtypes", [_ === void 0 ? Object : _])], H);
|
|
1393
|
+
//#endregion
|
|
1394
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/shell/shell.module.ts
|
|
1395
|
+
var U = class {};
|
|
1396
|
+
U = h([r({
|
|
1397
|
+
controllers: [],
|
|
1398
|
+
exports: [H],
|
|
1399
|
+
imports: [v],
|
|
1400
|
+
providers: [H]
|
|
1401
|
+
})], U);
|
|
1402
|
+
//#endregion
|
|
1403
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/sql/sql.service.ts
|
|
1404
|
+
var nt, W = nt = class {
|
|
1405
|
+
logger;
|
|
1406
|
+
constructor(e) {
|
|
1407
|
+
this.logger = e, this.logger.setContext(nt.name);
|
|
1408
|
+
}
|
|
1409
|
+
countKeywords(e, t) {
|
|
1410
|
+
for (let [n, r] of De) t[n] += (e.match(r) ?? []).length;
|
|
1411
|
+
}
|
|
1412
|
+
stripComments(e, t) {
|
|
1413
|
+
return e.replaceAll(Te, () => (t.comments++, " ")).replaceAll(Ee, () => (t.comments++, " "));
|
|
1414
|
+
}
|
|
1415
|
+
analyze({ sqlFiles: e, workingDirectory: t }) {
|
|
1416
|
+
let n = { ...Oe };
|
|
1417
|
+
for (let r of e) try {
|
|
1418
|
+
let e = c(u.resolve(t, r), "utf8");
|
|
1419
|
+
n.files++, n.lines += e.split("\n").length;
|
|
1420
|
+
let i = this.stripComments(e, n);
|
|
1421
|
+
n.statements += i.split(";").filter((e) => e.trim() !== "").length, this.countKeywords(i, n);
|
|
1422
|
+
} catch (e) {
|
|
1423
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
1424
|
+
this.logger.warn("🗄️ Skipped SQL analysis", void 0, {
|
|
1425
|
+
filePath: r,
|
|
1426
|
+
reason: t
|
|
1427
|
+
});
|
|
1428
|
+
continue;
|
|
1429
|
+
}
|
|
1430
|
+
return n;
|
|
1431
|
+
}
|
|
1432
|
+
};
|
|
1433
|
+
W = nt = h([n(), m("design:paramtypes", [_ === void 0 ? Object : _])], W);
|
|
1434
|
+
//#endregion
|
|
1435
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/sql/sql.module.ts
|
|
1436
|
+
var G = class {};
|
|
1437
|
+
G = h([r({
|
|
1438
|
+
controllers: [],
|
|
1439
|
+
exports: [W],
|
|
1440
|
+
imports: [v],
|
|
1441
|
+
providers: [W]
|
|
1442
|
+
})], G);
|
|
1443
|
+
//#endregion
|
|
1444
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/toml/toml.constants.ts
|
|
1445
|
+
var rt = /^\[\[[^\]]+\]\]/, it = /^\[[^\]]+\]/, at = /"""|'''/g, ot = {
|
|
1446
|
+
arrays: 0,
|
|
1447
|
+
arrayTables: 0,
|
|
1448
|
+
comments: 0,
|
|
1449
|
+
files: 0,
|
|
1450
|
+
keys: 0,
|
|
1451
|
+
lines: 0,
|
|
1452
|
+
tables: 0
|
|
1453
|
+
}, st, K = st = class {
|
|
1454
|
+
logger;
|
|
1455
|
+
constructor(e) {
|
|
1456
|
+
this.logger = e, this.logger.setContext(st.name);
|
|
1457
|
+
}
|
|
1458
|
+
countKey(e, t) {
|
|
1459
|
+
let n = e.indexOf("=");
|
|
1460
|
+
n <= 0 || (t.keys++, e.slice(n + 1).trim().startsWith("[") && t.arrays++);
|
|
1461
|
+
}
|
|
1462
|
+
countLine(e, t) {
|
|
1463
|
+
let n = e.trim();
|
|
1464
|
+
if (n.startsWith("#")) {
|
|
1465
|
+
t.comments++;
|
|
1466
|
+
return;
|
|
1467
|
+
}
|
|
1468
|
+
if (rt.test(n)) {
|
|
1469
|
+
t.arrayTables++;
|
|
1470
|
+
return;
|
|
1471
|
+
}
|
|
1472
|
+
if (it.test(n)) {
|
|
1473
|
+
t.tables++;
|
|
1474
|
+
return;
|
|
1475
|
+
}
|
|
1476
|
+
this.countKey(n, t);
|
|
1477
|
+
}
|
|
1478
|
+
isInsideMultilineString(e, t) {
|
|
1479
|
+
return (e.match(at) ?? []).length % 2 == 0 ? t : !t;
|
|
1480
|
+
}
|
|
1481
|
+
analyze({ tomlFiles: e, workingDirectory: t }) {
|
|
1482
|
+
let n = { ...ot };
|
|
1483
|
+
for (let r of e) try {
|
|
1484
|
+
let e = c(u.resolve(t, r), "utf8").split("\n"), i = !1;
|
|
1485
|
+
n.files++, n.lines += e.length;
|
|
1486
|
+
for (let t of e) i || this.countLine(t, n), i = this.isInsideMultilineString(t, i);
|
|
1487
|
+
} catch (e) {
|
|
1488
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
1489
|
+
this.logger.warn("🧰 Skipped TOML analysis", void 0, {
|
|
1490
|
+
filePath: r,
|
|
1491
|
+
reason: t
|
|
1492
|
+
});
|
|
1493
|
+
continue;
|
|
1494
|
+
}
|
|
1495
|
+
return n;
|
|
1496
|
+
}
|
|
1497
|
+
};
|
|
1498
|
+
K = st = h([n(), m("design:paramtypes", [_ === void 0 ? Object : _])], K);
|
|
1499
|
+
//#endregion
|
|
1500
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/toml/toml.module.ts
|
|
1501
|
+
var q = class {};
|
|
1502
|
+
q = h([r({
|
|
1503
|
+
controllers: [],
|
|
1504
|
+
exports: [K],
|
|
1505
|
+
imports: [v],
|
|
1506
|
+
providers: [K]
|
|
1507
|
+
})], q);
|
|
1508
|
+
//#endregion
|
|
1509
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/typescript/typescript.constants.ts
|
|
1510
|
+
var ct = {
|
|
1511
|
+
[f.SyntaxKind.ArrowFunction]: "function",
|
|
1512
|
+
[f.SyntaxKind.ClassDeclaration]: "class",
|
|
1513
|
+
[f.SyntaxKind.ClassExpression]: "class",
|
|
1514
|
+
[f.SyntaxKind.EnumDeclaration]: "enum",
|
|
1515
|
+
[f.SyntaxKind.FunctionDeclaration]: "function",
|
|
1516
|
+
[f.SyntaxKind.FunctionExpression]: "function",
|
|
1517
|
+
[f.SyntaxKind.GetAccessor]: "getter",
|
|
1518
|
+
[f.SyntaxKind.InterfaceDeclaration]: "interface",
|
|
1519
|
+
[f.SyntaxKind.MethodDeclaration]: "method",
|
|
1520
|
+
[f.SyntaxKind.PropertyDeclaration]: "property",
|
|
1521
|
+
[f.SyntaxKind.SetAccessor]: "setter"
|
|
1522
|
+
}, lt = {
|
|
1523
|
+
[f.SyntaxKind.AbstractKeyword]: "abstract",
|
|
1524
|
+
[f.SyntaxKind.AsyncKeyword]: "async",
|
|
1525
|
+
[f.SyntaxKind.ExportKeyword]: "export",
|
|
1526
|
+
[f.SyntaxKind.OverrideKeyword]: "override",
|
|
1527
|
+
[f.SyntaxKind.PrivateKeyword]: "private",
|
|
1528
|
+
[f.SyntaxKind.ProtectedKeyword]: "protected",
|
|
1529
|
+
[f.SyntaxKind.PublicKeyword]: "public",
|
|
1530
|
+
[f.SyntaxKind.ReadonlyKeyword]: "readonly",
|
|
1531
|
+
[f.SyntaxKind.StaticKeyword]: "static"
|
|
1532
|
+
}, ut = /\/\/.*\b(?:TODO|FIXME)\b|\/\*[\s\S]*?\b(?:TODO|FIXME)\b[\s\S]*?\*\//g, dt = /@([a-zA-Z][a-zA-Z0-9-]*)/g, ft = /* @__PURE__ */ new Set([
|
|
1533
|
+
".cjs",
|
|
1534
|
+
".js",
|
|
1535
|
+
".jsx",
|
|
1536
|
+
".mjs"
|
|
1537
|
+
]), pt = {
|
|
1538
|
+
asyncFunctions: 0,
|
|
1539
|
+
blockComments: 0,
|
|
1540
|
+
classes: 0,
|
|
1541
|
+
commentLines: 0,
|
|
1542
|
+
comments: 0,
|
|
1543
|
+
constants: 0,
|
|
1544
|
+
declarationCommentCounts: {},
|
|
1545
|
+
decorators: 0,
|
|
1546
|
+
docComments: 0,
|
|
1547
|
+
docTags: {},
|
|
1548
|
+
enums: 0,
|
|
1549
|
+
exported: 0,
|
|
1550
|
+
externalPackages: /* @__PURE__ */ new Set(),
|
|
1551
|
+
functions: 0,
|
|
1552
|
+
genericDeclarations: 0,
|
|
1553
|
+
imports: 0,
|
|
1554
|
+
interfaces: 0,
|
|
1555
|
+
jsFiles: 0,
|
|
1556
|
+
lineComments: 0,
|
|
1557
|
+
lines: 0,
|
|
1558
|
+
methods: 0,
|
|
1559
|
+
symbolCounts: {},
|
|
1560
|
+
syncFunctions: 0,
|
|
1561
|
+
testFiles: 0,
|
|
1562
|
+
todos: 0,
|
|
1563
|
+
tsFiles: 0
|
|
1564
|
+
}, J = class {
|
|
1565
|
+
comments;
|
|
1566
|
+
constructor(e) {
|
|
1567
|
+
this.comments = e;
|
|
1568
|
+
}
|
|
1569
|
+
getDeclarationName(e) {
|
|
1570
|
+
return e.name?.getText?.() ?? "(anonymous)";
|
|
1571
|
+
}
|
|
1572
|
+
getJsDocRange(e, t) {
|
|
1573
|
+
return (f.getLeadingCommentRanges(t.text, e.getFullStart()) ?? []).findLast((e) => e.kind === f.SyntaxKind.MultiLineCommentTrivia && t.text.slice(e.pos, e.pos + 3) === "/**");
|
|
1574
|
+
}
|
|
1575
|
+
prepare(e, t) {
|
|
1576
|
+
let { commentCounters: n, sourceFile: r } = t, i = ct[e.kind];
|
|
1577
|
+
if (i === void 0) return;
|
|
1578
|
+
let a = n.filter((e) => e.kind === i);
|
|
1579
|
+
if (a.length === 0) return;
|
|
1580
|
+
let o = this.getJsDocRange(e, r);
|
|
1581
|
+
if (o === void 0) return;
|
|
1582
|
+
let s = r.text.slice(o.pos, o.end).replaceAll("\r\n", "\n");
|
|
1583
|
+
return {
|
|
1584
|
+
counters: a,
|
|
1585
|
+
declaration: this.getDeclarationName(e),
|
|
1586
|
+
kind: i,
|
|
1587
|
+
line: r.getLineAndCharacterOfPosition(e.getStart(r)).line + 1,
|
|
1588
|
+
prose: this.readProse(s),
|
|
1589
|
+
source: s
|
|
1590
|
+
};
|
|
1591
|
+
}
|
|
1592
|
+
readProse(e) {
|
|
1593
|
+
return e.replace(/^\/\*\*/u, "").replace(/\*\/$/u, "").split("\n").map((e) => e.replace(/^\s*\*\s?/u, "")).join(" ");
|
|
1594
|
+
}
|
|
1595
|
+
measure(e, t) {
|
|
1596
|
+
let n = this.prepare(e, t);
|
|
1597
|
+
if (n === void 0) return [];
|
|
1598
|
+
let { counters: r, declaration: i, kind: a, line: o, prose: s, source: c } = n, l = [];
|
|
1599
|
+
for (let e of r) {
|
|
1600
|
+
let n = this.comments.measureText({
|
|
1601
|
+
comments: e.budget,
|
|
1602
|
+
declaration: i,
|
|
1603
|
+
filePath: t.filePath,
|
|
1604
|
+
kind: a,
|
|
1605
|
+
line: o,
|
|
1606
|
+
prose: s,
|
|
1607
|
+
source: c
|
|
1608
|
+
});
|
|
1609
|
+
for (let t of n) l.push({
|
|
1610
|
+
label: e.label,
|
|
1611
|
+
measurement: t
|
|
1612
|
+
});
|
|
1613
|
+
}
|
|
1614
|
+
return l;
|
|
1615
|
+
}
|
|
1616
|
+
};
|
|
1617
|
+
J = h([n(), m("design:paramtypes", [y === void 0 ? Object : y])], J);
|
|
1618
|
+
//#endregion
|
|
1619
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/typescript/typescript.service.ts
|
|
1620
|
+
var Y = class {
|
|
1621
|
+
declarationComments;
|
|
1622
|
+
constructor(e) {
|
|
1623
|
+
this.declarationComments = e;
|
|
1624
|
+
}
|
|
1625
|
+
kindDispatch = {
|
|
1626
|
+
[f.SyntaxKind.ArrowFunction]: (e, t, n) => this.handleFunction(e, t, n),
|
|
1627
|
+
[f.SyntaxKind.Decorator]: (e, t) => {
|
|
1628
|
+
t.decorators++;
|
|
1629
|
+
},
|
|
1630
|
+
[f.SyntaxKind.EnumDeclaration]: (e, t) => this.handleEnum(e, t),
|
|
1631
|
+
[f.SyntaxKind.FunctionDeclaration]: (e, t, n) => this.handleFunction(e, t, n),
|
|
1632
|
+
[f.SyntaxKind.FunctionExpression]: (e, t, n) => this.handleFunction(e, t, n),
|
|
1633
|
+
[f.SyntaxKind.GetAccessor]: (e, t) => this.handleMethodOrAccessor(e, t),
|
|
1634
|
+
[f.SyntaxKind.ImportDeclaration]: (e, t) => this.handleImport(e, t),
|
|
1635
|
+
[f.SyntaxKind.InterfaceDeclaration]: (e, t) => this.handleInterface(e, t),
|
|
1636
|
+
[f.SyntaxKind.MethodDeclaration]: (e, t) => this.handleMethodOrAccessor(e, t),
|
|
1637
|
+
[f.SyntaxKind.SetAccessor]: (e, t) => this.handleMethodOrAccessor(e, t),
|
|
1638
|
+
[f.SyntaxKind.TypeAliasDeclaration]: (e, t) => this.handleTypeAlias(e, t),
|
|
1639
|
+
[f.SyntaxKind.VariableStatement]: (e, t) => this.handleVariable(e, t)
|
|
1640
|
+
};
|
|
1641
|
+
analyzeFile(e) {
|
|
1642
|
+
let { commentCounters: t, counters: n, filePath: r, stats: i, workingDirectory: a } = e, o = c(u.resolve(a, r), "utf8"), s = f.createSourceFile(r, o, f.ScriptTarget.Latest, !0, this.getScriptKind(r));
|
|
1643
|
+
i.lines += o.split(/\r?\n/).length, i.todos += (o.match(ut) ?? []).length, this.scanComments(o, i), this.walkNode(s, {
|
|
1644
|
+
commentCounters: t,
|
|
1645
|
+
counters: n,
|
|
1646
|
+
filePath: r,
|
|
1647
|
+
insideClass: !1,
|
|
1648
|
+
sourceFile: s,
|
|
1649
|
+
stats: i
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
collectDeclarationComments(e, t) {
|
|
1653
|
+
for (let { label: n, measurement: r } of this.declarationComments.measure(e, t)) (t.stats.declarationCommentCounts[n] ??= []).push(r);
|
|
1654
|
+
}
|
|
1655
|
+
countComment(e, t) {
|
|
1656
|
+
t.comments++;
|
|
1657
|
+
let n = e.replaceAll("\r\n", "\n"), r = n.split("\n").length, i = n.includes("\n") ? Math.max(1, r - 1) : 1;
|
|
1658
|
+
if (t.commentLines += i, e.startsWith("/**")) {
|
|
1659
|
+
t.docComments++;
|
|
1660
|
+
for (let n of e.matchAll(dt)) {
|
|
1661
|
+
let e = n[1]?.toLowerCase() ?? "";
|
|
1662
|
+
t.docTags[e] = (t.docTags[e] ?? 0) + 1;
|
|
1663
|
+
}
|
|
1664
|
+
return;
|
|
1665
|
+
}
|
|
1666
|
+
if (e.startsWith("/*")) {
|
|
1667
|
+
t.blockComments++;
|
|
1668
|
+
return;
|
|
1669
|
+
}
|
|
1670
|
+
t.lineComments++;
|
|
1671
|
+
}
|
|
1672
|
+
countSymbols(e, t) {
|
|
1673
|
+
let n = ct[e.kind];
|
|
1674
|
+
if (n === void 0 || t.counters.length === 0) return;
|
|
1675
|
+
let r = this.getSymbolModifiers(e);
|
|
1676
|
+
for (let e of t.counters) e.kinds.includes(n) && e.modifiers.every((e) => r.has(e)) && (t.stats.symbolCounts[e.label] = (t.stats.symbolCounts[e.label] ?? 0) + 1);
|
|
1677
|
+
}
|
|
1678
|
+
createEmptyResult(e) {
|
|
1679
|
+
let { sourceFiles: t } = e;
|
|
1680
|
+
return {
|
|
1681
|
+
...pt,
|
|
1682
|
+
declarationCommentCounts: this.seedDeclarationCommentCounts(e.commentCounters),
|
|
1683
|
+
docTags: { ...pt.docTags },
|
|
1684
|
+
externalPackages: /* @__PURE__ */ new Set(),
|
|
1685
|
+
jsFiles: t.filter((e) => ft.has(u.extname(e))).length,
|
|
1686
|
+
symbolCounts: Object.fromEntries(e.symbolCounters.map((e) => [e.label, 0])),
|
|
1687
|
+
testFiles: t.filter((e) => /\.(test|spec|unit\.test|integration\.test|end-to-end\.test)\.[cm]?[jt]sx?$/.test(e)).length,
|
|
1688
|
+
tsFiles: t.filter((e) => !ft.has(u.extname(e))).length
|
|
1689
|
+
};
|
|
1690
|
+
}
|
|
1691
|
+
dispatchNode(e, t, n) {
|
|
1692
|
+
this.kindDispatch[e.kind]?.(e, t, n);
|
|
1693
|
+
}
|
|
1694
|
+
getCountersForFile(e, t) {
|
|
1695
|
+
return t.filter((t) => t.patterns.length === 0 || t.patterns.some((t) => u.matchesGlob(e, t)));
|
|
1696
|
+
}
|
|
1697
|
+
getScriptKind(e) {
|
|
1698
|
+
let t = u.extname(e);
|
|
1699
|
+
return t === ".tsx" || t === ".jsx" ? f.ScriptKind.TSX : ft.has(t) ? f.ScriptKind.JS : f.ScriptKind.TS;
|
|
1700
|
+
}
|
|
1701
|
+
getSymbolModifiers(e) {
|
|
1702
|
+
let t = f.canHaveModifiers(e) ? f.getModifiers(e) : void 0, n = /* @__PURE__ */ new Set();
|
|
1703
|
+
for (let e of t ?? []) {
|
|
1704
|
+
let t = lt[e.kind];
|
|
1705
|
+
t !== void 0 && n.add(t);
|
|
1706
|
+
}
|
|
1707
|
+
return n;
|
|
1708
|
+
}
|
|
1709
|
+
handleClass(e, t) {
|
|
1710
|
+
t.classes++, this.hasExportKeyword(e) && t.exported++, this.hasTypeParameters(e) && t.genericDeclarations++;
|
|
1711
|
+
}
|
|
1712
|
+
handleEnum(e, t) {
|
|
1713
|
+
t.enums++, this.hasExportKeyword(e) && t.exported++;
|
|
1714
|
+
}
|
|
1715
|
+
handleFunction(e, t, n) {
|
|
1716
|
+
n ? t.methods++ : (t.functions++, this.hasExportKeyword(e) && t.exported++), this.hasAsyncKeyword(e) ? t.asyncFunctions++ : t.syncFunctions++, this.hasTypeParameters(e) && t.genericDeclarations++;
|
|
1717
|
+
}
|
|
1718
|
+
handleImport(e, t) {
|
|
1719
|
+
if (t.imports++, !f.isImportDeclaration(e) || !f.isStringLiteral(e.moduleSpecifier)) return;
|
|
1720
|
+
let n = e.moduleSpecifier.text;
|
|
1721
|
+
if (n && !n.startsWith(".") && !n.startsWith("/")) {
|
|
1722
|
+
let e = n.startsWith("@") ? n.split("/").slice(0, 2).join("/") : n.split("/")[0] ?? n;
|
|
1723
|
+
t.externalPackages.add(e);
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
handleInterface(e, t) {
|
|
1727
|
+
t.interfaces++, this.hasExportKeyword(e) && t.exported++, this.hasTypeParameters(e) && t.genericDeclarations++;
|
|
1728
|
+
}
|
|
1729
|
+
handleMethodOrAccessor(e, t) {
|
|
1730
|
+
t.methods++, this.hasAsyncKeyword(e) ? t.asyncFunctions++ : t.syncFunctions++;
|
|
1731
|
+
}
|
|
1732
|
+
handleTypeAlias(e, t) {
|
|
1733
|
+
this.hasExportKeyword(e) && t.exported++, this.hasTypeParameters(e) && t.genericDeclarations++;
|
|
1734
|
+
}
|
|
1735
|
+
handleVariable(e, t) {
|
|
1736
|
+
if (f.isVariableStatement(e) && (e.declarationList.flags & f.NodeFlags.Const) !== 0) {
|
|
1737
|
+
let n = e.declarationList.declarations.length;
|
|
1738
|
+
t.constants += n, this.hasExportKeyword(e) && (t.exported += n);
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
hasAsyncKeyword(e) {
|
|
1742
|
+
return (f.canHaveModifiers(e) ? f.getModifiers(e) : void 0)?.some((e) => e.kind === f.SyntaxKind.AsyncKeyword) ?? !1;
|
|
1743
|
+
}
|
|
1744
|
+
hasExportKeyword(e) {
|
|
1745
|
+
return (f.canHaveModifiers(e) ? f.getModifiers(e) : void 0)?.some((e) => e.kind === f.SyntaxKind.ExportKeyword) ?? !1;
|
|
1746
|
+
}
|
|
1747
|
+
hasTypeParameters(e) {
|
|
1748
|
+
let t = e;
|
|
1749
|
+
return "typeParameters" in e && Array.isArray(t.typeParameters) && t.typeParameters.length > 0;
|
|
1750
|
+
}
|
|
1751
|
+
scanComments(e, t) {
|
|
1752
|
+
let n = f.createScanner(f.ScriptTarget.Latest, !1, f.LanguageVariant.Standard, e), r = n.scan();
|
|
1753
|
+
for (; r !== f.SyntaxKind.EndOfFileToken;) (r === f.SyntaxKind.SingleLineCommentTrivia || r === f.SyntaxKind.MultiLineCommentTrivia) && this.countComment(n.getTokenText(), t), r = n.scan();
|
|
1754
|
+
}
|
|
1755
|
+
seedDeclarationCommentCounts(e) {
|
|
1756
|
+
let t = {};
|
|
1757
|
+
for (let n of e) n.kind !== void 0 && (t[n.label] = []);
|
|
1758
|
+
return t;
|
|
1759
|
+
}
|
|
1760
|
+
walkNode(e, t) {
|
|
1761
|
+
if (this.countSymbols(e, t), this.collectDeclarationComments(e, t), e.kind === f.SyntaxKind.ClassDeclaration || e.kind === f.SyntaxKind.ClassExpression) {
|
|
1762
|
+
this.handleClass(e, t.stats);
|
|
1763
|
+
let n = {
|
|
1764
|
+
...t,
|
|
1765
|
+
insideClass: !0
|
|
1766
|
+
};
|
|
1767
|
+
f.forEachChild(e, (e) => this.walkNode(e, n));
|
|
1768
|
+
return;
|
|
1769
|
+
}
|
|
1770
|
+
this.dispatchNode(e, t.stats, t.insideClass), f.forEachChild(e, (e) => this.walkNode(e, t));
|
|
1771
|
+
}
|
|
1772
|
+
analyze(e) {
|
|
1773
|
+
let t = this.createEmptyResult(e);
|
|
1774
|
+
for (let n of e.sourceFiles) this.analyzeFile({
|
|
1775
|
+
commentCounters: e.commentCounters,
|
|
1776
|
+
counters: this.getCountersForFile(n, e.symbolCounters),
|
|
1777
|
+
filePath: n,
|
|
1778
|
+
stats: t,
|
|
1779
|
+
workingDirectory: e.workingDirectory
|
|
1780
|
+
});
|
|
1781
|
+
return t;
|
|
1782
|
+
}
|
|
1783
|
+
};
|
|
1784
|
+
Y = h([n(), m("design:paramtypes", [J === void 0 ? Object : J])], Y);
|
|
1785
|
+
//#endregion
|
|
1786
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/typescript/typescript.module.ts
|
|
1787
|
+
var X = class {};
|
|
1788
|
+
X = h([r({
|
|
1789
|
+
controllers: [],
|
|
1790
|
+
exports: [Y],
|
|
1791
|
+
imports: [D],
|
|
1792
|
+
providers: [J, Y]
|
|
1793
|
+
})], X);
|
|
1794
|
+
//#endregion
|
|
1795
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/yaml/yaml.constants.ts
|
|
1796
|
+
var mt = {
|
|
1797
|
+
aliases: 0,
|
|
1798
|
+
anchors: 0,
|
|
1799
|
+
comments: 0,
|
|
1800
|
+
documents: 0,
|
|
1801
|
+
files: 0,
|
|
1802
|
+
keys: 0,
|
|
1803
|
+
lines: 0,
|
|
1804
|
+
mappings: 0,
|
|
1805
|
+
maxDepth: 0,
|
|
1806
|
+
scalars: 0,
|
|
1807
|
+
sequences: 0
|
|
1808
|
+
}, ht, Z = ht = class {
|
|
1809
|
+
logger;
|
|
1810
|
+
constructor(e) {
|
|
1811
|
+
this.logger = e, this.logger.setContext(ht.name);
|
|
1812
|
+
}
|
|
1813
|
+
countCollection(e, t, n) {
|
|
1814
|
+
if (oe(e)) {
|
|
1815
|
+
t.mappings++;
|
|
1816
|
+
for (let r of e.items) se(r) && (t.keys++, this.countNode(r.key, t, n + 1), this.countNode(r.value, t, n + 1));
|
|
1817
|
+
return;
|
|
1818
|
+
}
|
|
1819
|
+
if (le(e)) {
|
|
1820
|
+
t.sequences++;
|
|
1821
|
+
for (let r of e.items) this.countNode(r, t, n + 1);
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
countComments(e, t) {
|
|
1825
|
+
typeof e.comment == "string" && t.comments++, typeof e.commentBefore == "string" && (t.comments += e.commentBefore.split("\n").length);
|
|
1826
|
+
}
|
|
1827
|
+
countDocument(e, t) {
|
|
1828
|
+
t.documents++, this.countComments(e, t), this.countNode(e.contents, t, 1);
|
|
1829
|
+
}
|
|
1830
|
+
countNode(e, t, n) {
|
|
1831
|
+
if (oe(e) || le(e) || ce(e) || ae(e)) {
|
|
1832
|
+
if (t.maxDepth = Math.max(t.maxDepth, n), this.countComments(e, t), typeof e.anchor == "string" && t.anchors++, ae(e)) {
|
|
1833
|
+
t.aliases++;
|
|
1834
|
+
return;
|
|
1835
|
+
}
|
|
1836
|
+
if (ce(e)) {
|
|
1837
|
+
t.scalars++;
|
|
1838
|
+
return;
|
|
1839
|
+
}
|
|
1840
|
+
this.countCollection(e, t, n);
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
analyze({ workingDirectory: e, yamlFiles: t }) {
|
|
1844
|
+
let n = { ...mt };
|
|
1845
|
+
for (let r of t) try {
|
|
1846
|
+
let t = c(u.resolve(e, r), "utf8");
|
|
1847
|
+
n.files++, n.lines += t.split("\n").length;
|
|
1848
|
+
for (let e of ue(t)) this.countDocument(e, n);
|
|
1849
|
+
} catch (e) {
|
|
1850
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
1851
|
+
this.logger.warn("🧾 Skipped YAML analysis", void 0, {
|
|
1852
|
+
filePath: r,
|
|
1853
|
+
reason: t
|
|
1854
|
+
});
|
|
1855
|
+
continue;
|
|
1856
|
+
}
|
|
1857
|
+
return n;
|
|
1858
|
+
}
|
|
1859
|
+
};
|
|
1860
|
+
Z = ht = h([n(), m("design:paramtypes", [_ === void 0 ? Object : _])], Z);
|
|
1861
|
+
//#endregion
|
|
1862
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/yaml/yaml.module.ts
|
|
1863
|
+
var Q = class {};
|
|
1864
|
+
Q = h([r({
|
|
1865
|
+
controllers: [],
|
|
1866
|
+
exports: [Z],
|
|
1867
|
+
imports: [v],
|
|
1868
|
+
providers: [Z]
|
|
1869
|
+
})], Q);
|
|
1870
|
+
//#endregion
|
|
1871
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/languages/languages.service.ts
|
|
1872
|
+
var $ = class {
|
|
1873
|
+
cssService;
|
|
1874
|
+
languageComments;
|
|
1875
|
+
hclService;
|
|
1876
|
+
jsonService;
|
|
1877
|
+
jupyterService;
|
|
1878
|
+
markdownService;
|
|
1879
|
+
pythonService;
|
|
1880
|
+
shellService;
|
|
1881
|
+
sqlService;
|
|
1882
|
+
tomlService;
|
|
1883
|
+
typescriptService;
|
|
1884
|
+
yamlService;
|
|
1885
|
+
constructor(e, t, n, r, i, a, o, s, c, l, ee, u) {
|
|
1886
|
+
this.cssService = e, this.languageComments = t, this.hclService = n, this.jsonService = r, this.jupyterService = i, this.markdownService = a, this.pythonService = o, this.shellService = s, this.sqlService = c, this.tomlService = l, this.typescriptService = ee, this.yamlService = u;
|
|
1887
|
+
}
|
|
1888
|
+
analyze(e) {
|
|
1889
|
+
let { discoveredFiles: t, workingDirectory: n } = e, r = this.pythonService.analyze({
|
|
1890
|
+
command: e.configuration.python.command,
|
|
1891
|
+
pythonFiles: t.pyFiles,
|
|
1892
|
+
workingDirectory: n
|
|
1893
|
+
});
|
|
1894
|
+
return {
|
|
1895
|
+
commentCounts: this.languageComments.measure({
|
|
1896
|
+
counters: e.commentCounters,
|
|
1897
|
+
files: t,
|
|
1898
|
+
pythonComments: r.commentTokens,
|
|
1899
|
+
workingDirectory: n
|
|
1900
|
+
}),
|
|
1901
|
+
css: this.cssService.analyze({
|
|
1902
|
+
cssFiles: t.cssFiles,
|
|
1903
|
+
workingDirectory: n
|
|
1904
|
+
}),
|
|
1905
|
+
hcl: this.hclService.analyze({
|
|
1906
|
+
hclFiles: t.hclFiles,
|
|
1907
|
+
workingDirectory: n
|
|
1908
|
+
}),
|
|
1909
|
+
json: this.jsonService.analyze({
|
|
1910
|
+
jsonFiles: t.jsonFiles,
|
|
1911
|
+
workingDirectory: n
|
|
1912
|
+
}),
|
|
1913
|
+
jupyter: this.jupyterService.analyze({
|
|
1914
|
+
notebookFiles: t.notebookFiles,
|
|
1915
|
+
pythonCommand: e.configuration.python.command,
|
|
1916
|
+
workingDirectory: n
|
|
1917
|
+
}),
|
|
1918
|
+
markdown: this.markdownService.analyze({
|
|
1919
|
+
markdownFiles: t.markdownFiles,
|
|
1920
|
+
workingDirectory: n
|
|
1921
|
+
}),
|
|
1922
|
+
python: r,
|
|
1923
|
+
shell: this.shellService.analyze({
|
|
1924
|
+
shellFiles: t.shellFiles,
|
|
1925
|
+
workingDirectory: n
|
|
1926
|
+
}),
|
|
1927
|
+
sql: this.sqlService.analyze({
|
|
1928
|
+
sqlFiles: t.sqlFiles,
|
|
1929
|
+
workingDirectory: n
|
|
1930
|
+
}),
|
|
1931
|
+
toml: this.tomlService.analyze({
|
|
1932
|
+
tomlFiles: t.tomlFiles,
|
|
1933
|
+
workingDirectory: n
|
|
1934
|
+
}),
|
|
1935
|
+
typescript: this.typescriptService.analyze({
|
|
1936
|
+
commentCounters: e.commentCounters,
|
|
1937
|
+
sourceFiles: t.sourceFiles,
|
|
1938
|
+
symbolCounters: e.symbolCounters,
|
|
1939
|
+
workingDirectory: n
|
|
1940
|
+
}),
|
|
1941
|
+
yaml: this.yamlService.analyze({
|
|
1942
|
+
workingDirectory: n,
|
|
1943
|
+
yamlFiles: t.yamlFiles
|
|
1944
|
+
})
|
|
1945
|
+
};
|
|
1946
|
+
}
|
|
1947
|
+
};
|
|
1948
|
+
$ = h([n(), m("design:paramtypes", [
|
|
1949
|
+
O === void 0 ? Object : O,
|
|
1950
|
+
E === void 0 ? Object : E,
|
|
1951
|
+
A === void 0 ? Object : A,
|
|
1952
|
+
M === void 0 ? Object : M,
|
|
1953
|
+
B === void 0 ? Object : B,
|
|
1954
|
+
P === void 0 ? Object : P,
|
|
1955
|
+
R === void 0 ? Object : R,
|
|
1956
|
+
H === void 0 ? Object : H,
|
|
1957
|
+
W === void 0 ? Object : W,
|
|
1958
|
+
K === void 0 ? Object : K,
|
|
1959
|
+
Y === void 0 ? Object : Y,
|
|
1960
|
+
Z === void 0 ? Object : Z
|
|
1961
|
+
])], $);
|
|
1962
|
+
//#endregion
|
|
1963
|
+
//#region packages/ic-suite/codometer/codometer-languages/src/modules/languages/languages.module.ts
|
|
1964
|
+
var gt = class {};
|
|
1965
|
+
gt = h([r({
|
|
1966
|
+
controllers: [],
|
|
1967
|
+
exports: [$],
|
|
1968
|
+
imports: [
|
|
1969
|
+
D,
|
|
1970
|
+
k,
|
|
1971
|
+
j,
|
|
1972
|
+
N,
|
|
1973
|
+
V,
|
|
1974
|
+
F,
|
|
1975
|
+
z,
|
|
1976
|
+
U,
|
|
1977
|
+
G,
|
|
1978
|
+
q,
|
|
1979
|
+
X,
|
|
1980
|
+
Q
|
|
1981
|
+
],
|
|
1982
|
+
providers: [$]
|
|
1983
|
+
})], gt);
|
|
1984
|
+
//#endregion
|
|
1985
|
+
export { D as CommentsModule, y as CommentsService, b as CssCommentsService, k as CssModule, O as CssService, x as HashCommentsService, S as HclCommentsService, j as HclModule, A as HclService, N as JsonModule, M as JsonService, V as JupyterModule, B as JupyterService, E as LanguageCommentsService, gt as LanguagesModule, $ as LanguagesService, F as MarkdownModule, P as MarkdownService, z as PythonModule, R as PythonService, U as ShellModule, H as ShellService, C as SqlCommentsService, G as SqlModule, W as SqlService, q as TomlModule, K as TomlService, w as TypescriptCommentsService, X as TypescriptModule, Y as TypescriptService, T as YamlCommentsService, Q as YamlModule, Z as YamlService };
|