@archest/vitest 1.0.0 → 1.0.2

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.
Files changed (95) hide show
  1. package/dist/index.d.ts +3 -0
  2. package/dist/index.js +1 -17
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +118 -551
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/matchers/index.d.ts +21 -0
  7. package/dist/matchers/models.d.ts +201 -0
  8. package/node_modules/@archest/core/dist/classes/classCheckExtendClass.d.ts +3 -0
  9. package/node_modules/@archest/core/dist/classes/classCheckHaveMaxCyclomaticComplexity.d.ts +3 -0
  10. package/node_modules/@archest/core/dist/classes/classCheckHaveModifier.d.ts +3 -0
  11. package/node_modules/@archest/core/dist/classes/classCheckHaveNameMatchingFileName.d.ts +3 -0
  12. package/node_modules/@archest/core/dist/classes/classCheckImplementInterface.d.ts +3 -0
  13. package/node_modules/@archest/core/dist/classes/classCheckMatchNamePattern.d.ts +3 -0
  14. package/node_modules/@archest/core/dist/classes/classCheckResideInFolder.d.ts +3 -0
  15. package/node_modules/@archest/core/dist/classes/locateClasses.d.ts +5 -0
  16. package/node_modules/@archest/core/dist/classes/types.d.ts +25 -0
  17. package/node_modules/@archest/core/dist/dto.d.ts +78 -0
  18. package/node_modules/@archest/core/dist/files/checkDependOnExternalModule.d.ts +3 -0
  19. package/node_modules/@archest/core/dist/files/checkDependOnFilesInFolder.d.ts +3 -0
  20. package/node_modules/@archest/core/dist/files/fileCheckBeFreeOfCycles.d.ts +3 -0
  21. package/node_modules/@archest/core/dist/files/fileCheckHaveMaxCyclomaticComplexity.d.ts +3 -0
  22. package/node_modules/@archest/core/dist/files/fileCheckHaveMaxExportedFunctions.d.ts +3 -0
  23. package/node_modules/@archest/core/dist/files/fileCheckHaveMinMaintainabilityIndex.d.ts +3 -0
  24. package/node_modules/@archest/core/dist/files/fileCheckMatchNamePattern.d.ts +3 -0
  25. package/node_modules/@archest/core/dist/files/getFileDependencies.d.ts +2 -0
  26. package/node_modules/@archest/core/dist/files/locateFiles.d.ts +4 -0
  27. package/node_modules/@archest/core/dist/files/types.d.ts +17 -0
  28. package/node_modules/@archest/core/dist/functions/functionCheckHaveExplicitReturnType.d.ts +3 -0
  29. package/node_modules/@archest/core/dist/functions/functionCheckHaveMaxCyclomaticComplexity.d.ts +3 -0
  30. package/node_modules/@archest/core/dist/functions/functionCheckHaveMinMaintainabilityIndex.d.ts +3 -0
  31. package/node_modules/@archest/core/dist/functions/functionCheckHaveModifier.d.ts +3 -0
  32. package/node_modules/@archest/core/dist/functions/functionCheckHaveNameMatchingFileName.d.ts +3 -0
  33. package/node_modules/@archest/core/dist/functions/functionCheckMatchNamePattern.d.ts +3 -0
  34. package/node_modules/@archest/core/dist/functions/locateFunctions.d.ts +5 -0
  35. package/node_modules/@archest/core/dist/functions/types.d.ts +19 -0
  36. package/node_modules/@archest/core/dist/index.d.ts +43 -0
  37. package/node_modules/@archest/core/dist/index.js +14 -0
  38. package/node_modules/@archest/core/dist/index.js.map +1 -0
  39. package/node_modules/@archest/core/dist/index.mjs +615 -0
  40. package/node_modules/@archest/core/dist/index.mjs.map +1 -0
  41. package/node_modules/@archest/core/dist/layers/checkLayeredArchitecture.d.ts +3 -0
  42. package/node_modules/@archest/core/dist/layers/createLayeredArchitecture.d.ts +3 -0
  43. package/node_modules/@archest/core/dist/layers/getLayerDependencies.d.ts +2 -0
  44. package/node_modules/@archest/core/dist/layers/layer.d.ts +2 -0
  45. package/node_modules/@archest/core/dist/layers/layerShouldNotBeAccessedByAnyLayer.d.ts +2 -0
  46. package/node_modules/@archest/core/dist/layers/layerShouldOnlyBeAccessedBy.d.ts +2 -0
  47. package/node_modules/@archest/core/dist/layers/types.d.ts +8 -0
  48. package/node_modules/@archest/core/dist/metrics/calculateCyclomaticComplexity.d.ts +2 -0
  49. package/node_modules/@archest/core/dist/metrics/calculateMaintainabilityIndex.d.ts +2 -0
  50. package/node_modules/@archest/core/dist/project/parseProject.d.ts +55 -0
  51. package/node_modules/@archest/core/dist/properties/locateProperties.d.ts +5 -0
  52. package/node_modules/@archest/core/dist/properties/propertyCheckBeReadonly.d.ts +3 -0
  53. package/node_modules/@archest/core/dist/properties/types.d.ts +17 -0
  54. package/node_modules/@archest/core/dist/shared/sharedCheckHaveMaxCyclomaticComplexity.d.ts +1 -0
  55. package/node_modules/@archest/core/dist/shared/sharedCheckHaveMinMaintainabilityIndex.d.ts +1 -0
  56. package/node_modules/@archest/core/dist/shared/sharedCheckHaveModifier.d.ts +7 -0
  57. package/node_modules/@archest/core/dist/shared/sharedCheckHaveNameMatchingFileName.d.ts +3 -0
  58. package/node_modules/@archest/core/dist/shared/sharedCheckMatchNamePattern.d.ts +1 -0
  59. package/node_modules/@archest/core/dist/slices/locateSlices.d.ts +3 -0
  60. package/node_modules/@archest/core/dist/slices/sliceCheckBeFreeOfCycles.d.ts +3 -0
  61. package/node_modules/@archest/core/dist/slices/sliceCheckHaveMaxDistanceFromMainSequence.d.ts +3 -0
  62. package/node_modules/@archest/core/dist/slices/types.d.ts +8 -0
  63. package/node_modules/@archest/core/dist/types.d.ts +11 -0
  64. package/node_modules/@archest/core/dist/utils/ruleBuilder.d.ts +6 -0
  65. package/node_modules/@archest/core/package.json +49 -0
  66. package/node_modules/@archest/core-rust/core-rust.darwin-arm64.node +0 -0
  67. package/node_modules/@archest/core-rust/core-rust.linux-x64-gnu.node +0 -0
  68. package/node_modules/@archest/core-rust/core-rust.win32-x64-msvc.node +0 -0
  69. package/node_modules/@archest/core-rust/index.d.ts +16 -0
  70. package/node_modules/@archest/core-rust/index.js +316 -0
  71. package/node_modules/@archest/core-rust/package.json +34 -0
  72. package/package.json +12 -1
  73. package/dist/src/core/ClassLocator.d.ts +0 -20
  74. package/dist/src/core/FileLocator.d.ts +0 -15
  75. package/dist/src/core/FunctionLocator.d.ts +0 -15
  76. package/dist/src/core/LayerLocator.d.ts +0 -23
  77. package/dist/src/core/Project.d.ts +0 -20
  78. package/dist/src/core/PropertyLocator.d.ts +0 -12
  79. package/dist/src/core/SliceLocator.d.ts +0 -10
  80. package/dist/src/core/types.d.ts +0 -4
  81. package/dist/src/index.d.ts +0 -9
  82. package/dist/src/matchers/index.d.ts +0 -15
  83. package/src/core/ClassLocator.ts +0 -226
  84. package/src/core/FileLocator.ts +0 -168
  85. package/src/core/FunctionLocator.ts +0 -105
  86. package/src/core/LayerLocator.ts +0 -119
  87. package/src/core/Project.ts +0 -171
  88. package/src/core/PropertyLocator.ts +0 -50
  89. package/src/core/SliceLocator.ts +0 -92
  90. package/src/core/types.ts +0 -4
  91. package/src/index.ts +0 -9
  92. package/src/matchers/index.ts +0 -113
  93. package/test/architecture.test.ts +0 -59
  94. package/tsconfig.json +0 -17
  95. package/vite.config.ts +0 -18
@@ -0,0 +1,615 @@
1
+ import * as e from "node:path";
2
+ import { dirname as t } from "node:path";
3
+ import { ArchestProject as n } from "@archest/core-rust";
4
+ import * as r from "typescript";
5
+ //#region src/classes/classCheckExtendClass.ts
6
+ function i(e, t, n) {
7
+ let r = [];
8
+ for (let i of e.classes) {
9
+ let e = i.name || "Anonymous", a = !1;
10
+ i.extends === t && (a = !0), n && a ? r.push(`Class ${e} extends ${t}, but it shouldn't.`) : !n && !a && r.push(`Class ${e} does not extend ${t}, but it should.`);
11
+ }
12
+ return {
13
+ pass: r.length === 0,
14
+ message: () => r.join("\n")
15
+ };
16
+ }
17
+ //#endregion
18
+ //#region src/utils/ruleBuilder.ts
19
+ function a(e, t, n) {
20
+ let r = [];
21
+ for (let i of e) {
22
+ let { passes: e, failMessage: a, failNotMessage: o } = n(i);
23
+ t && e ? o && r.push(o) : !t && !e && a && r.push(a);
24
+ }
25
+ return {
26
+ pass: r.length === 0,
27
+ message: () => r.join("\n")
28
+ };
29
+ }
30
+ //#endregion
31
+ //#region src/shared/sharedCheckHaveMaxCyclomaticComplexity.ts
32
+ function o(e, t, n, r, i, o) {
33
+ return a(e, o, (e) => {
34
+ let a = t(e), o = n(e), s = o > i, c = `${r} ${a || "Anonymous"}`;
35
+ return {
36
+ passes: !s,
37
+ failMessage: `${c} has a total cyclomatic complexity of ${o}, which exceeds the maximum of ${i}.`,
38
+ failNotMessage: `${c} has a total cyclomatic complexity of ${o}, which exceeds the maximum of ${i}, but it shouldn't.`
39
+ };
40
+ });
41
+ }
42
+ //#endregion
43
+ //#region src/classes/classCheckHaveMaxCyclomaticComplexity.ts
44
+ function s(e, t, n) {
45
+ return o(e.classes, (e) => e.name, (e) => e.cyclomatic_complexity || 0, "Class", t, n);
46
+ }
47
+ //#endregion
48
+ //#region src/shared/sharedCheckHaveModifier.ts
49
+ function c(e, t, n, r, i) {
50
+ return a(e, i, (e) => {
51
+ let i = t(e), a = !1;
52
+ switch (r) {
53
+ case "export":
54
+ a = !!e.is_exported;
55
+ break;
56
+ case "default":
57
+ a = !!e.is_default;
58
+ break;
59
+ case "abstract":
60
+ a = !!e.is_abstract;
61
+ break;
62
+ case "async":
63
+ a = !!e.is_async;
64
+ break;
65
+ case "readonly":
66
+ a = !!e.is_readonly;
67
+ break;
68
+ default: throw Error(`Modifier ${r} is not fully supported.`);
69
+ }
70
+ let o = `${n} ${i || "Anonymous"}`;
71
+ return {
72
+ passes: a,
73
+ failMessage: `${o} does not have modifier ${r}, but it should.`,
74
+ failNotMessage: `${o} has modifier ${r}, but it shouldn't.`
75
+ };
76
+ });
77
+ }
78
+ //#endregion
79
+ //#region src/classes/classCheckHaveModifier.ts
80
+ function l(e, t, n) {
81
+ return c(e.classes, (e) => e.name, "Class", t, n);
82
+ }
83
+ //#endregion
84
+ //#region src/shared/sharedCheckHaveNameMatchingFileName.ts
85
+ function u(t, n, r, i) {
86
+ return a(t, i, (t) => {
87
+ let i = n(t);
88
+ if (!t._filePath) return {
89
+ passes: !0,
90
+ failMessage: "",
91
+ failNotMessage: ""
92
+ };
93
+ let a = e.basename(t._filePath, e.extname(t._filePath)), o = i === a, s = `${r} ${i || "Anonymous"}`;
94
+ return {
95
+ passes: o,
96
+ failMessage: `${s} does not have a name matching its filename ${a}, but it should.`,
97
+ failNotMessage: `${s} has a name matching its filename ${a}, but it shouldn't.`
98
+ };
99
+ });
100
+ }
101
+ //#endregion
102
+ //#region src/classes/classCheckHaveNameMatchingFileName.ts
103
+ function d(e, t) {
104
+ return u(e.classes, (e) => e.name, "Class", t);
105
+ }
106
+ //#endregion
107
+ //#region src/classes/classCheckImplementInterface.ts
108
+ function f(e, t, n) {
109
+ let r = [];
110
+ for (let i of e.classes) {
111
+ let e = i.name || "Anonymous", a = !1;
112
+ i.implements.includes(t) && (a = !0), n && a ? r.push(`Class ${e} implements ${t}, but it shouldn't.`) : !n && !a && r.push(`Class ${e} does not implement ${t}, but it should.`);
113
+ }
114
+ return {
115
+ pass: r.length === 0,
116
+ message: () => r.join("\n")
117
+ };
118
+ }
119
+ //#endregion
120
+ //#region src/shared/sharedCheckMatchNamePattern.ts
121
+ function p(e, t, n, r, i) {
122
+ let o = typeof r == "string" ? new RegExp(r) : r;
123
+ return a(e, i, (e) => {
124
+ let i = t(e), a = i ? o.test(i) : !1, s = `${n} ${i || "Anonymous"}`;
125
+ return {
126
+ passes: a,
127
+ failMessage: `${s} does not match pattern ${r}, but it should.`,
128
+ failNotMessage: `${s} matches pattern ${r}, but it shouldn't.`
129
+ };
130
+ });
131
+ }
132
+ //#endregion
133
+ //#region src/classes/classCheckMatchNamePattern.ts
134
+ function m(e, t, n) {
135
+ return p(e.classes, (e) => e.name, "Class", t, n);
136
+ }
137
+ //#endregion
138
+ //#region src/classes/classCheckResideInFolder.ts
139
+ function h(e, t, n) {
140
+ let r = [];
141
+ for (let i of e.classes) {
142
+ let e = i.name || "Anonymous Class", a = i._filePath, o = a.includes(`/${t}/`) || a.includes(`\\${t}\\`);
143
+ n && o ? r.push(`Class ${e} resides in ${t}, but it shouldn't.`) : !n && !o && r.push(`Class ${e} does not reside in ${t}, but it should.`);
144
+ }
145
+ return {
146
+ pass: r.length === 0,
147
+ message: () => r.join("\n")
148
+ };
149
+ }
150
+ //#endregion
151
+ //#region src/classes/locateClasses.ts
152
+ function g(e, t, n) {
153
+ let r = e;
154
+ if (n?.inFolder && (r = r.filter((e) => e._filePath.includes(`/${n.inFolder}/`) || e._filePath.includes(`\\${n.inFolder}\\`))), n?.matchNamePattern) {
155
+ let e = typeof n.matchNamePattern == "string" ? new RegExp(n.matchNamePattern) : n.matchNamePattern;
156
+ r = r.filter((t) => t.name && e.test(t.name));
157
+ }
158
+ if (n?.withDecorator) {
159
+ let e = n.withDecorator;
160
+ r = r.filter((t) => t.decorators.includes(e));
161
+ }
162
+ if (n?.extending && (r = r.filter((e) => e.extends === n.extending)), n?.implementing) {
163
+ let e = n.implementing;
164
+ r = r.filter((t) => t.implements.includes(e));
165
+ }
166
+ return n?.havingModifier && (r = r.filter((e) => {
167
+ switch (n.havingModifier) {
168
+ case "export": return e.is_exported;
169
+ case "default": return e.is_default;
170
+ case "abstract": return e.is_abstract;
171
+ default: throw Error(`Modifier ${n.havingModifier} is not fully supported.`);
172
+ }
173
+ })), {
174
+ type: "ClassLocator",
175
+ classes: r,
176
+ projectData: t
177
+ };
178
+ }
179
+ //#endregion
180
+ //#region src/files/checkDependOnExternalModule.ts
181
+ function _(e, t, n) {
182
+ let r = [], i = typeof t == "string" ? new RegExp(t) : t;
183
+ for (let a of e.files) {
184
+ let e = (a.external_dependencies || []).some((e) => i.test(e));
185
+ n && e ? r.push(`${a.path} incorrectly depends on external module '${t}'`) : !n && !e && r.push(`${a.path} does not depend on external module '${t}'`);
186
+ }
187
+ return {
188
+ pass: r.length === 0,
189
+ message: () => r.join("\n")
190
+ };
191
+ }
192
+ //#endregion
193
+ //#region src/files/getFileDependencies.ts
194
+ function v(e, t) {
195
+ return e.dependencies || [];
196
+ }
197
+ //#endregion
198
+ //#region src/files/checkDependOnFilesInFolder.ts
199
+ function y(e, t, n) {
200
+ let r = [];
201
+ for (let i of e.files) {
202
+ let a = v(i, e.projectData).some((e) => e.includes(`/${t}/`) || e.includes(`\\${t}\\`));
203
+ n && a ? r.push(`File ${i.path} depends on files in ${t}, but it shouldn't.`) : !n && !a && r.push(`File ${i.path} does not depend on files in ${t}, but it should.`);
204
+ }
205
+ return {
206
+ pass: r.length === 0,
207
+ message: () => r.join("\n")
208
+ };
209
+ }
210
+ //#endregion
211
+ //#region src/files/fileCheckBeFreeOfCycles.ts
212
+ function b(e, t) {
213
+ let n = e.files.map((e) => e.path), r = e.archestProject;
214
+ if (!r) return {
215
+ pass: !0,
216
+ message: () => "Mock pass: archestProject not in registry"
217
+ };
218
+ let i = r.checkFileCycles(n, !!t);
219
+ return {
220
+ pass: i.pass,
221
+ message: () => i.message
222
+ };
223
+ }
224
+ //#endregion
225
+ //#region src/files/fileCheckHaveMaxCyclomaticComplexity.ts
226
+ function x(e, t, n) {
227
+ return o(e.files, (e) => e.path, (e) => {
228
+ let t = 0;
229
+ for (let n of e.functions) t += n.cyclomatic_complexity || 0;
230
+ for (let n of e.classes) t += n.cyclomatic_complexity || 0;
231
+ return t;
232
+ }, "File", t, n);
233
+ }
234
+ //#endregion
235
+ //#region src/files/fileCheckHaveMaxExportedFunctions.ts
236
+ function S(e, t, n) {
237
+ let r = [];
238
+ for (let i of e.files) {
239
+ let e = i.functions.filter((e) => e.is_exported).length, a = e > t;
240
+ n && a ? r.push(`File ${i.path} has ${e} exported functions, which exceeds the maximum of ${t}, but it shouldn't.`) : !n && a && r.push(`File ${i.path} has ${e} exported functions, which exceeds the maximum of ${t}.`);
241
+ }
242
+ return {
243
+ pass: n ? r.length > 0 : r.length === 0,
244
+ message: () => r.join("\n") || (n ? "Expected some files to exceed maximum exported functions, but none did." : "")
245
+ };
246
+ }
247
+ //#endregion
248
+ //#region src/shared/sharedCheckHaveMinMaintainabilityIndex.ts
249
+ function C(e, t, n, r, i, o) {
250
+ return a(e, o, (e) => {
251
+ let a = t(e), o = n(e), s = o < i, c = `${r} ${a || "Anonymous"}`;
252
+ return {
253
+ passes: !s,
254
+ failMessage: `${c} has a maintainability index of ${o.toFixed(2)}, which falls below the minimum of ${i}.`,
255
+ failNotMessage: `${c} has a maintainability index of ${o.toFixed(2)}, which falls below the minimum of ${i}, but it shouldn't.`
256
+ };
257
+ });
258
+ }
259
+ //#endregion
260
+ //#region src/files/fileCheckHaveMinMaintainabilityIndex.ts
261
+ function w(e, t, n) {
262
+ return C(e.files, (e) => e.path, (e) => e.functions.length > 0 && e.functions[0].maintainability_index || 100, "File", t, n);
263
+ }
264
+ //#endregion
265
+ //#region src/files/fileCheckMatchNamePattern.ts
266
+ function T(e, t, n) {
267
+ return p(e.files, (e) => e.path, "File", t, n);
268
+ }
269
+ //#endregion
270
+ //#region src/files/locateFiles.ts
271
+ function E(e, t, n, r) {
272
+ let i = e;
273
+ if (r?.inFolder && (i = i.filter((e) => e.path.includes(`/${r.inFolder}/`) || e.path.includes(`\\${r.inFolder}\\`))), r?.matchNamePattern) {
274
+ let e = typeof r.matchNamePattern == "string" ? new RegExp(r.matchNamePattern) : r.matchNamePattern;
275
+ i = i.filter((t) => e.test(t.path));
276
+ }
277
+ let a = {
278
+ type: "FileLocator",
279
+ files: i,
280
+ projectData: t
281
+ };
282
+ return n && Object.defineProperty(a, "archestProject", {
283
+ value: n,
284
+ enumerable: !1
285
+ }), a;
286
+ }
287
+ //#endregion
288
+ //#region src/functions/functionCheckHaveExplicitReturnType.ts
289
+ function D(e, t) {
290
+ let n = [];
291
+ for (let r of e.functions) {
292
+ let e = r.name || "Anonymous Function", i = r.has_explicit_return_type;
293
+ t && i ? n.push(`Function ${e} has an explicit return type, but it shouldn't.`) : !t && !i && n.push(`Function ${e} does not have an explicit return type, but it should.`);
294
+ }
295
+ return {
296
+ pass: n.length === 0,
297
+ message: () => n.join("\n")
298
+ };
299
+ }
300
+ //#endregion
301
+ //#region src/functions/functionCheckHaveMaxCyclomaticComplexity.ts
302
+ function O(e, t, n) {
303
+ return o(e.functions, (e) => e.name, (e) => e.cyclomatic_complexity || 0, "Function", t, n);
304
+ }
305
+ //#endregion
306
+ //#region src/functions/functionCheckHaveMinMaintainabilityIndex.ts
307
+ function k(e, t, n) {
308
+ return C(e.functions, (e) => e.name, (e) => e.maintainability_index || 100, "Function", t, n);
309
+ }
310
+ //#endregion
311
+ //#region src/functions/functionCheckHaveModifier.ts
312
+ function A(e, t, n) {
313
+ return c(e.functions, (e) => e.name, "Function", t, n);
314
+ }
315
+ //#endregion
316
+ //#region src/functions/functionCheckHaveNameMatchingFileName.ts
317
+ function j(e, t) {
318
+ return u(e.functions, (e) => e.name, "Function", t);
319
+ }
320
+ //#endregion
321
+ //#region src/functions/functionCheckMatchNamePattern.ts
322
+ function M(e, t, n) {
323
+ return p(e.functions, (e) => e.name, "Function", t, n);
324
+ }
325
+ //#endregion
326
+ //#region src/functions/locateFunctions.ts
327
+ function N(e, t, n) {
328
+ let r = e;
329
+ if (n?.inFolder && (r = r.filter((e) => e._filePath.includes(`/${n.inFolder}/`) || e._filePath.includes(`\\${n.inFolder}\\`))), n?.matchNamePattern) {
330
+ let e = typeof n.matchNamePattern == "string" ? new RegExp(n.matchNamePattern) : n.matchNamePattern;
331
+ r = r.filter((t) => t.name && e.test(t.name));
332
+ }
333
+ return n?.isTopLevel && (r = r.filter((e) => e.is_top_level)), {
334
+ type: "FunctionLocator",
335
+ functions: r,
336
+ projectData: t
337
+ };
338
+ }
339
+ //#endregion
340
+ //#region src/layers/checkLayeredArchitecture.ts
341
+ function P(e) {
342
+ let t = [];
343
+ for (let n of e.assertions) t.push(...n(e.files));
344
+ return {
345
+ pass: t.length === 0,
346
+ message: () => t.join("\n")
347
+ };
348
+ }
349
+ //#endregion
350
+ //#region src/layers/createLayeredArchitecture.ts
351
+ function F(e, t) {
352
+ return {
353
+ type: "LayeredArchitecture",
354
+ files: e,
355
+ layers: /* @__PURE__ */ new Map(),
356
+ assertions: [],
357
+ projectData: t
358
+ };
359
+ }
360
+ //#endregion
361
+ //#region src/layers/layer.ts
362
+ function I(e, t, n) {
363
+ return e.layers.set(t, n), e;
364
+ }
365
+ //#endregion
366
+ //#region src/layers/getLayerDependencies.ts
367
+ function L(e, t) {
368
+ return e.dependencies || [];
369
+ }
370
+ //#endregion
371
+ //#region src/layers/layerShouldNotBeAccessedByAnyLayer.ts
372
+ function R(e, t) {
373
+ if (!e.layers.has(t)) throw Error(`Layer ${t} is not defined`);
374
+ return e.assertions.push((n) => {
375
+ let r = [], i = e.layers.get(t);
376
+ for (let a of n) {
377
+ let n = a.path;
378
+ !n.includes(`/${i}/`) && !n.includes(`\\${i}\\`) && L(a, e.projectData).some((e) => e.includes(`/${i}/`) || e.includes(`\\${i}\\`)) && r.push(`File ${n} accesses layer ${t} but it shouldn't.`);
379
+ }
380
+ return r;
381
+ }), e;
382
+ }
383
+ //#endregion
384
+ //#region src/layers/layerShouldOnlyBeAccessedBy.ts
385
+ function z(e, t, n) {
386
+ if (!e.layers.has(t)) throw Error(`Layer ${t} is not defined`);
387
+ return e.assertions.push((r) => {
388
+ let i = [], a = e.layers.get(t), o = n.map((t) => e.layers.get(t));
389
+ for (let s of r) {
390
+ let r = s.path, c = o.some((e) => r.includes(`/${e}/`) || r.includes(`\\${e}\\`));
391
+ !r.includes(`/${a}/`) && !r.includes(`\\${a}\\`) && !c && L(s, e.projectData).some((e) => e.includes(`/${a}/`) || e.includes(`\\${a}\\`)) && i.push(`File ${r} accesses layer ${t} but only ${n.join(", ")} are allowed.`);
392
+ }
393
+ return i;
394
+ }), e;
395
+ }
396
+ //#endregion
397
+ //#region src/properties/locateProperties.ts
398
+ function B(e, t, n) {
399
+ let r = e;
400
+ if (n?.inFolder && (r = r.filter((e) => e._filePath.includes(`/${n.inFolder}/`) || e._filePath.includes(`\\${n.inFolder}\\`))), n?.matchNamePattern) {
401
+ let e = typeof n.matchNamePattern == "string" ? new RegExp(n.matchNamePattern) : n.matchNamePattern;
402
+ r = r.filter((t) => e.test(t.name));
403
+ }
404
+ return {
405
+ type: "PropertyLocator",
406
+ properties: r,
407
+ projectData: t
408
+ };
409
+ }
410
+ //#endregion
411
+ //#region src/slices/locateSlices.ts
412
+ function V(e, t, n) {
413
+ let r = n.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "([^/\\\\]+)"), i = new RegExp(r), a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map();
414
+ for (let t of e) {
415
+ let e = t.path.match(i);
416
+ if (e?.[1]) {
417
+ let n = e[1];
418
+ a.add(n), o.has(n) || o.set(n, []), o.get(n)?.push(t);
419
+ }
420
+ }
421
+ return {
422
+ type: "SliceLocator",
423
+ slicePattern: i,
424
+ sliceIds: a,
425
+ sliceFiles: o,
426
+ projectData: t
427
+ };
428
+ }
429
+ //#endregion
430
+ //#region src/project/parseProject.ts
431
+ function H(e = {}) {
432
+ let i = e.tsConfigFilePath || r.findConfigFile(process.cwd(), r.sys.fileExists, "tsconfig.json");
433
+ if (!i) throw Error("Could not find tsconfig.json");
434
+ let a = t(i), o = r.readConfigFile(i, r.sys.readFile);
435
+ e.include && (o.config.include = e.include), e.exclude && (o.config.exclude = e.exclude);
436
+ let s = r.parseJsonConfigFileContent(o.config, r.sys, a, void 0, i, void 0, [{
437
+ extension: ".vue",
438
+ isMixedContent: !0,
439
+ scriptKind: r.ScriptKind.TS
440
+ }, {
441
+ extension: ".svelte",
442
+ isMixedContent: !0,
443
+ scriptKind: r.ScriptKind.TS
444
+ }]), c = n.parse(s.fileNames), l = JSON.parse(c.getProjectData());
445
+ return {
446
+ projectData: l,
447
+ getFiles: (e) => E(l.files, l, c, e),
448
+ getClasses: (e) => g(l.files.flatMap((e) => e.classes.map((t) => ({
449
+ ...t,
450
+ _filePath: e.path
451
+ }))), l, e),
452
+ layeredArchitecture: () => {
453
+ let e = F(l.files, l), t = {
454
+ layer: (n, r) => (e = I(e, n, r), t),
455
+ whereLayer: (n) => ({
456
+ shouldNotBeAccessedByAnyLayer: () => (e = R(e, n), t),
457
+ shouldOnlyBeAccessedBy: (...r) => (e = z(e, n, r), t)
458
+ }),
459
+ check: () => P(e),
460
+ get data() {
461
+ return e;
462
+ }
463
+ };
464
+ return t;
465
+ },
466
+ getFunctions: (e) => N(l.files.flatMap((e) => e.functions.map((t) => ({
467
+ ...t,
468
+ _filePath: e.path
469
+ }))), l, e),
470
+ getProperties: (e) => B(l.files.flatMap((e) => e.properties.map((t) => ({
471
+ ...t,
472
+ _filePath: e.path
473
+ }))), l, e),
474
+ getSlices: (e) => V(l.files, l, e)
475
+ };
476
+ }
477
+ //#endregion
478
+ //#region src/properties/propertyCheckBeReadonly.ts
479
+ function U(e, t) {
480
+ let n = [];
481
+ for (let r of e.properties) {
482
+ let e = r.name || "Anonymous Property", i = r.is_readonly;
483
+ t && i ? n.push(`Property ${e} is readonly, but it shouldn't be.`) : !t && !i && n.push(`Property ${e} is not readonly, but it should be.`);
484
+ }
485
+ return {
486
+ pass: n.length === 0,
487
+ message: () => n.join("\n")
488
+ };
489
+ }
490
+ //#endregion
491
+ //#region src/slices/sliceCheckBeFreeOfCycles.ts
492
+ function W(e, t) {
493
+ let n = /* @__PURE__ */ new Map();
494
+ for (let t of e.sliceIds) n.set(t, /* @__PURE__ */ new Set());
495
+ for (let [t, r] of e.sliceFiles.entries()) for (let i of r) if (i.dependencies) for (let r of i.dependencies) {
496
+ let i = r.match(e.slicePattern);
497
+ if (i?.[1]) {
498
+ let r = i[1];
499
+ r !== t && e.sliceIds.has(r) && n.get(t)?.add(r);
500
+ }
501
+ }
502
+ let r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = [], o = (e, t) => {
503
+ r.add(e), i.add(e);
504
+ for (let s of n.get(e) || []) if (!r.has(s)) {
505
+ if (o(s, [...t, s])) return !0;
506
+ } else if (i.has(s)) return a.push(`Cycle detected between slices: ${t.join(" -> ")} -> ${s}`), !0;
507
+ return i.delete(e), !1;
508
+ };
509
+ for (let t of e.sliceIds) r.has(t) || o(t, [t]);
510
+ return t ? {
511
+ pass: a.length > 0,
512
+ message: () => a.length > 0 ? "" : "Expected cycles between slices but found none."
513
+ } : {
514
+ pass: a.length === 0,
515
+ message: () => a.join("\n")
516
+ };
517
+ }
518
+ //#endregion
519
+ //#region src/slices/sliceCheckHaveMaxDistanceFromMainSequence.ts
520
+ function G(e, t, n) {
521
+ let r = [], i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
522
+ for (let t of e.sliceIds) i.set(t, /* @__PURE__ */ new Set()), a.set(t, /* @__PURE__ */ new Set());
523
+ for (let [t, n] of e.sliceFiles.entries()) for (let r of n) if (r.dependencies) for (let n of r.dependencies) {
524
+ let r = n.match(e.slicePattern);
525
+ if (r?.[1]) {
526
+ let n = r[1];
527
+ n !== t && e.sliceIds.has(n) && (i.get(t)?.add(n), a.get(n)?.add(t));
528
+ }
529
+ }
530
+ for (let o of e.sliceIds) {
531
+ let s = i.get(o)?.size || 0, c = a.get(o)?.size || 0, l = e.sliceFiles.get(o), u = 0, d = 0;
532
+ for (let e of l) for (let t of e.classes) d++, t.is_abstract && u++;
533
+ let f = s + c === 0 ? 0 : s / (c + s), p = d === 0 ? 0 : u / d, m = Math.abs(p + f - 1), h = m > t;
534
+ n && h ? r.push(`Slice ${o} has a Distance from the Main Sequence of ${m.toFixed(2)}, which exceeds the maximum of ${t}, but it shouldn't.`) : !n && h && r.push(`Slice ${o} has a Distance from the Main Sequence of ${m.toFixed(2)}, which exceeds the maximum of ${t}.`);
535
+ }
536
+ return {
537
+ pass: n ? r.length > 0 : r.length === 0,
538
+ message: () => r.join("\n") || (n ? "Expected some slices to exceed maximum distance from main sequence, but none did." : "")
539
+ };
540
+ }
541
+ //#endregion
542
+ //#region src/testUtils.ts
543
+ function K(e, t = "test.ts") {
544
+ return r.createSourceFile(t, e, r.ScriptTarget.Latest, !0);
545
+ }
546
+ function q(e) {
547
+ return { files: e.map((e) => ({
548
+ path: e.fileName,
549
+ classes: Y(e),
550
+ functions: X(e),
551
+ properties: Z(e)
552
+ })) };
553
+ }
554
+ function J(e) {
555
+ return n.parseMock(JSON.stringify(e));
556
+ }
557
+ function Y(e) {
558
+ let t = [];
559
+ return r.forEachChild(e, (n) => {
560
+ if (r.isClassDeclaration(n)) {
561
+ let i = null, a = [];
562
+ if (n.heritageClauses) for (let e of n.heritageClauses) {
563
+ if (e.token === r.SyntaxKind.ExtendsKeyword) for (let t of e.types) r.isIdentifier(t.expression) && (i = t.expression.text);
564
+ if (e.token === r.SyntaxKind.ImplementsKeyword) for (let t of e.types) r.isIdentifier(t.expression) && a.push(t.expression.text);
565
+ }
566
+ let o = [];
567
+ if (r.canHaveDecorators(n)) {
568
+ let e = r.getDecorators(n);
569
+ if (e) for (let t of e) r.isIdentifier(t.expression) ? o.push(t.expression.text) : r.isCallExpression(t.expression) && r.isIdentifier(t.expression.expression) && o.push(t.expression.expression.text);
570
+ }
571
+ t.push({
572
+ name: n.name?.text || null,
573
+ is_exported: r.canHaveModifiers(n) && r.getModifiers(n)?.some((e) => e.kind === r.SyntaxKind.ExportKeyword) || !1,
574
+ is_default: r.canHaveModifiers(n) && r.getModifiers(n)?.some((e) => e.kind === r.SyntaxKind.DefaultKeyword) || !1,
575
+ is_abstract: r.canHaveModifiers(n) && r.getModifiers(n)?.some((e) => e.kind === r.SyntaxKind.AbstractKeyword) || !1,
576
+ extends: i,
577
+ implements: a,
578
+ decorators: o,
579
+ _filePath: e.fileName
580
+ });
581
+ }
582
+ }), t;
583
+ }
584
+ function X(e) {
585
+ let t = [];
586
+ return r.forEachChild(e, (n) => {
587
+ if (r.isFunctionDeclaration(n) || r.isMethodDeclaration(n) || r.isArrowFunction(n)) {
588
+ let i = null;
589
+ (r.isFunctionDeclaration(n) || r.isMethodDeclaration(n)) && (i = n.name?.getText() || null), t.push({
590
+ name: i,
591
+ is_exported: r.canHaveModifiers(n) && r.getModifiers(n)?.some((e) => e.kind === r.SyntaxKind.ExportKeyword) || !1,
592
+ is_async: r.canHaveModifiers(n) && r.getModifiers(n)?.some((e) => e.kind === r.SyntaxKind.AsyncKeyword) || !1,
593
+ is_top_level: !0,
594
+ has_explicit_return_type: !!n.type,
595
+ _filePath: e.fileName
596
+ });
597
+ }
598
+ }), t;
599
+ }
600
+ function Z(e) {
601
+ let t = [];
602
+ return r.forEachChild(e, (n) => {
603
+ r.isClassDeclaration(n) && n.members.forEach((n) => {
604
+ r.isPropertyDeclaration(n) && t.push({
605
+ name: n.name.getText(),
606
+ is_readonly: r.canHaveModifiers(n) && r.getModifiers(n)?.some((e) => e.kind === r.SyntaxKind.ReadonlyKeyword) || !1,
607
+ _filePath: e.fileName
608
+ });
609
+ });
610
+ }), t;
611
+ }
612
+ //#endregion
613
+ export { _ as checkDependOnExternalModule, y as checkDependOnFilesInFolder, P as checkLayeredArchitecture, i as classCheckExtendClass, s as classCheckHaveMaxCyclomaticComplexity, l as classCheckHaveModifier, d as classCheckHaveNameMatchingFileName, f as classCheckImplementInterface, m as classCheckMatchNamePattern, h as classCheckResideInFolder, F as createLayeredArchitecture, J as createMockArchestProject, q as createMockProgram, K as createSourceFile, b as fileCheckBeFreeOfCycles, x as fileCheckHaveMaxCyclomaticComplexity, S as fileCheckHaveMaxExportedFunctions, w as fileCheckHaveMinMaintainabilityIndex, T as fileCheckMatchNamePattern, D as functionCheckHaveExplicitReturnType, O as functionCheckHaveMaxCyclomaticComplexity, k as functionCheckHaveMinMaintainabilityIndex, A as functionCheckHaveModifier, j as functionCheckHaveNameMatchingFileName, M as functionCheckMatchNamePattern, Y as getClasses, X as getFunctions, Z as getProperties, I as layer, R as layerShouldNotBeAccessedByAnyLayer, z as layerShouldOnlyBeAccessedBy, g as locateClasses, E as locateFiles, N as locateFunctions, B as locateProperties, V as locateSlices, H as parseProject, U as propertyCheckBeReadonly, W as sliceCheckBeFreeOfCycles, G as sliceCheckHaveMaxDistanceFromMainSequence };
614
+
615
+ //# sourceMappingURL=index.mjs.map