@archest/vitest 1.0.1 → 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 (191) hide show
  1. package/dist/index.d.ts +3 -0
  2. package/dist/index.js +1 -13
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +44 -764
  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/locateClasses.d.ts +5 -0
  9. package/node_modules/@archest/core/dist/classes/types.d.ts +25 -0
  10. package/node_modules/@archest/core/dist/dto.d.ts +78 -0
  11. package/node_modules/@archest/core/dist/files/checkDependOnExternalModule.d.ts +3 -0
  12. package/node_modules/@archest/core/dist/files/getFileDependencies.d.ts +2 -0
  13. package/node_modules/@archest/core/dist/files/locateFiles.d.ts +4 -0
  14. package/node_modules/@archest/core/dist/files/types.d.ts +17 -0
  15. package/node_modules/@archest/core/dist/functions/locateFunctions.d.ts +5 -0
  16. package/node_modules/@archest/core/dist/functions/types.d.ts +19 -0
  17. package/node_modules/@archest/core/dist/index.d.ts +43 -0
  18. package/node_modules/@archest/core/dist/index.js +14 -0
  19. package/node_modules/@archest/core/dist/index.js.map +1 -0
  20. package/node_modules/@archest/core/dist/index.mjs +615 -0
  21. package/node_modules/@archest/core/dist/index.mjs.map +1 -0
  22. package/node_modules/@archest/core/dist/layers/createLayeredArchitecture.d.ts +3 -0
  23. package/node_modules/@archest/core/dist/layers/getLayerDependencies.d.ts +2 -0
  24. package/node_modules/@archest/core/dist/layers/types.d.ts +8 -0
  25. package/node_modules/@archest/core/dist/project/parseProject.d.ts +55 -0
  26. package/node_modules/@archest/core/dist/properties/locateProperties.d.ts +5 -0
  27. package/node_modules/@archest/core/dist/properties/types.d.ts +17 -0
  28. package/node_modules/@archest/core/dist/shared/sharedCheckHaveMaxCyclomaticComplexity.d.ts +1 -0
  29. package/node_modules/@archest/core/dist/shared/sharedCheckHaveMinMaintainabilityIndex.d.ts +1 -0
  30. package/node_modules/@archest/core/dist/shared/sharedCheckHaveModifier.d.ts +7 -0
  31. package/node_modules/@archest/core/dist/shared/sharedCheckHaveNameMatchingFileName.d.ts +3 -0
  32. package/node_modules/@archest/core/dist/shared/sharedCheckMatchNamePattern.d.ts +1 -0
  33. package/node_modules/@archest/core/dist/slices/locateSlices.d.ts +3 -0
  34. package/node_modules/@archest/core/dist/slices/types.d.ts +8 -0
  35. package/node_modules/@archest/core/package.json +49 -0
  36. package/node_modules/@archest/core-rust/core-rust.darwin-arm64.node +0 -0
  37. package/node_modules/@archest/core-rust/core-rust.linux-x64-gnu.node +0 -0
  38. package/node_modules/@archest/core-rust/core-rust.win32-x64-msvc.node +0 -0
  39. package/node_modules/@archest/core-rust/index.d.ts +16 -0
  40. package/node_modules/@archest/core-rust/index.js +316 -0
  41. package/node_modules/@archest/core-rust/package.json +34 -0
  42. package/package.json +12 -1
  43. package/dist/src/core/classes/locateClasses.d.ts +0 -3
  44. package/dist/src/core/classes/types.d.ts +0 -14
  45. package/dist/src/core/files/getFileDependencies.d.ts +0 -2
  46. package/dist/src/core/files/locateFiles.d.ts +0 -3
  47. package/dist/src/core/files/types.d.ts +0 -10
  48. package/dist/src/core/functions/locateFunctions.d.ts +0 -3
  49. package/dist/src/core/functions/types.d.ts +0 -11
  50. package/dist/src/core/layers/createLayeredArchitecture.d.ts +0 -3
  51. package/dist/src/core/layers/getLayerDependencies.d.ts +0 -2
  52. package/dist/src/core/layers/types.d.ts +0 -8
  53. package/dist/src/core/project/parseProject.d.ts +0 -22
  54. package/dist/src/core/properties/locateProperties.d.ts +0 -3
  55. package/dist/src/core/properties/types.d.ts +0 -10
  56. package/dist/src/core/shared/sharedCheckHaveMaxCyclomaticComplexity.d.ts +0 -1
  57. package/dist/src/core/shared/sharedCheckHaveMinMaintainabilityIndex.d.ts +0 -1
  58. package/dist/src/core/shared/sharedCheckHaveModifier.d.ts +0 -2
  59. package/dist/src/core/shared/sharedCheckHaveNameMatchingFileName.d.ts +0 -2
  60. package/dist/src/core/shared/sharedCheckMatchNamePattern.d.ts +0 -1
  61. package/dist/src/core/slices/locateSlices.d.ts +0 -3
  62. package/dist/src/core/slices/types.d.ts +0 -8
  63. package/dist/src/index.d.ts +0 -35
  64. package/dist/src/matchers/index.d.ts +0 -20
  65. package/src/core/classes/classCheckExtendClass.test.ts +0 -30
  66. package/src/core/classes/classCheckExtendClass.ts +0 -41
  67. package/src/core/classes/classCheckHaveMaxCyclomaticComplexity.test.ts +0 -8
  68. package/src/core/classes/classCheckHaveMaxCyclomaticComplexity.ts +0 -35
  69. package/src/core/classes/classCheckHaveModifier.test.ts +0 -30
  70. package/src/core/classes/classCheckHaveModifier.ts +0 -17
  71. package/src/core/classes/classCheckHaveNameMatchingFileName.test.ts +0 -30
  72. package/src/core/classes/classCheckHaveNameMatchingFileName.ts +0 -15
  73. package/src/core/classes/classCheckImplementInterface.test.ts +0 -30
  74. package/src/core/classes/classCheckImplementInterface.ts +0 -43
  75. package/src/core/classes/classCheckMatchNamePattern.test.ts +0 -8
  76. package/src/core/classes/classCheckMatchNamePattern.ts +0 -17
  77. package/src/core/classes/classCheckResideInFolder.test.ts +0 -8
  78. package/src/core/classes/classCheckResideInFolder.ts +0 -31
  79. package/src/core/classes/locateClasses.test.ts +0 -13
  80. package/src/core/classes/locateClasses.ts +0 -127
  81. package/src/core/classes/types.ts +0 -16
  82. package/src/core/files/checkDependOnFilesInFolder.test.ts +0 -7
  83. package/src/core/files/checkDependOnFilesInFolder.ts +0 -36
  84. package/src/core/files/fileCheckBeFreeOfCycles.test.ts +0 -7
  85. package/src/core/files/fileCheckBeFreeOfCycles.ts +0 -72
  86. package/src/core/files/fileCheckHaveMaxCyclomaticComplexity.test.ts +0 -8
  87. package/src/core/files/fileCheckHaveMaxCyclomaticComplexity.ts +0 -35
  88. package/src/core/files/fileCheckHaveMaxExportedFunctions.test.ts +0 -32
  89. package/src/core/files/fileCheckHaveMaxExportedFunctions.ts +0 -45
  90. package/src/core/files/fileCheckHaveMinMaintainabilityIndex.test.ts +0 -8
  91. package/src/core/files/fileCheckHaveMinMaintainabilityIndex.ts +0 -19
  92. package/src/core/files/fileCheckMatchNamePattern.test.ts +0 -30
  93. package/src/core/files/fileCheckMatchNamePattern.ts +0 -17
  94. package/src/core/files/getFileDependencies.ts +0 -43
  95. package/src/core/files/locateFiles.test.ts +0 -30
  96. package/src/core/files/locateFiles.ts +0 -31
  97. package/src/core/files/types.ts +0 -12
  98. package/src/core/functions/functionCheckHaveExplicitReturnType.test.ts +0 -30
  99. package/src/core/functions/functionCheckHaveExplicitReturnType.ts +0 -29
  100. package/src/core/functions/functionCheckHaveMaxCyclomaticComplexity.test.ts +0 -8
  101. package/src/core/functions/functionCheckHaveMaxCyclomaticComplexity.ts +0 -20
  102. package/src/core/functions/functionCheckHaveMinMaintainabilityIndex.test.ts +0 -8
  103. package/src/core/functions/functionCheckHaveMinMaintainabilityIndex.ts +0 -20
  104. package/src/core/functions/functionCheckHaveModifier.test.ts +0 -30
  105. package/src/core/functions/functionCheckHaveModifier.ts +0 -18
  106. package/src/core/functions/functionCheckHaveNameMatchingFileName.test.ts +0 -30
  107. package/src/core/functions/functionCheckHaveNameMatchingFileName.ts +0 -16
  108. package/src/core/functions/functionCheckMatchNamePattern.test.ts +0 -30
  109. package/src/core/functions/functionCheckMatchNamePattern.ts +0 -18
  110. package/src/core/functions/locateFunctions.test.ts +0 -16
  111. package/src/core/functions/locateFunctions.ts +0 -47
  112. package/src/core/functions/types.ts +0 -13
  113. package/src/core/layers/checkLayeredArchitecture.test.ts +0 -23
  114. package/src/core/layers/checkLayeredArchitecture.ts +0 -15
  115. package/src/core/layers/createLayeredArchitecture.test.ts +0 -13
  116. package/src/core/layers/createLayeredArchitecture.ts +0 -15
  117. package/src/core/layers/getLayerDependencies.ts +0 -45
  118. package/src/core/layers/layer.test.ts +0 -12
  119. package/src/core/layers/layer.ts +0 -10
  120. package/src/core/layers/layerShouldNotBeAccessedByAnyLayer.test.ts +0 -14
  121. package/src/core/layers/layerShouldNotBeAccessedByAnyLayer.ts +0 -40
  122. package/src/core/layers/layerShouldOnlyBeAccessedBy.test.ts +0 -15
  123. package/src/core/layers/layerShouldOnlyBeAccessedBy.ts +0 -48
  124. package/src/core/layers/types.ts +0 -9
  125. package/src/core/metrics/calculateCyclomaticComplexity.test.ts +0 -23
  126. package/src/core/metrics/calculateCyclomaticComplexity.ts +0 -36
  127. package/src/core/metrics/calculateMaintainabilityIndex.test.ts +0 -38
  128. package/src/core/metrics/calculateMaintainabilityIndex.ts +0 -47
  129. package/src/core/project/parseProject.test.ts +0 -19
  130. package/src/core/project/parseProject.ts +0 -216
  131. package/src/core/properties/locateProperties.test.ts +0 -19
  132. package/src/core/properties/locateProperties.ts +0 -41
  133. package/src/core/properties/propertyCheckBeReadonly.test.ts +0 -32
  134. package/src/core/properties/propertyCheckBeReadonly.ts +0 -27
  135. package/src/core/properties/types.ts +0 -12
  136. package/src/core/shared/sharedCheckHaveMaxCyclomaticComplexity.test.ts +0 -30
  137. package/src/core/shared/sharedCheckHaveMaxCyclomaticComplexity.ts +0 -23
  138. package/src/core/shared/sharedCheckHaveMinMaintainabilityIndex.test.ts +0 -30
  139. package/src/core/shared/sharedCheckHaveMinMaintainabilityIndex.ts +0 -23
  140. package/src/core/shared/sharedCheckHaveModifier.test.ts +0 -31
  141. package/src/core/shared/sharedCheckHaveModifier.ts +0 -51
  142. package/src/core/shared/sharedCheckHaveNameMatchingFileName.test.ts +0 -17
  143. package/src/core/shared/sharedCheckHaveNameMatchingFileName.ts +0 -36
  144. package/src/core/shared/sharedCheckMatchNamePattern.test.ts +0 -29
  145. package/src/core/shared/sharedCheckMatchNamePattern.ts +0 -22
  146. package/src/core/slices/locateSlices.test.ts +0 -22
  147. package/src/core/slices/locateSlices.ts +0 -35
  148. package/src/core/slices/sliceCheckBeFreeOfCycles.test.ts +0 -26
  149. package/src/core/slices/sliceCheckBeFreeOfCycles.ts +0 -91
  150. package/src/core/slices/sliceCheckHaveMaxDistanceFromMainSequence.test.ts +0 -27
  151. package/src/core/slices/sliceCheckHaveMaxDistanceFromMainSequence.ts +0 -110
  152. package/src/core/slices/types.ts +0 -9
  153. package/src/core/testUtils.ts +0 -61
  154. package/src/core/types.ts +0 -19
  155. package/src/core/utils/ruleBuilder.test.ts +0 -24
  156. package/src/core/utils/ruleBuilder.ts +0 -28
  157. package/src/index.ts +0 -35
  158. package/src/matchers/index.ts +0 -331
  159. package/test/architecture.test.ts +0 -152
  160. package/tsconfig.json +0 -18
  161. package/vite.config.ts +0 -18
  162. /package/{dist/src/core → node_modules/@archest/core/dist}/classes/classCheckExtendClass.d.ts +0 -0
  163. /package/{dist/src/core → node_modules/@archest/core/dist}/classes/classCheckHaveMaxCyclomaticComplexity.d.ts +0 -0
  164. /package/{dist/src/core → node_modules/@archest/core/dist}/classes/classCheckHaveModifier.d.ts +0 -0
  165. /package/{dist/src/core → node_modules/@archest/core/dist}/classes/classCheckHaveNameMatchingFileName.d.ts +0 -0
  166. /package/{dist/src/core → node_modules/@archest/core/dist}/classes/classCheckImplementInterface.d.ts +0 -0
  167. /package/{dist/src/core → node_modules/@archest/core/dist}/classes/classCheckMatchNamePattern.d.ts +0 -0
  168. /package/{dist/src/core → node_modules/@archest/core/dist}/classes/classCheckResideInFolder.d.ts +0 -0
  169. /package/{dist/src/core → node_modules/@archest/core/dist}/files/checkDependOnFilesInFolder.d.ts +0 -0
  170. /package/{dist/src/core → node_modules/@archest/core/dist}/files/fileCheckBeFreeOfCycles.d.ts +0 -0
  171. /package/{dist/src/core → node_modules/@archest/core/dist}/files/fileCheckHaveMaxCyclomaticComplexity.d.ts +0 -0
  172. /package/{dist/src/core → node_modules/@archest/core/dist}/files/fileCheckHaveMaxExportedFunctions.d.ts +0 -0
  173. /package/{dist/src/core → node_modules/@archest/core/dist}/files/fileCheckHaveMinMaintainabilityIndex.d.ts +0 -0
  174. /package/{dist/src/core → node_modules/@archest/core/dist}/files/fileCheckMatchNamePattern.d.ts +0 -0
  175. /package/{dist/src/core → node_modules/@archest/core/dist}/functions/functionCheckHaveExplicitReturnType.d.ts +0 -0
  176. /package/{dist/src/core → node_modules/@archest/core/dist}/functions/functionCheckHaveMaxCyclomaticComplexity.d.ts +0 -0
  177. /package/{dist/src/core → node_modules/@archest/core/dist}/functions/functionCheckHaveMinMaintainabilityIndex.d.ts +0 -0
  178. /package/{dist/src/core → node_modules/@archest/core/dist}/functions/functionCheckHaveModifier.d.ts +0 -0
  179. /package/{dist/src/core → node_modules/@archest/core/dist}/functions/functionCheckHaveNameMatchingFileName.d.ts +0 -0
  180. /package/{dist/src/core → node_modules/@archest/core/dist}/functions/functionCheckMatchNamePattern.d.ts +0 -0
  181. /package/{dist/src/core → node_modules/@archest/core/dist}/layers/checkLayeredArchitecture.d.ts +0 -0
  182. /package/{dist/src/core → node_modules/@archest/core/dist}/layers/layer.d.ts +0 -0
  183. /package/{dist/src/core → node_modules/@archest/core/dist}/layers/layerShouldNotBeAccessedByAnyLayer.d.ts +0 -0
  184. /package/{dist/src/core → node_modules/@archest/core/dist}/layers/layerShouldOnlyBeAccessedBy.d.ts +0 -0
  185. /package/{dist/src/core → node_modules/@archest/core/dist}/metrics/calculateCyclomaticComplexity.d.ts +0 -0
  186. /package/{dist/src/core → node_modules/@archest/core/dist}/metrics/calculateMaintainabilityIndex.d.ts +0 -0
  187. /package/{dist/src/core → node_modules/@archest/core/dist}/properties/propertyCheckBeReadonly.d.ts +0 -0
  188. /package/{dist/src/core → node_modules/@archest/core/dist}/slices/sliceCheckBeFreeOfCycles.d.ts +0 -0
  189. /package/{dist/src/core → node_modules/@archest/core/dist}/slices/sliceCheckHaveMaxDistanceFromMainSequence.d.ts +0 -0
  190. /package/{dist/src/core → node_modules/@archest/core/dist}/types.d.ts +0 -0
  191. /package/{dist/src/core → node_modules/@archest/core/dist}/utils/ruleBuilder.d.ts +0 -0
@@ -0,0 +1,316 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /* prettier-ignore */
4
+
5
+ /* auto-generated by NAPI-RS */
6
+
7
+ const { existsSync, readFileSync } = require('fs')
8
+ const { join } = require('path')
9
+
10
+ const { platform, arch } = process
11
+
12
+ let nativeBinding = null
13
+ let localFileExisted = false
14
+ let loadError = null
15
+
16
+ function isMusl() {
17
+ // For Node 10
18
+ if (!process.report || typeof process.report.getReport !== 'function') {
19
+ try {
20
+ const lddPath = require('child_process').execSync('which ldd').toString().trim()
21
+ return readFileSync(lddPath, 'utf8').includes('musl')
22
+ } catch (e) {
23
+ return true
24
+ }
25
+ } else {
26
+ const { glibcVersionRuntime } = process.report.getReport().header
27
+ return !glibcVersionRuntime
28
+ }
29
+ }
30
+
31
+ switch (platform) {
32
+ case 'android':
33
+ switch (arch) {
34
+ case 'arm64':
35
+ localFileExisted = existsSync(join(__dirname, 'core-rust.android-arm64.node'))
36
+ try {
37
+ if (localFileExisted) {
38
+ nativeBinding = require('./core-rust.android-arm64.node')
39
+ } else {
40
+ nativeBinding = require('@archest/core-rust-android-arm64')
41
+ }
42
+ } catch (e) {
43
+ loadError = e
44
+ }
45
+ break
46
+ case 'arm':
47
+ localFileExisted = existsSync(join(__dirname, 'core-rust.android-arm-eabi.node'))
48
+ try {
49
+ if (localFileExisted) {
50
+ nativeBinding = require('./core-rust.android-arm-eabi.node')
51
+ } else {
52
+ nativeBinding = require('@archest/core-rust-android-arm-eabi')
53
+ }
54
+ } catch (e) {
55
+ loadError = e
56
+ }
57
+ break
58
+ default:
59
+ throw new Error(`Unsupported architecture on Android ${arch}`)
60
+ }
61
+ break
62
+ case 'win32':
63
+ switch (arch) {
64
+ case 'x64':
65
+ localFileExisted = existsSync(
66
+ join(__dirname, 'core-rust.win32-x64-msvc.node')
67
+ )
68
+ try {
69
+ if (localFileExisted) {
70
+ nativeBinding = require('./core-rust.win32-x64-msvc.node')
71
+ } else {
72
+ nativeBinding = require('@archest/core-rust-win32-x64-msvc')
73
+ }
74
+ } catch (e) {
75
+ loadError = e
76
+ }
77
+ break
78
+ case 'ia32':
79
+ localFileExisted = existsSync(
80
+ join(__dirname, 'core-rust.win32-ia32-msvc.node')
81
+ )
82
+ try {
83
+ if (localFileExisted) {
84
+ nativeBinding = require('./core-rust.win32-ia32-msvc.node')
85
+ } else {
86
+ nativeBinding = require('@archest/core-rust-win32-ia32-msvc')
87
+ }
88
+ } catch (e) {
89
+ loadError = e
90
+ }
91
+ break
92
+ case 'arm64':
93
+ localFileExisted = existsSync(
94
+ join(__dirname, 'core-rust.win32-arm64-msvc.node')
95
+ )
96
+ try {
97
+ if (localFileExisted) {
98
+ nativeBinding = require('./core-rust.win32-arm64-msvc.node')
99
+ } else {
100
+ nativeBinding = require('@archest/core-rust-win32-arm64-msvc')
101
+ }
102
+ } catch (e) {
103
+ loadError = e
104
+ }
105
+ break
106
+ default:
107
+ throw new Error(`Unsupported architecture on Windows: ${arch}`)
108
+ }
109
+ break
110
+ case 'darwin':
111
+ localFileExisted = existsSync(join(__dirname, 'core-rust.darwin-universal.node'))
112
+ try {
113
+ if (localFileExisted) {
114
+ nativeBinding = require('./core-rust.darwin-universal.node')
115
+ } else {
116
+ nativeBinding = require('@archest/core-rust-darwin-universal')
117
+ }
118
+ break
119
+ } catch {}
120
+ switch (arch) {
121
+ case 'x64':
122
+ localFileExisted = existsSync(join(__dirname, 'core-rust.darwin-x64.node'))
123
+ try {
124
+ if (localFileExisted) {
125
+ nativeBinding = require('./core-rust.darwin-x64.node')
126
+ } else {
127
+ nativeBinding = require('@archest/core-rust-darwin-x64')
128
+ }
129
+ } catch (e) {
130
+ loadError = e
131
+ }
132
+ break
133
+ case 'arm64':
134
+ localFileExisted = existsSync(
135
+ join(__dirname, 'core-rust.darwin-arm64.node')
136
+ )
137
+ try {
138
+ if (localFileExisted) {
139
+ nativeBinding = require('./core-rust.darwin-arm64.node')
140
+ } else {
141
+ nativeBinding = require('@archest/core-rust-darwin-arm64')
142
+ }
143
+ } catch (e) {
144
+ loadError = e
145
+ }
146
+ break
147
+ default:
148
+ throw new Error(`Unsupported architecture on macOS: ${arch}`)
149
+ }
150
+ break
151
+ case 'freebsd':
152
+ if (arch !== 'x64') {
153
+ throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
154
+ }
155
+ localFileExisted = existsSync(join(__dirname, 'core-rust.freebsd-x64.node'))
156
+ try {
157
+ if (localFileExisted) {
158
+ nativeBinding = require('./core-rust.freebsd-x64.node')
159
+ } else {
160
+ nativeBinding = require('@archest/core-rust-freebsd-x64')
161
+ }
162
+ } catch (e) {
163
+ loadError = e
164
+ }
165
+ break
166
+ case 'linux':
167
+ switch (arch) {
168
+ case 'x64':
169
+ if (isMusl()) {
170
+ localFileExisted = existsSync(
171
+ join(__dirname, 'core-rust.linux-x64-musl.node')
172
+ )
173
+ try {
174
+ if (localFileExisted) {
175
+ nativeBinding = require('./core-rust.linux-x64-musl.node')
176
+ } else {
177
+ nativeBinding = require('@archest/core-rust-linux-x64-musl')
178
+ }
179
+ } catch (e) {
180
+ loadError = e
181
+ }
182
+ } else {
183
+ localFileExisted = existsSync(
184
+ join(__dirname, 'core-rust.linux-x64-gnu.node')
185
+ )
186
+ try {
187
+ if (localFileExisted) {
188
+ nativeBinding = require('./core-rust.linux-x64-gnu.node')
189
+ } else {
190
+ nativeBinding = require('@archest/core-rust-linux-x64-gnu')
191
+ }
192
+ } catch (e) {
193
+ loadError = e
194
+ }
195
+ }
196
+ break
197
+ case 'arm64':
198
+ if (isMusl()) {
199
+ localFileExisted = existsSync(
200
+ join(__dirname, 'core-rust.linux-arm64-musl.node')
201
+ )
202
+ try {
203
+ if (localFileExisted) {
204
+ nativeBinding = require('./core-rust.linux-arm64-musl.node')
205
+ } else {
206
+ nativeBinding = require('@archest/core-rust-linux-arm64-musl')
207
+ }
208
+ } catch (e) {
209
+ loadError = e
210
+ }
211
+ } else {
212
+ localFileExisted = existsSync(
213
+ join(__dirname, 'core-rust.linux-arm64-gnu.node')
214
+ )
215
+ try {
216
+ if (localFileExisted) {
217
+ nativeBinding = require('./core-rust.linux-arm64-gnu.node')
218
+ } else {
219
+ nativeBinding = require('@archest/core-rust-linux-arm64-gnu')
220
+ }
221
+ } catch (e) {
222
+ loadError = e
223
+ }
224
+ }
225
+ break
226
+ case 'arm':
227
+ if (isMusl()) {
228
+ localFileExisted = existsSync(
229
+ join(__dirname, 'core-rust.linux-arm-musleabihf.node')
230
+ )
231
+ try {
232
+ if (localFileExisted) {
233
+ nativeBinding = require('./core-rust.linux-arm-musleabihf.node')
234
+ } else {
235
+ nativeBinding = require('@archest/core-rust-linux-arm-musleabihf')
236
+ }
237
+ } catch (e) {
238
+ loadError = e
239
+ }
240
+ } else {
241
+ localFileExisted = existsSync(
242
+ join(__dirname, 'core-rust.linux-arm-gnueabihf.node')
243
+ )
244
+ try {
245
+ if (localFileExisted) {
246
+ nativeBinding = require('./core-rust.linux-arm-gnueabihf.node')
247
+ } else {
248
+ nativeBinding = require('@archest/core-rust-linux-arm-gnueabihf')
249
+ }
250
+ } catch (e) {
251
+ loadError = e
252
+ }
253
+ }
254
+ break
255
+ case 'riscv64':
256
+ if (isMusl()) {
257
+ localFileExisted = existsSync(
258
+ join(__dirname, 'core-rust.linux-riscv64-musl.node')
259
+ )
260
+ try {
261
+ if (localFileExisted) {
262
+ nativeBinding = require('./core-rust.linux-riscv64-musl.node')
263
+ } else {
264
+ nativeBinding = require('@archest/core-rust-linux-riscv64-musl')
265
+ }
266
+ } catch (e) {
267
+ loadError = e
268
+ }
269
+ } else {
270
+ localFileExisted = existsSync(
271
+ join(__dirname, 'core-rust.linux-riscv64-gnu.node')
272
+ )
273
+ try {
274
+ if (localFileExisted) {
275
+ nativeBinding = require('./core-rust.linux-riscv64-gnu.node')
276
+ } else {
277
+ nativeBinding = require('@archest/core-rust-linux-riscv64-gnu')
278
+ }
279
+ } catch (e) {
280
+ loadError = e
281
+ }
282
+ }
283
+ break
284
+ case 's390x':
285
+ localFileExisted = existsSync(
286
+ join(__dirname, 'core-rust.linux-s390x-gnu.node')
287
+ )
288
+ try {
289
+ if (localFileExisted) {
290
+ nativeBinding = require('./core-rust.linux-s390x-gnu.node')
291
+ } else {
292
+ nativeBinding = require('@archest/core-rust-linux-s390x-gnu')
293
+ }
294
+ } catch (e) {
295
+ loadError = e
296
+ }
297
+ break
298
+ default:
299
+ throw new Error(`Unsupported architecture on Linux: ${arch}`)
300
+ }
301
+ break
302
+ default:
303
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
304
+ }
305
+
306
+ if (!nativeBinding) {
307
+ if (loadError) {
308
+ throw loadError
309
+ }
310
+ throw new Error(`Failed to load native binding`)
311
+ }
312
+
313
+ const { ArchestProject, parseProjectRust } = nativeBinding
314
+
315
+ module.exports.ArchestProject = ArchestProject
316
+ module.exports.parseProjectRust = parseProjectRust
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@archest/core-rust",
3
+ "version": "1.0.2",
4
+ "private": true,
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "files": [
8
+ "index.js",
9
+ "index.d.ts",
10
+ "*.node"
11
+ ],
12
+ "napi": {
13
+ "name": "core-rust",
14
+ "triples": {
15
+ "defaults": false,
16
+ "additional": [
17
+ "x86_64-apple-darwin",
18
+ "aarch64-apple-darwin",
19
+ "x86_64-pc-windows-msvc",
20
+ "aarch64-pc-windows-msvc",
21
+ "x86_64-unknown-linux-gnu",
22
+ "aarch64-unknown-linux-gnu"
23
+ ]
24
+ }
25
+ },
26
+ "scripts": {
27
+ "build": "napi build --platform --release",
28
+ "build:debug": "napi build --platform",
29
+ "artifacts": "napi artifacts"
30
+ },
31
+ "devDependencies": {
32
+ "@napi-rs/cli": "^2.18.4"
33
+ }
34
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archest/vitest",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/hinterdupfinger/archest.git"
@@ -19,6 +19,9 @@
19
19
  "types": "./dist/index.d.ts"
20
20
  }
21
21
  },
22
+ "files": [
23
+ "dist"
24
+ ],
22
25
  "keywords": [
23
26
  "vitest",
24
27
  "architecture",
@@ -36,6 +39,14 @@
36
39
  "peerDependencies": {
37
40
  "typescript": "^5.x || ^6.x"
38
41
  },
42
+ "dependencies": {
43
+ "@archest/core": "1.0.2",
44
+ "@archest/core-rust": "1.0.2"
45
+ },
46
+ "bundledDependencies": [
47
+ "@archest/core",
48
+ "@archest/core-rust"
49
+ ],
39
50
  "scripts": {
40
51
  "build": "vite build",
41
52
  "test": "vitest run",
@@ -1,3 +0,0 @@
1
- import { ClassLocatorData, ClassQueryOptions } from './types';
2
- import * as ts from 'typescript';
3
- export declare function locateClasses(classes: ts.ClassDeclaration[], program: ts.Program, options?: ClassQueryOptions): ClassLocatorData;
@@ -1,14 +0,0 @@
1
- import type * as ts from 'typescript';
2
- export interface ClassLocatorData {
3
- type: 'ClassLocator';
4
- classes: ts.ClassDeclaration[];
5
- program: ts.Program;
6
- }
7
- export interface ClassQueryOptions {
8
- inFolder?: string;
9
- matchNamePattern?: string | RegExp;
10
- withDecorator?: string;
11
- extending?: string;
12
- implementing?: string;
13
- havingModifier?: string;
14
- }
@@ -1,2 +0,0 @@
1
- import * as ts from 'typescript';
2
- export declare function getFileDependencies(sourceFile: ts.SourceFile, program: ts.Program): string[];
@@ -1,3 +0,0 @@
1
- import { FileLocatorData, FileQueryOptions } from './types';
2
- import type * as ts from 'typescript';
3
- export declare function locateFiles(sourceFiles: ts.SourceFile[], program: ts.Program, options?: FileQueryOptions): FileLocatorData;
@@ -1,10 +0,0 @@
1
- import type * as ts from 'typescript';
2
- export interface FileLocatorData {
3
- type: 'FileLocator';
4
- files: ts.SourceFile[];
5
- program: ts.Program;
6
- }
7
- export interface FileQueryOptions {
8
- inFolder?: string;
9
- matchNamePattern?: string | RegExp;
10
- }
@@ -1,3 +0,0 @@
1
- import { FunctionLocatorData, FunctionQueryOptions } from './types';
2
- import * as ts from 'typescript';
3
- export declare function locateFunctions(functions: ts.FunctionLikeDeclaration[], program: ts.Program, options?: FunctionQueryOptions): FunctionLocatorData;
@@ -1,11 +0,0 @@
1
- import type * as ts from 'typescript';
2
- export interface FunctionLocatorData {
3
- type: 'FunctionLocator';
4
- functions: ts.FunctionLikeDeclaration[];
5
- program: ts.Program;
6
- }
7
- export interface FunctionQueryOptions {
8
- inFolder?: string;
9
- matchNamePattern?: string | RegExp;
10
- isTopLevel?: boolean;
11
- }
@@ -1,3 +0,0 @@
1
- import { LayeredArchitectureData } from './types';
2
- import type * as ts from 'typescript';
3
- export declare function createLayeredArchitecture(files: ts.SourceFile[], program: ts.Program): LayeredArchitectureData;
@@ -1,2 +0,0 @@
1
- import * as ts from 'typescript';
2
- export declare function getLayerDependencies(sourceFile: ts.SourceFile, program: ts.Program): string[];
@@ -1,8 +0,0 @@
1
- import type * as ts from 'typescript';
2
- export interface LayeredArchitectureData {
3
- type: 'LayeredArchitecture';
4
- files: ts.SourceFile[];
5
- layers: Map<string, string>;
6
- assertions: Array<(files: ts.SourceFile[]) => string[]>;
7
- program: ts.Program;
8
- }
@@ -1,22 +0,0 @@
1
- import { ClassQueryOptions } from '../classes/types';
2
- import { FileQueryOptions } from '../files/types';
3
- import { FunctionQueryOptions } from '../functions/types';
4
- import { PropertyQueryOptions } from '../properties/types';
5
- export declare function parseProject(options?: {
6
- tsConfigFilePath?: string;
7
- }): {
8
- getFiles: (queryOptions?: FileQueryOptions) => import('../files/types').FileLocatorData;
9
- getClasses: (queryOptions?: ClassQueryOptions) => import('../classes/types').ClassLocatorData;
10
- layeredArchitecture: () => {
11
- layer: (name: string, folderPattern: string) => /*elided*/ any;
12
- whereLayer: (name: string) => {
13
- shouldNotBeAccessedByAnyLayer: () => /*elided*/ any;
14
- shouldOnlyBeAccessedBy: (...allowedLayers: string[]) => /*elided*/ any;
15
- };
16
- check: () => import('../types').RuleResult;
17
- readonly data: import('../layers/types').LayeredArchitectureData;
18
- };
19
- getFunctions: (queryOptions?: FunctionQueryOptions) => import('../functions/types').FunctionLocatorData;
20
- getProperties: (queryOptions?: PropertyQueryOptions) => import('../properties/types').PropertyLocatorData;
21
- getSlices: (pattern: string) => import('../slices/types').SliceLocatorData;
22
- };
@@ -1,3 +0,0 @@
1
- import { PropertyLocatorData, PropertyQueryOptions } from './types';
2
- import * as ts from 'typescript';
3
- export declare function locateProperties(properties: ts.PropertyDeclaration[], program: ts.Program, options?: PropertyQueryOptions): PropertyLocatorData;
@@ -1,10 +0,0 @@
1
- import type * as ts from 'typescript';
2
- export interface PropertyLocatorData {
3
- type: 'PropertyLocator';
4
- properties: ts.PropertyDeclaration[];
5
- program: ts.Program;
6
- }
7
- export interface PropertyQueryOptions {
8
- inFolder?: string;
9
- matchNamePattern?: string | RegExp;
10
- }
@@ -1 +0,0 @@
1
- export declare function sharedCheckHaveMaxCyclomaticComplexity<T>(items: T[], getName: (item: T) => string | undefined, getComplexity: (item: T) => number, label: string, max: number, isNot: boolean): import('../types').RuleResult;
@@ -1 +0,0 @@
1
- export declare function sharedCheckHaveMinMaintainabilityIndex<T>(items: T[], getName: (item: T) => string | undefined, getMi: (item: T) => number, label: string, min: number, isNot: boolean): import('../types').RuleResult;
@@ -1,2 +0,0 @@
1
- import * as ts from 'typescript';
2
- export declare function sharedCheckHaveModifier<T extends ts.Node>(items: T[], getName: (item: T) => string | undefined, label: string, modifierStr: string, isNot: boolean): import('../types').RuleResult;
@@ -1,2 +0,0 @@
1
- import * as ts from 'typescript';
2
- export declare function sharedCheckHaveNameMatchingFileName<T extends ts.Node>(items: T[], getName: (item: T) => string | undefined, label: string, isNot: boolean): import('../types').RuleResult;
@@ -1 +0,0 @@
1
- export declare function sharedCheckMatchNamePattern<T>(items: T[], getName: (item: T) => string | undefined, label: string, pattern: string | RegExp, isNot: boolean): import('../types').RuleResult;
@@ -1,3 +0,0 @@
1
- import { SliceLocatorData } from './types';
2
- import type * as ts from 'typescript';
3
- export declare function locateSlices(sourceFiles: ts.SourceFile[], program: ts.Program, pattern: string): SliceLocatorData;
@@ -1,8 +0,0 @@
1
- import type * as ts from 'typescript';
2
- export interface SliceLocatorData {
3
- type: 'SliceLocator';
4
- slicePattern: RegExp;
5
- sliceIds: Set<string>;
6
- sliceFiles: Map<string, ts.SourceFile[]>;
7
- program: ts.Program;
8
- }
@@ -1,35 +0,0 @@
1
- export * from './core/classes/classCheckExtendClass';
2
- export * from './core/classes/classCheckHaveMaxCyclomaticComplexity';
3
- export * from './core/classes/classCheckHaveModifier';
4
- export * from './core/classes/classCheckHaveNameMatchingFileName';
5
- export * from './core/classes/classCheckImplementInterface';
6
- export * from './core/classes/classCheckMatchNamePattern';
7
- export * from './core/classes/classCheckResideInFolder';
8
- export * from './core/classes/locateClasses';
9
- export * from './core/files/checkDependOnFilesInFolder';
10
- export * from './core/files/fileCheckBeFreeOfCycles';
11
- export * from './core/files/fileCheckHaveMaxCyclomaticComplexity';
12
- export * from './core/files/fileCheckHaveMaxExportedFunctions';
13
- export * from './core/files/fileCheckHaveMinMaintainabilityIndex';
14
- export * from './core/files/fileCheckMatchNamePattern';
15
- export * from './core/files/locateFiles';
16
- export * from './core/functions/functionCheckHaveExplicitReturnType';
17
- export * from './core/functions/functionCheckHaveMaxCyclomaticComplexity';
18
- export * from './core/functions/functionCheckHaveMinMaintainabilityIndex';
19
- export * from './core/functions/functionCheckHaveModifier';
20
- export * from './core/functions/functionCheckHaveNameMatchingFileName';
21
- export * from './core/functions/functionCheckMatchNamePattern';
22
- export * from './core/functions/locateFunctions';
23
- export * from './core/layers/checkLayeredArchitecture';
24
- export * from './core/layers/createLayeredArchitecture';
25
- export * from './core/layers/layer';
26
- export * from './core/layers/layerShouldNotBeAccessedByAnyLayer';
27
- export * from './core/layers/layerShouldOnlyBeAccessedBy';
28
- export { parseProject } from './core/project/parseProject';
29
- export * from './core/properties/locateProperties';
30
- export * from './core/properties/propertyCheckBeReadonly';
31
- export * from './core/slices/locateSlices';
32
- export * from './core/slices/sliceCheckBeFreeOfCycles';
33
- export * from './core/slices/sliceCheckHaveMaxDistanceFromMainSequence';
34
- export * from './core/types';
35
- export { setupMatchers } from './matchers';
@@ -1,20 +0,0 @@
1
- export declare function setupMatchers(): void;
2
- declare module 'vitest' {
3
- interface Assertion<T = any> {
4
- toPass(): void;
5
- toResideInFolder(folder: string): void;
6
- toHaveModifier(modifier: 'export' | 'default' | 'abstract' | 'async' | 'private' | 'public'): void;
7
- toExtendClass(className: string): void;
8
- toImplementInterface(interfaceName: string): void;
9
- toHaveExplicitReturnType(): void;
10
- toBeReadonly(): void;
11
- toDependOnFilesInFolder(folder: string): void;
12
- toBeFreeOfCycles(): void;
13
- toMatchNamePattern(pattern: string | RegExp): void;
14
- toHaveMaxCyclomaticComplexity(max: number): void;
15
- toHaveMinMaintainabilityIndex(min: number): void;
16
- toHaveMaxDistanceFromMainSequence(max: number): void;
17
- toHaveNameMatchingFileName(): void;
18
- toHaveMaxExportedFunctions(max: number): void;
19
- }
20
- }
@@ -1,30 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { createSourceFile, getClasses } from '../testUtils';
3
- import { classCheckExtendClass } from './classCheckExtendClass';
4
- import type { ClassLocatorData } from './types';
5
-
6
- describe('classCheckExtendClass', () => {
7
- it('should pass if class extends correctly', () => {
8
- const sourceFile = createSourceFile(`class Test extends Base {}`);
9
- const data: ClassLocatorData = {
10
- type: 'ClassLocator',
11
- classes: getClasses(sourceFile),
12
- // biome-ignore lint/suspicious/noExplicitAny: Mocking TS types for tests
13
- program: {} as any,
14
- };
15
- const result = classCheckExtendClass(data, 'Base', false);
16
- expect(result.pass).toBe(true);
17
- });
18
-
19
- it('should fail if class does not extend correctly', () => {
20
- const sourceFile = createSourceFile(`class Test extends Other {}`);
21
- const data: ClassLocatorData = {
22
- type: 'ClassLocator',
23
- classes: getClasses(sourceFile),
24
- // biome-ignore lint/suspicious/noExplicitAny: Mocking TS types for tests
25
- program: {} as any,
26
- };
27
- const result = classCheckExtendClass(data, 'Base', false);
28
- expect(result.pass).toBe(false);
29
- });
30
- });
@@ -1,41 +0,0 @@
1
- import * as ts from 'typescript';
2
- import type { RuleResult } from '../types';
3
- import type { ClassLocatorData } from './types';
4
-
5
- export function classCheckExtendClass(
6
- locator: ClassLocatorData,
7
- className: string,
8
- isNot: boolean,
9
- ): RuleResult {
10
- const violations: string[] = [];
11
- for (const c of locator.classes) {
12
- const name = c.name?.text || 'Anonymous';
13
- let matches = false;
14
- if (c.heritageClauses) {
15
- for (const clause of c.heritageClauses) {
16
- if (clause.token === ts.SyntaxKind.ExtendsKeyword) {
17
- for (const type of clause.types) {
18
- if (
19
- ts.isIdentifier(type.expression) &&
20
- type.expression.text === className
21
- ) {
22
- matches = true;
23
- break;
24
- }
25
- }
26
- }
27
- }
28
- }
29
- if (isNot && matches) {
30
- violations.push(`Class ${name} extends ${className}, but it shouldn't.`);
31
- } else if (!isNot && !matches) {
32
- violations.push(
33
- `Class ${name} does not extend ${className}, but it should.`,
34
- );
35
- }
36
- }
37
- return {
38
- pass: violations.length === 0,
39
- message: () => violations.join('\n'),
40
- };
41
- }