@md-code/follow-architecture 0.1.1 → 0.3.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 (487) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/LICENSE +202 -0
  3. package/README.md +1420 -139
  4. package/dist/aliases.d.ts +3 -0
  5. package/dist/aliases.js +12 -0
  6. package/dist/args.d.ts +18 -0
  7. package/dist/args.js +94 -0
  8. package/dist/bin/follow-architecture.d.ts +2 -0
  9. package/dist/bin/follow-architecture.js +23 -0
  10. package/dist/closure-project.d.ts +4 -0
  11. package/dist/closure-project.js +132 -0
  12. package/dist/code-entities/classify.d.ts +11 -0
  13. package/dist/code-entities/classify.js +45 -0
  14. package/dist/code-entities/connector.d.ts +8 -0
  15. package/dist/code-entities/connector.js +119 -0
  16. package/dist/code-entities/entities.d.ts +9 -0
  17. package/dist/code-entities/entities.js +227 -0
  18. package/dist/code-entities/project.d.ts +21 -0
  19. package/dist/code-entities/project.js +259 -0
  20. package/dist/code-entities/walk.d.ts +31 -0
  21. package/dist/code-entities/walk.js +105 -0
  22. package/dist/config-options.d.ts +76 -0
  23. package/dist/config-options.js +52 -0
  24. package/dist/config-project.d.ts +4 -0
  25. package/dist/config-project.js +92 -0
  26. package/dist/config-report.d.ts +19 -0
  27. package/dist/config-report.js +161 -0
  28. package/dist/config-rule.d.ts +95 -0
  29. package/dist/config-rule.js +211 -0
  30. package/dist/config-state.d.ts +25 -0
  31. package/dist/config-state.js +269 -0
  32. package/dist/config.d.ts +107 -0
  33. package/dist/config.js +38 -0
  34. package/dist/css/index.d.ts +31 -0
  35. package/dist/css/index.js +251 -0
  36. package/dist/css/syntax/css/gate.d.ts +2 -0
  37. package/dist/css/syntax/css/gate.js +69 -0
  38. package/dist/css/syntax/css/index.d.ts +7 -0
  39. package/dist/css/syntax/css/index.js +51 -0
  40. package/dist/css/syntax/css/reference.d.ts +3 -0
  41. package/dist/css/syntax/css/reference.js +36 -0
  42. package/dist/css/syntax/language.d.ts +25 -0
  43. package/dist/css/syntax/language.js +81 -0
  44. package/dist/css/syntax/scss/index.d.ts +25 -0
  45. package/dist/css/syntax/scss/index.js +95 -0
  46. package/dist/css/syntax/scss/reference.d.ts +3 -0
  47. package/dist/css/syntax/scss/reference.js +17 -0
  48. package/dist/css/syntax/styled/document.d.ts +68 -0
  49. package/dist/css/syntax/styled/document.js +261 -0
  50. package/dist/css/syntax/styled/markup.d.ts +6 -0
  51. package/dist/css/syntax/styled/markup.js +84 -0
  52. package/dist/css/syntax/styled/tags.d.ts +2 -0
  53. package/dist/css/syntax/styled/tags.js +22 -0
  54. package/dist/css/syntax/styled/template.d.ts +23 -0
  55. package/dist/css/syntax/styled/template.js +67 -0
  56. package/dist/css/syntax/tailwind/tailwind-engine.d.ts +23 -0
  57. package/dist/css/syntax/tailwind/tailwind-engine.js +37 -0
  58. package/dist/css/syntax/tailwind/tailwind.d.ts +26 -0
  59. package/dist/css/syntax/tailwind/tailwind.js +118 -0
  60. package/dist/css/value/check.d.ts +86 -0
  61. package/dist/css/value/check.js +122 -0
  62. package/dist/css/value/expression/arithmetic.d.ts +7 -0
  63. package/dist/css/value/expression/arithmetic.js +73 -0
  64. package/dist/css/value/expression/block.d.ts +9 -0
  65. package/dist/css/value/expression/block.js +92 -0
  66. package/dist/css/value/expression/conditional.d.ts +8 -0
  67. package/dist/css/value/expression/conditional.js +53 -0
  68. package/dist/css/value/expression/index.d.ts +5 -0
  69. package/dist/css/value/expression/index.js +73 -0
  70. package/dist/css/value/expression/map.d.ts +7 -0
  71. package/dist/css/value/expression/map.js +113 -0
  72. package/dist/css/value/object/index.d.ts +5 -0
  73. package/dist/css/value/object/index.js +113 -0
  74. package/dist/css/value/object/members.d.ts +7 -0
  75. package/dist/css/value/object/members.js +103 -0
  76. package/dist/css/value/object/node.d.ts +8 -0
  77. package/dist/css/value/object/node.js +134 -0
  78. package/dist/css/value/object/path.d.ts +10 -0
  79. package/dist/css/value/object/path.js +152 -0
  80. package/dist/css/value/pieces.d.ts +61 -0
  81. package/dist/css/value/pieces.js +65 -0
  82. package/dist/css/value/resolve.d.ts +33 -0
  83. package/dist/css/value/resolve.js +104 -0
  84. package/dist/css/value/scope.d.ts +28 -0
  85. package/dist/css/value/scope.js +205 -0
  86. package/dist/css/value/substitute.d.ts +10 -0
  87. package/dist/css/value/substitute.js +145 -0
  88. package/dist/css/value/values.d.ts +23 -0
  89. package/dist/css/value/values.js +131 -0
  90. package/dist/entities/architecture.d.ts +165 -0
  91. package/dist/entities/architecture.js +2 -0
  92. package/dist/entities/ast/assignments-nodes.d.ts +10 -0
  93. package/dist/entities/ast/assignments-nodes.js +64 -0
  94. package/dist/entities/ast/assignments-raw.d.ts +6 -0
  95. package/dist/entities/ast/assignments-raw.js +139 -0
  96. package/dist/entities/ast/assignments-tagged.d.ts +5 -0
  97. package/dist/entities/ast/assignments-tagged.js +195 -0
  98. package/dist/entities/ast/assignments.d.ts +9 -0
  99. package/dist/entities/ast/assignments.js +80 -0
  100. package/dist/entities/ast/branches.d.ts +4 -0
  101. package/dist/entities/ast/branches.js +32 -0
  102. package/dist/entities/ast/calls.d.ts +6 -0
  103. package/dist/entities/ast/calls.js +150 -0
  104. package/dist/entities/ast/classes.d.ts +5 -0
  105. package/dist/entities/ast/classes.js +61 -0
  106. package/dist/entities/ast/climb.d.ts +12 -0
  107. package/dist/entities/ast/climb.js +17 -0
  108. package/dist/entities/ast/comments.d.ts +5 -0
  109. package/dist/entities/ast/comments.js +130 -0
  110. package/dist/entities/ast/declaration.d.ts +4 -0
  111. package/dist/entities/ast/declaration.js +26 -0
  112. package/dist/entities/ast/depth.d.ts +17 -0
  113. package/dist/entities/ast/depth.js +166 -0
  114. package/dist/entities/ast/enums.d.ts +6 -0
  115. package/dist/entities/ast/enums.js +17 -0
  116. package/dist/entities/ast/export-chain.d.ts +15 -0
  117. package/dist/entities/ast/export-chain.js +171 -0
  118. package/dist/entities/ast/file-exports.d.ts +7 -0
  119. package/dist/entities/ast/file-exports.js +101 -0
  120. package/dist/entities/ast/file-facts.d.ts +16 -0
  121. package/dist/entities/ast/file-facts.js +64 -0
  122. package/dist/entities/ast/file-imports.d.ts +5 -0
  123. package/dist/entities/ast/file-imports.js +100 -0
  124. package/dist/entities/ast/file.d.ts +5 -0
  125. package/dist/entities/ast/file.js +23 -0
  126. package/dist/entities/ast/functions.d.ts +8 -0
  127. package/dist/entities/ast/functions.js +111 -0
  128. package/dist/entities/ast/heritage.d.ts +4 -0
  129. package/dist/entities/ast/heritage.js +44 -0
  130. package/dist/entities/ast/index.d.ts +9 -0
  131. package/dist/entities/ast/index.js +181 -0
  132. package/dist/entities/ast/kind.d.ts +5 -0
  133. package/dist/entities/ast/kind.js +34 -0
  134. package/dist/entities/ast/loose.d.ts +37 -0
  135. package/dist/entities/ast/loose.js +2 -0
  136. package/dist/entities/ast/modifiers.d.ts +5 -0
  137. package/dist/entities/ast/modifiers.js +32 -0
  138. package/dist/entities/ast/project.d.ts +9 -0
  139. package/dist/entities/ast/project.js +106 -0
  140. package/dist/entities/ast/properties.d.ts +11 -0
  141. package/dist/entities/ast/properties.js +176 -0
  142. package/dist/entities/ast/resolve.d.ts +16 -0
  143. package/dist/entities/ast/resolve.js +317 -0
  144. package/dist/entities/ast/tree.d.ts +31 -0
  145. package/dist/entities/ast/tree.js +518 -0
  146. package/dist/entities/ast/types.d.ts +6 -0
  147. package/dist/entities/ast/types.js +46 -0
  148. package/dist/entities/ast/usage.d.ts +11 -0
  149. package/dist/entities/ast/usage.js +81 -0
  150. package/dist/entities/ast/variables.d.ts +8 -0
  151. package/dist/entities/ast/variables.js +91 -0
  152. package/dist/entities/context.d.ts +29 -0
  153. package/dist/entities/context.js +2 -0
  154. package/dist/entities/facts.d.ts +284 -0
  155. package/dist/entities/facts.js +2 -0
  156. package/dist/entities/findings.d.ts +19 -0
  157. package/dist/entities/findings.js +2 -0
  158. package/dist/entities/kinds.d.ts +40 -0
  159. package/dist/entities/kinds.js +332 -0
  160. package/dist/entities/location/homes.d.ts +28 -0
  161. package/dist/entities/location/homes.js +195 -0
  162. package/dist/entities/location/place.d.ts +10 -0
  163. package/dist/entities/location/place.js +63 -0
  164. package/dist/entities/location/where.d.ts +19 -0
  165. package/dist/entities/location/where.js +277 -0
  166. package/dist/entities/location.d.ts +16 -0
  167. package/dist/entities/location.js +140 -0
  168. package/dist/entities/operators.d.ts +14 -0
  169. package/dist/entities/operators.js +30 -0
  170. package/dist/entities/overview/data.d.ts +43 -0
  171. package/dist/entities/overview/data.js +2 -0
  172. package/dist/entities/overview/decision.d.ts +60 -0
  173. package/dist/entities/overview/decision.js +2 -0
  174. package/dist/entities/overview/file-tree.d.ts +10 -0
  175. package/dist/entities/overview/file-tree.js +2 -0
  176. package/dist/entities/overview/finding.d.ts +58 -0
  177. package/dist/entities/overview/finding.js +2 -0
  178. package/dist/entities/overview/graph.d.ts +82 -0
  179. package/dist/entities/overview/graph.js +2 -0
  180. package/dist/entities/overview/input.d.ts +15 -0
  181. package/dist/entities/overview/input.js +2 -0
  182. package/dist/entities/overview/summaries.d.ts +81 -0
  183. package/dist/entities/overview/summaries.js +2 -0
  184. package/dist/entities/place.d.ts +5 -0
  185. package/dist/entities/place.js +2 -0
  186. package/dist/entities/queries.d.ts +9 -0
  187. package/dist/entities/queries.js +375 -0
  188. package/dist/entities/repair.d.ts +16 -0
  189. package/dist/entities/repair.js +29 -0
  190. package/dist/entities/schema.d.ts +22 -0
  191. package/dist/entities/schema.js +81 -0
  192. package/dist/entities/story.d.ts +47 -0
  193. package/dist/entities/story.js +2 -0
  194. package/dist/entities/structure-facts.d.ts +11 -0
  195. package/dist/entities/structure-facts.js +2 -0
  196. package/dist/entities/token.d.ts +23 -0
  197. package/dist/entities/token.js +2 -0
  198. package/dist/entities/tree/build.d.ts +6 -0
  199. package/dist/entities/tree/build.js +313 -0
  200. package/dist/entities/tree/entries.d.ts +7 -0
  201. package/dist/entities/tree/entries.js +145 -0
  202. package/dist/entities/tree/index.d.ts +6 -0
  203. package/dist/entities/tree/index.js +21 -0
  204. package/dist/entities/tree/match.d.ts +17 -0
  205. package/dist/entities/tree/match.js +190 -0
  206. package/dist/fa-index.d.ts +16 -0
  207. package/dist/fa-index.js +165 -0
  208. package/dist/fa-open.d.ts +51 -0
  209. package/dist/fa-open.js +242 -0
  210. package/dist/fa-store.d.ts +22 -0
  211. package/dist/fa-store.js +232 -0
  212. package/dist/fa-values.d.ts +37 -0
  213. package/dist/fa-values.js +104 -0
  214. package/dist/facts-record.d.ts +45 -0
  215. package/dist/facts-record.js +297 -0
  216. package/dist/frameworks/angular/index.d.ts +7 -0
  217. package/dist/frameworks/angular/index.js +18 -0
  218. package/dist/frameworks/facet.d.ts +18 -0
  219. package/dist/frameworks/facet.js +15 -0
  220. package/dist/frameworks/index.d.ts +9 -0
  221. package/dist/frameworks/index.js +134 -0
  222. package/dist/frameworks/react/index.d.ts +7 -0
  223. package/dist/frameworks/react/index.js +237 -0
  224. package/dist/frameworks/test/index.d.ts +6 -0
  225. package/dist/frameworks/test/index.js +157 -0
  226. package/dist/frameworks/vue/index.d.ts +7 -0
  227. package/dist/frameworks/vue/index.js +18 -0
  228. package/dist/ignore.d.ts +3 -0
  229. package/dist/ignore.js +62 -0
  230. package/dist/index-file.d.ts +43 -0
  231. package/dist/index-file.js +218 -0
  232. package/dist/index-run.d.ts +39 -0
  233. package/dist/index-run.js +217 -0
  234. package/dist/index-zone.d.ts +25 -0
  235. package/dist/index-zone.js +219 -0
  236. package/dist/main.d.ts +10 -0
  237. package/dist/main.js +411 -0
  238. package/dist/nodes/child-entities.d.ts +3 -0
  239. package/dist/nodes/child-entities.js +12 -0
  240. package/dist/nodes/children.d.ts +25 -0
  241. package/dist/nodes/children.js +165 -0
  242. package/dist/nodes/finally/emit.d.ts +6 -0
  243. package/dist/nodes/finally/emit.js +71 -0
  244. package/dist/nodes/finally/entities.d.ts +13 -0
  245. package/dist/nodes/finally/entities.js +42 -0
  246. package/dist/nodes/finally/index.d.ts +8 -0
  247. package/dist/nodes/finally/index.js +35 -0
  248. package/dist/nodes/finally/queries.d.ts +5 -0
  249. package/dist/nodes/finally/queries.js +25 -0
  250. package/dist/nodes/finally/relations-access.d.ts +5 -0
  251. package/dist/nodes/finally/relations-access.js +50 -0
  252. package/dist/nodes/finally/relations-edge.d.ts +29 -0
  253. package/dist/nodes/finally/relations-edge.js +148 -0
  254. package/dist/nodes/finally/relations-group.d.ts +31 -0
  255. package/dist/nodes/finally/relations-group.js +106 -0
  256. package/dist/nodes/finally/relations.d.ts +5 -0
  257. package/dist/nodes/finally/relations.js +85 -0
  258. package/dist/nodes/finally/required.d.ts +5 -0
  259. package/dist/nodes/finally/required.js +92 -0
  260. package/dist/nodes/finally/violation.d.ts +17 -0
  261. package/dist/nodes/finally/violation.js +2 -0
  262. package/dist/nodes/similar.d.ts +21 -0
  263. package/dist/nodes/similar.js +178 -0
  264. package/dist/piece-forms.d.ts +9 -0
  265. package/dist/piece-forms.js +68 -0
  266. package/dist/pipeline-entities.d.ts +6 -0
  267. package/dist/pipeline-entities.js +79 -0
  268. package/dist/pipeline-facts.d.ts +12 -0
  269. package/dist/pipeline-facts.js +114 -0
  270. package/dist/pipeline-unclassified.d.ts +14 -0
  271. package/dist/pipeline-unclassified.js +188 -0
  272. package/dist/pipeline.d.ts +7 -0
  273. package/dist/pipeline.js +28 -0
  274. package/dist/plugin.d.ts +2 -0
  275. package/dist/plugin.js +3 -0
  276. package/dist/release-file.d.ts +3 -0
  277. package/dist/release-file.js +13 -0
  278. package/dist/report/asks.d.ts +55 -0
  279. package/dist/report/asks.js +60 -0
  280. package/dist/report/cli-report.d.ts +2 -0
  281. package/dist/report/cli-report.js +13 -0
  282. package/dist/report/config-error-guard.d.ts +8 -0
  283. package/dist/report/config-error-guard.js +5 -0
  284. package/dist/report/configErrors.d.ts +126 -0
  285. package/dist/report/configErrors.js +121 -0
  286. package/dist/report/errorTypes/codes/structure.d.ts +15 -0
  287. package/dist/report/errorTypes/codes/structure.js +76 -0
  288. package/dist/report/errorTypes/decision-maker.d.ts +23 -0
  289. package/dist/report/errorTypes/decision-maker.js +109 -0
  290. package/dist/report/errorTypes/destinations.d.ts +38 -0
  291. package/dist/report/errorTypes/destinations.js +165 -0
  292. package/dist/report/errorTypes/finding-type.d.ts +11 -0
  293. package/dist/report/errorTypes/finding-type.js +2 -0
  294. package/dist/report/errorTypes/index.d.ts +15 -0
  295. package/dist/report/errorTypes/index.js +55 -0
  296. package/dist/report/errorTypes/types/fileContents.d.ts +9 -0
  297. package/dist/report/errorTypes/types/fileContents.js +40 -0
  298. package/dist/report/errorTypes/types/unknownEntity.d.ts +9 -0
  299. package/dist/report/errorTypes/types/unknownEntity.js +27 -0
  300. package/dist/report/errorTypes/types/wrongAction.d.ts +22 -0
  301. package/dist/report/errorTypes/types/wrongAction.js +140 -0
  302. package/dist/report/errorTypes/types/wrongPlacement.d.ts +9 -0
  303. package/dist/report/errorTypes/types/wrongPlacement.js +67 -0
  304. package/dist/report/errorTypes/vocabulary/ids.d.ts +5 -0
  305. package/dist/report/errorTypes/vocabulary/ids.js +16 -0
  306. package/dist/report/errorTypes/vocabulary/phrases.d.ts +10 -0
  307. package/dist/report/errorTypes/vocabulary/phrases.js +187 -0
  308. package/dist/report/errorTypes/vocabulary/places.d.ts +8 -0
  309. package/dist/report/errorTypes/vocabulary/places.js +36 -0
  310. package/dist/report/errorTypes/vocabulary/verbs.d.ts +7 -0
  311. package/dist/report/errorTypes/vocabulary/verbs.js +30 -0
  312. package/dist/report/finding-from.d.ts +9 -0
  313. package/dist/report/finding-from.js +108 -0
  314. package/dist/report/notices.d.ts +9 -0
  315. package/dist/report/notices.js +57 -0
  316. package/dist/report/observed.d.ts +19 -0
  317. package/dist/report/observed.js +87 -0
  318. package/dist/report/render-report.d.ts +12 -0
  319. package/dist/report/render-report.js +145 -0
  320. package/dist/report/user-report/build/bundle.d.ts +3 -0
  321. package/dist/report/user-report/build/bundle.js +188 -0
  322. package/dist/report/user-report/build/bundle.prebuilt.js +1262 -0
  323. package/dist/report/user-report/data/collect.d.ts +4 -0
  324. package/dist/report/user-report/data/collect.js +93 -0
  325. package/dist/report/user-report/data/entities.d.ts +7 -0
  326. package/dist/report/user-report/data/entities.js +88 -0
  327. package/dist/report/user-report/data/entity-examples.d.ts +16 -0
  328. package/dist/report/user-report/data/entity-examples.js +136 -0
  329. package/dist/report/user-report/data/entity-filters.d.ts +15 -0
  330. package/dist/report/user-report/data/entity-filters.js +79 -0
  331. package/dist/report/user-report/data/entity-marks.d.ts +5 -0
  332. package/dist/report/user-report/data/entity-marks.js +79 -0
  333. package/dist/report/user-report/data/file-tree.d.ts +9 -0
  334. package/dist/report/user-report/data/file-tree.js +80 -0
  335. package/dist/report/user-report/data/finding-boundary.d.ts +9 -0
  336. package/dist/report/user-report/data/finding-boundary.js +21 -0
  337. package/dist/report/user-report/data/finding-plan.d.ts +16 -0
  338. package/dist/report/user-report/data/finding-plan.js +45 -0
  339. package/dist/report/user-report/data/finding-title.d.ts +12 -0
  340. package/dist/report/user-report/data/finding-title.js +36 -0
  341. package/dist/report/user-report/data/findings.d.ts +10 -0
  342. package/dist/report/user-report/data/findings.js +181 -0
  343. package/dist/report/user-report/data/graph-edges.d.ts +19 -0
  344. package/dist/report/user-report/data/graph-edges.js +109 -0
  345. package/dist/report/user-report/data/graph-entities.d.ts +6 -0
  346. package/dist/report/user-report/data/graph-entities.js +158 -0
  347. package/dist/report/user-report/data/graph-helpers.d.ts +7 -0
  348. package/dist/report/user-report/data/graph-helpers.js +67 -0
  349. package/dist/report/user-report/data/graph.d.ts +12 -0
  350. package/dist/report/user-report/data/graph.js +97 -0
  351. package/dist/report/user-report/data/nodes.d.ts +11 -0
  352. package/dist/report/user-report/data/nodes.js +116 -0
  353. package/dist/report/user-report/data/rules.d.ts +7 -0
  354. package/dist/report/user-report/data/rules.js +62 -0
  355. package/dist/report/user-report/data/scan.d.ts +8 -0
  356. package/dist/report/user-report/data/scan.js +69 -0
  357. package/dist/report/user-report/html/shell.d.ts +3 -0
  358. package/dist/report/user-report/html/shell.js +27 -0
  359. package/dist/report/user-report/index.d.ts +8 -0
  360. package/dist/report/user-report/index.js +58 -0
  361. package/dist/report/user-report/shared/describe.d.ts +7 -0
  362. package/dist/report/user-report/shared/describe.js +86 -0
  363. package/dist/rules/index.d.ts +7 -0
  364. package/dist/rules/index.js +327 -0
  365. package/dist/rules/list-vars.d.ts +5 -0
  366. package/dist/rules/list-vars.js +149 -0
  367. package/dist/rules/name.d.ts +16 -0
  368. package/dist/rules/name.js +18 -0
  369. package/dist/rules/normalize.d.ts +5 -0
  370. package/dist/rules/normalize.js +108 -0
  371. package/dist/rules/vars.d.ts +22 -0
  372. package/dist/rules/vars.js +117 -0
  373. package/dist/scan-run.d.ts +20 -0
  374. package/dist/scan-run.js +130 -0
  375. package/dist/scripts/audit-report.d.ts +2 -0
  376. package/dist/scripts/audit-report.js +157 -0
  377. package/dist/usage-index.d.ts +4 -0
  378. package/dist/usage-index.js +282 -0
  379. package/dist/usage-mode.d.ts +7 -0
  380. package/dist/usage-mode.js +16 -0
  381. package/dist/usage-pass.d.ts +19 -0
  382. package/dist/usage-pass.js +136 -0
  383. package/dist/usage-prepare.d.ts +2 -0
  384. package/dist/usage-prepare.js +22 -0
  385. package/dist/usage-sweep.d.ts +10 -0
  386. package/dist/usage-sweep.js +264 -0
  387. package/dist/utils/accumulate.d.ts +6 -0
  388. package/dist/utils/accumulate.js +18 -0
  389. package/dist/utils/aliases.d.ts +22 -0
  390. package/dist/utils/aliases.js +173 -0
  391. package/dist/utils/article.d.ts +2 -0
  392. package/dist/utils/article.js +12 -0
  393. package/dist/utils/classify.d.ts +12 -0
  394. package/dist/utils/classify.js +25 -0
  395. package/dist/utils/configs.d.ts +25 -0
  396. package/dist/utils/configs.js +97 -0
  397. package/dist/utils/count.d.ts +7 -0
  398. package/dist/utils/count.js +13 -0
  399. package/dist/utils/dispatch.d.ts +2 -0
  400. package/dist/utils/dispatch.js +27 -0
  401. package/dist/utils/distinct.d.ts +2 -0
  402. package/dist/utils/distinct.js +14 -0
  403. package/dist/utils/field.d.ts +14 -0
  404. package/dist/utils/field.js +60 -0
  405. package/dist/utils/file-name.d.ts +2 -0
  406. package/dist/utils/file-name.js +11 -0
  407. package/dist/utils/files.d.ts +7 -0
  408. package/dist/utils/files.js +77 -0
  409. package/dist/utils/fixpoint.d.ts +2 -0
  410. package/dist/utils/fixpoint.js +19 -0
  411. package/dist/utils/gate.d.ts +2 -0
  412. package/dist/utils/gate.js +12 -0
  413. package/dist/utils/group.d.ts +3 -0
  414. package/dist/utils/group.js +33 -0
  415. package/dist/utils/host.d.ts +3 -0
  416. package/dist/utils/host.js +16 -0
  417. package/dist/utils/imports.d.ts +12 -0
  418. package/dist/utils/imports.js +185 -0
  419. package/dist/utils/judged.d.ts +5 -0
  420. package/dist/utils/judged.js +19 -0
  421. package/dist/utils/keyed.d.ts +2 -0
  422. package/dist/utils/keyed.js +23 -0
  423. package/dist/utils/map-record.d.ts +2 -0
  424. package/dist/utils/map-record.js +11 -0
  425. package/dist/utils/packages.d.ts +15 -0
  426. package/dist/utils/packages.js +207 -0
  427. package/dist/utils/path-label.d.ts +6 -0
  428. package/dist/utils/path-label.js +37 -0
  429. package/dist/utils/pattern.d.ts +19 -0
  430. package/dist/utils/pattern.js +231 -0
  431. package/dist/utils/permission.d.ts +16 -0
  432. package/dist/utils/permission.js +18 -0
  433. package/dist/utils/plural.d.ts +2 -0
  434. package/dist/utils/plural.js +9 -0
  435. package/dist/utils/qualified.d.ts +2 -0
  436. package/dist/utils/qualified.js +21 -0
  437. package/dist/utils/rank.d.ts +2 -0
  438. package/dist/utils/rank.js +24 -0
  439. package/dist/utils/read-field.d.ts +12 -0
  440. package/dist/utils/read-field.js +50 -0
  441. package/dist/utils/read-when.d.ts +2 -0
  442. package/dist/utils/read-when.js +17 -0
  443. package/dist/utils/reason.d.ts +4 -0
  444. package/dist/utils/reason.js +9 -0
  445. package/dist/utils/record.d.ts +3 -0
  446. package/dist/utils/record.js +21 -0
  447. package/dist/utils/resolve.d.ts +2 -0
  448. package/dist/utils/resolve.js +24 -0
  449. package/dist/utils/search.d.ts +2 -0
  450. package/dist/utils/search.js +21 -0
  451. package/dist/utils/seen.d.ts +6 -0
  452. package/dist/utils/seen.js +27 -0
  453. package/dist/utils/span.d.ts +5 -0
  454. package/dist/utils/span.js +2 -0
  455. package/dist/utils/speak.d.ts +2 -0
  456. package/dist/utils/speak.js +18 -0
  457. package/dist/utils/split.d.ts +8 -0
  458. package/dist/utils/split.js +21 -0
  459. package/dist/utils/template.d.ts +5 -0
  460. package/dist/utils/template.js +5 -0
  461. package/dist/utils/text.d.ts +4 -0
  462. package/dist/utils/text.js +42 -0
  463. package/dist/utils/tokenize.d.ts +2 -0
  464. package/dist/utils/tokenize.js +18 -0
  465. package/dist/utils/try-read.d.ts +4 -0
  466. package/dist/utils/try-read.js +24 -0
  467. package/dist/utils/typed-field.d.ts +3 -0
  468. package/dist/utils/typed-field.js +16 -0
  469. package/dist/utils/verdicts.d.ts +4 -0
  470. package/dist/utils/verdicts.js +20 -0
  471. package/entities/operators.ts +31 -0
  472. package/package.json +101 -47
  473. package/report/errorTypes/vocabulary/ids.ts +17 -0
  474. package/report/errorTypes/vocabulary/phrases.ts +181 -0
  475. package/report/errorTypes/vocabulary/places.ts +51 -0
  476. package/report/errorTypes/vocabulary/verbs.ts +31 -0
  477. package/report/user-report/shared/describe.ts +107 -0
  478. package/ast.js +0 -107
  479. package/bin/follow-architecture.js +0 -6
  480. package/config.js +0 -101
  481. package/entities/aliases.js +0 -10
  482. package/entities/invariants.js +0 -134
  483. package/entities/nodes.js +0 -112
  484. package/main.js +0 -96
  485. package/plugin.js +0 -5
  486. package/report.js +0 -73
  487. package/utils.js +0 -104
@@ -0,0 +1,264 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.nameSymbol = exports.sweep = void 0;
37
+ // WHO USES A NAME, IN ONE WALK. `findReferencesAsNodes` asks the language service
38
+ // a question about the whole program once per candidate — 38 000 questions on this
39
+ // repo, ~1.5 ms each, and every answer re-derives what the checker already knows.
40
+ // The same facts are computable in a single pass: resolve every identifier to its
41
+ // symbol, group the occurrences by that symbol, and count.
42
+ //
43
+ // The answer keeps the shape and the meaning of `ReferencesFact`
44
+ // (`entities/facts.ts`): `total` = uses (the declaration's own name is not a use,
45
+ // a use in the declaring file is), `outside` = the ones in other files, `files` =
46
+ // the distinct files, `usedIn` = those where the name is USED and not merely
47
+ // republished by `export … from`.
48
+ const path = __importStar(require("node:path"));
49
+ const ts_morph_1 = require("ts-morph");
50
+ const emptyPart = () => ({ all: 0, used: 0, head: false });
51
+ const tallyOf = (into, symbol) => {
52
+ let tally = into.names.get(symbol);
53
+ if (tally === undefined) {
54
+ tally = new Map();
55
+ into.names.set(symbol, tally);
56
+ }
57
+ return tally;
58
+ };
59
+ const partOf = (name, file) => {
60
+ const found = name.get(file);
61
+ if (found !== undefined)
62
+ return found;
63
+ const part = emptyPart();
64
+ name.set(file, part);
65
+ return part;
66
+ };
67
+ // The file a node lives in, relative to the repo — the spelling a rule sees.
68
+ const relOf = (node, repoRoot) => {
69
+ const file = node.getSourceFile().fileName;
70
+ const rel = path.relative(repoRoot, file);
71
+ return rel.startsWith("..") ? null : rel.split(path.sep).join("/");
72
+ };
73
+ // Is the token part of an `export … from`? The same syntax rule the language
74
+ // service answer is filtered by: walk up to the statement that holds the name.
75
+ const inExportFrom = (node) => {
76
+ for (let current = node.parent; current !== undefined; current = current.parent) {
77
+ if (current.kind === ts_morph_1.ts.SyntaxKind.SourceFile)
78
+ return false;
79
+ if (current.kind === ts_morph_1.ts.SyntaxKind.ExportDeclaration)
80
+ return true;
81
+ }
82
+ return false;
83
+ };
84
+ // A declaration inside `declare global { … }` or `declare module "x" { … }` does
85
+ // not own its symbol: the checker merges those declarations into a symbol of
86
+ // another file's scope, and the walk sees a different one. The language service
87
+ // resolves the merge; the walk does not, so the name is answered exactly.
88
+ const inAmbientBlock = (node) => {
89
+ for (let current = node.parent; current !== undefined; current = current.parent) {
90
+ if (!ts_morph_1.ts.isModuleDeclaration(current))
91
+ continue;
92
+ const flags = ts_morph_1.ts.getCombinedModifierFlags(current);
93
+ if ((flags & ts_morph_1.ts.ModifierFlags.Ambient) !== 0)
94
+ return true;
95
+ if (current.name.kind === ts_morph_1.ts.SyntaxKind.StringLiteral)
96
+ return true;
97
+ }
98
+ return false;
99
+ };
100
+ // The token IS the name the TARGET symbol is declared under — the definition,
101
+ // which the language service does not count as a reference. Asked of the symbol
102
+ // rather than of the parent's shape: a declaration is whatever the checker says
103
+ // declares it. An alias (`import { x }`) declares the alias, not the target, and
104
+ // the language service counts it as a reference to the target — so it is a use.
105
+ const isDefinition = (node, target) => target.declarations !== undefined && target.declarations.some((declared) => declared === node.parent);
106
+ // An alias (`import { x as y }`, `export { x as y }`) names its target: the checker
107
+ // answers references against the TARGET's symbol, and so must the sweep, or the
108
+ // same name would be counted once per alias.
109
+ const targetOf = (checker, symbol) => {
110
+ if ((symbol.flags & ts_morph_1.ts.SymbolFlags.Alias) === 0)
111
+ return symbol;
112
+ try {
113
+ return checker.getAliasedSymbol(symbol);
114
+ }
115
+ catch {
116
+ return symbol;
117
+ }
118
+ };
119
+ // Do we count this token at all? Identifiers everywhere (declarations, uses,
120
+ // member names, shorthand properties, JSX names) and the string spelling of a
121
+ // module-specifier name (`import { "x" as y }`). Nothing else in a file names a binding.
122
+ const isNameToken = (node) => {
123
+ if (node.kind === ts_morph_1.ts.SyntaxKind.Identifier)
124
+ return true;
125
+ if (node.kind !== ts_morph_1.ts.SyntaxKind.StringLiteral)
126
+ return false;
127
+ const parent = node.parent;
128
+ return parent !== undefined && (ts_morph_1.ts.isImportSpecifier(parent) || ts_morph_1.ts.isExportSpecifier(parent));
129
+ };
130
+ // `namespaced` holds the files something imports as `import * as ns`: through a
131
+ // namespace any export may be reached, and the language service answers that
132
+ // shape its own way (it even counts the namespace token itself), so a name
133
+ // declared in such a file is not answered by the walk at all.
134
+ // A name re-exported under another name (`export { PairView as Diff }`) is counted
135
+ // by the language service once per spelling of the specifier, not once per token —
136
+ // three specifiers of `PairView` in one line give it six references where the walk
137
+ // sees three tokens. Not attributable here: such a symbol is asked exactly.
138
+ const isExportAlias = (node) => {
139
+ const parent = node.parent;
140
+ return parent !== undefined && ts_morph_1.ts.isExportSpecifier(parent) && parent.propertyName !== undefined;
141
+ };
142
+ // A class or interface member is answered across the type hierarchy: a use of the
143
+ // interface's `emit` is a reference to the class method that implements it, and
144
+ // the walk sees one symbol per declaration. Not attributable here — asked exactly.
145
+ const isMember = (symbol) => (symbol.flags & (ts_morph_1.ts.SymbolFlags.Property | ts_morph_1.ts.SymbolFlags.Method | ts_morph_1.ts.SymbolFlags.GetAccessor | ts_morph_1.ts.SymbolFlags.SetAccessor)) !== 0;
146
+ const isModuleSymbol = (symbol) => symbol.declarations !== undefined && symbol.declarations.some((each) => each.kind === ts_morph_1.ts.SyntaxKind.SourceFile);
147
+ const modulePath = (module, repoRoot) => {
148
+ for (const each of module.declarations ?? []) {
149
+ if (each.kind !== ts_morph_1.ts.SyntaxKind.SourceFile)
150
+ continue;
151
+ const rel = relOf(each, repoRoot);
152
+ if (rel !== null)
153
+ return rel;
154
+ }
155
+ return null;
156
+ };
157
+ const hasDeclarations = (symbol) => symbol.declarations !== undefined && symbol.declarations.length > 0;
158
+ // The symbol this token names: `{ Post }` declares a property, and the name is a
159
+ // USE of the variable that property reads — the shorthand answers for both.
160
+ const attribute = (node, checker) => {
161
+ const parent = node.parent;
162
+ const symbol = parent !== undefined && ts_morph_1.ts.isShorthandPropertyAssignment(parent)
163
+ ? checker.getShorthandAssignmentValueSymbol(parent)
164
+ : checker.getSymbolAtLocation(node);
165
+ return symbol === undefined ? undefined : targetOf(checker, symbol);
166
+ };
167
+ // One token → one count in its symbol's tally. A declaration in an ambient block,
168
+ // or a name whose symbol has no declaration at all (an augmentation's export), is
169
+ // not attributable by this walk: the name is answered exactly instead.
170
+ const countToken = (node, into, checker, repoRoot) => {
171
+ const target = attribute(node, checker);
172
+ if (target === undefined)
173
+ return;
174
+ const text = node.getText();
175
+ if (isExportAlias(node)) {
176
+ into.aliased.add(target);
177
+ return;
178
+ }
179
+ if (inAmbientBlock(node) || !hasDeclarations(target)) {
180
+ into.unsure.add(text);
181
+ return;
182
+ }
183
+ const rel = relOf(node, repoRoot);
184
+ if (rel === null)
185
+ return;
186
+ if (isModuleSymbol(target)) {
187
+ const file = modulePath(target, repoRoot);
188
+ if (file !== null)
189
+ into.namespaced.add(file);
190
+ return;
191
+ }
192
+ const part = partOf(tallyOf(into, target), rel);
193
+ if (part.all === 0)
194
+ part.head = isDefinition(node, target);
195
+ part.all += 1;
196
+ if (!inExportFrom(node))
197
+ part.used += 1;
198
+ };
199
+ // The whole program, one walk. Files outside the repo (the compiler's own libs, a
200
+ // dependency's `.d.ts`) are skipped: a use in them is not a use in this repo.
201
+ const collect = (program, repoRoot) => {
202
+ const checker = program.getTypeChecker();
203
+ const into = { names: new Map(), unsure: new Set(), namespaced: new Set(), aliased: new Set() };
204
+ for (const file of program.getSourceFiles()) {
205
+ if (relOf(file, repoRoot) === null)
206
+ continue;
207
+ const visit = (node) => {
208
+ if (isNameToken(node))
209
+ countToken(node, into, checker, repoRoot);
210
+ ts_morph_1.ts.forEachChild(node, visit);
211
+ };
212
+ ts_morph_1.ts.forEachChild(file, visit);
213
+ }
214
+ return into;
215
+ };
216
+ // The tally of one symbol as the fact a rule reads. The declaring file is the
217
+ // caller's business: the same name in two modules must answer for its own module.
218
+ // The declaration the caller asks about is not its own reference — the language
219
+ // service skips it, but only when nothing sortable comes before it in its file:
220
+ // a use above the declaration makes the declaration itself a counted reference.
221
+ const answerOf = (name, ownRel) => {
222
+ let total = name.get(ownRel)?.head === true ? -1 : 0;
223
+ const where = [];
224
+ const used = [];
225
+ for (const [file, part] of name) {
226
+ total += part.all;
227
+ if (file === ownRel)
228
+ continue;
229
+ if (part.all > 0)
230
+ where.push(file);
231
+ if (part.used > 0)
232
+ used.push(file);
233
+ }
234
+ return { total, outside: where.reduce((sum, file) => sum + (name.get(file)?.all ?? 0), 0), files: where, usedIn: used };
235
+ };
236
+ // The symbol a NAME TOKEN declares or uses, with aliases resolved: what the
237
+ // checker would answer references about.
238
+ const nameSymbol = (checker, node) => {
239
+ const symbol = checker.getSymbolAtLocation(node);
240
+ return symbol === undefined ? undefined : targetOf(checker, symbol);
241
+ };
242
+ exports.nameSymbol = nameSymbol;
243
+ const sweep = (program, repoRoot) => {
244
+ const { names, unsure, namespaced, aliased } = collect(program, repoRoot);
245
+ // A symbol with more than one declaration is answered per declaration by the
246
+ // language service, and the walk keeps one tally for all of them.
247
+ const merged = new Set();
248
+ for (const [symbol] of names)
249
+ if ((symbol.declarations?.length ?? 0) > 1)
250
+ merged.add(symbol);
251
+ return {
252
+ references: (symbol, ownRel, name) => {
253
+ if (unsure.has(name) || namespaced.has(ownRel) || merged.has(symbol) || isMember(symbol) || aliased.has(symbol))
254
+ return null;
255
+ const tally = names.get(symbol);
256
+ // A symbol the walk never met (a declaration outside the repository, a lib
257
+ // type) has no tally here, and "no uses" would be a claim, not an answer:
258
+ // the caller asks exactly instead.
259
+ return tally === undefined ? null : answerOf(tally, ownRel);
260
+ },
261
+ unsure,
262
+ };
263
+ };
264
+ exports.sweep = sweep;
@@ -0,0 +1,6 @@
1
+ declare const accumulateByKey: <Item, Bucket>(items: readonly {
2
+ key: string;
3
+ item: Item;
4
+ bucket: Bucket;
5
+ }[], buckets: Map<string, Bucket>, join: (bucket: Bucket, item: Item) => void) => void;
6
+ export { accumulateByKey };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.accumulateByKey = void 0;
4
+ // A KEYED ACCUMULATION is one mechanism: items arrive with a key, and each is
5
+ // merged into the bucket that key names — a new bucket when the key is new,
6
+ // the existing one otherwise. The relation check groups refused edges by
7
+ // kind + target + what (`nodes/finally/relations`); any consumer that folds
8
+ // items into keyed buckets asks the same question. The walk is the same —
9
+ // read the bucket, merge, store — so it lives here once. What a bucket IS and
10
+ // how an item joins it is the caller's own.
11
+ const accumulateByKey = (items, buckets, join) => {
12
+ for (const { key, item, bucket } of items) {
13
+ const target = buckets.get(key) ?? bucket;
14
+ join(target, item);
15
+ buckets.set(key, target);
16
+ }
17
+ };
18
+ exports.accumulateByKey = accumulateByKey;
@@ -0,0 +1,22 @@
1
+ import { type FieldValue } from "@md-code/follow-architecture/utils/field";
2
+ type Aliases = Record<string, string>;
3
+ type Alias = {
4
+ name: string;
5
+ rest: string;
6
+ };
7
+ declare const splitAlias: (aliases: Aliases | null | undefined, specifier: string) => Alias | null;
8
+ type Placement = {
9
+ dirs: string[];
10
+ files: string[];
11
+ };
12
+ type AliasScope = {
13
+ repoRoot?: string | null;
14
+ repoFiles?: readonly string[];
15
+ };
16
+ declare const locateAlias: (aliases: Aliases | null | undefined, name: string, rest: string, scope?: AliasScope) => Placement | null;
17
+ declare const placesOf: (aliases: Aliases | null | undefined, specifier: string, scope?: AliasScope) => string[] | null;
18
+ declare const primaryPlace: (aliases: Aliases | null | undefined, specifier: string, scope?: AliasScope) => string | null;
19
+ declare const expandPattern: (aliases: Aliases | null | undefined, pattern: string, scope?: AliasScope) => string;
20
+ declare const expandLocationFilters: (filter: FieldValue, aliases: Aliases | null | undefined) => FieldValue;
21
+ export { splitAlias, locateAlias, placesOf, primaryPlace, expandPattern, expandLocationFilters };
22
+ export type { Aliases, AliasScope, Placement };
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.expandLocationFilters = exports.expandPattern = exports.primaryPlace = exports.placesOf = exports.locateAlias = exports.splitAlias = void 0;
37
+ // ONE vocabulary for the architecture's aliases: what a specifier names, where it
38
+ // points, and how a config pattern that starts with `@` becomes a repo path. Its
39
+ // four consumers — the import resolver, node names/children, rule `where`/`ignore`
40
+ // and `location` filters — ask these functions and nothing else, so the alias map
41
+ // and the packages' `exports` are read in exactly one place.
42
+ //
43
+ // Without a scanned set (the config is built before the repo is scanned) only the
44
+ // plain reading is available: `@pkg` is the package folder, `@pkg/x` the folder
45
+ // under it. With `{ repoRoot, repoFiles }` a subpath also goes through the
46
+ // package's manifest and lands on the source its artifact was built from.
47
+ const notices_1 = require("@md-code/follow-architecture/report/notices");
48
+ const configError = __importStar(require("@md-code/follow-architecture/report/configErrors"));
49
+ const packages_1 = require("@md-code/follow-architecture/utils/packages");
50
+ const field_1 = require("@md-code/follow-architecture/utils/field");
51
+ const splitAlias = (aliases, specifier) => {
52
+ const s = String(specifier ?? "");
53
+ let name = null;
54
+ for (const candidate of Object.keys(aliases ?? {})) {
55
+ if (s !== candidate && !s.startsWith(`${candidate}/`))
56
+ continue;
57
+ if (name == null || candidate.length > name.length)
58
+ name = candidate;
59
+ }
60
+ if (name == null)
61
+ return null;
62
+ return { name, rest: s.slice(name.length).replace(/^\//, "") };
63
+ };
64
+ exports.splitAlias = splitAlias;
65
+ const isStars = (rest) => rest.length > 0 && /^\*(?:\/\*)*$/.test(rest);
66
+ // `@pkg/*` — every public source of the package, for a package that has no
67
+ // folders to walk. Only a scanned set can answer it.
68
+ const starredPlace = (folder, manifest, repoFiles) => {
69
+ const sources = (0, packages_1.publicSources)(folder, manifest, repoFiles);
70
+ return sources.length ? { dirs: [], files: sources } : null;
71
+ };
72
+ const artifactPlace = ({ name, folder, rest, manifest, repoFiles }) => {
73
+ const folderReading = { dirs: [`${folder}/${rest}`], files: [] };
74
+ const artifact = (0, packages_1.exportsPath)(manifest, rest) ?? (0, packages_1.typesVersionPath)(manifest, rest);
75
+ if (artifact == null || !repoFiles)
76
+ return folderReading;
77
+ const source = (0, packages_1.sourceOf)(folder, artifact, repoFiles);
78
+ if (source)
79
+ return { dirs: [], files: [source] };
80
+ (0, notices_1.notice)(`the alias ${name}/${rest} points at ${(0, packages_1.norm)(artifact)}, which no scanned file mirrors`, "the package's `exports` names that file but the package has no source for it — the import resolves to nothing the architecture can see");
81
+ return folderReading;
82
+ };
83
+ // Where an alias subpath points: the package's public entry when its manifest
84
+ // names one, otherwise the folder (or file) under the alias target.
85
+ const locateAlias = (aliases, name, rest, scope = {}) => {
86
+ const target = aliases?.[name];
87
+ if (target == null)
88
+ return null;
89
+ const folder = (0, packages_1.folderOf)(target);
90
+ if (!rest)
91
+ return { dirs: [folder], files: (0, packages_1.isFile)(target) ? [(0, packages_1.norm)(target)] : [] };
92
+ const manifest = (0, packages_1.manifestOf)(scope.repoRoot, folder);
93
+ const repoFiles = scope.repoFiles;
94
+ const starred = repoFiles && isStars(rest) ? starredPlace(folder, manifest, repoFiles) : null;
95
+ return starred ?? artifactPlace({ name, folder, rest, manifest, repoFiles });
96
+ };
97
+ exports.locateAlias = locateAlias;
98
+ // A CONFIG pattern (`@pkg/**`, `@pkg/chip`, `@pkg/themes`) → the repo place(s) it
99
+ // stands for, absolute. `null` when the specifier is not an alias at all.
100
+ const placesOf = (aliases, specifier, scope = {}) => {
101
+ const alias = splitAlias(aliases, specifier);
102
+ if (!alias)
103
+ return null;
104
+ const place = locateAlias(aliases, alias.name, alias.rest, scope);
105
+ const places = [...(place?.dirs ?? []), ...(place?.files ?? [])];
106
+ if (!places.length)
107
+ return [`${(0, packages_1.folderOf)(String(aliases?.[alias.name] ?? ""))}/${alias.rest}`];
108
+ return places;
109
+ };
110
+ exports.placesOf = placesOf;
111
+ // The ONE place a specifier names, when the caller needs a single string (a node's
112
+ // name, a child): the package folder when the alias has one, else the entry file.
113
+ const primaryPlace = (aliases, specifier, scope = {}) => {
114
+ const alias = splitAlias(aliases, specifier);
115
+ if (!alias)
116
+ return null;
117
+ const place = locateAlias(aliases, alias.name, alias.rest, scope);
118
+ if (place == null)
119
+ return null;
120
+ return place.dirs[0] ?? place.files[0] ?? null;
121
+ };
122
+ exports.primaryPlace = primaryPlace;
123
+ // A PREFIX pattern (`@md/utils/`) names a FOLDER and everything under it, so only
124
+ // folders answer it: the alias's entry file is not one.
125
+ const folderPlace = (aliases, specifier, scope) => {
126
+ const alias = splitAlias(aliases, specifier);
127
+ if (!alias) {
128
+ if (!specifier.startsWith("@"))
129
+ return specifier;
130
+ throw configError.unknownAlias({ specifier, known: Object.keys(aliases ?? {}) });
131
+ }
132
+ const place = locateAlias(aliases, alias.name, alias.rest, scope);
133
+ const folder = (0, packages_1.folderOf)(String(aliases?.[alias.name] ?? ""));
134
+ return place?.dirs[0] ?? (alias.rest ? `${folder}/${alias.rest}` : folder);
135
+ };
136
+ // A CONFIG pattern → the repo path it stands for: one path when the alias names
137
+ // one place, a brace alternation when it names several. A `@`-specifier that is
138
+ // NOT an alias is a config error — it would silently match nothing. A trailing
139
+ // `/` is a PREFIX (`startsWith: "@md/utils/"`), not a glob: it must survive, or
140
+ // the filter would widen from `utils/*` to `utils*` and swallow `utils-uniqueness`.
141
+ const expandPattern = (aliases, pattern, scope = {}) => {
142
+ const s = String(pattern ?? "");
143
+ if (s.endsWith("/"))
144
+ return `${folderPlace(aliases, s.slice(0, -1), scope)}/`;
145
+ const places = placesOf(aliases, s, scope);
146
+ if (!places) {
147
+ if (!s.startsWith("@"))
148
+ return s;
149
+ throw configError.unknownAlias({ specifier: s, known: Object.keys(aliases ?? {}) });
150
+ }
151
+ return places.length === 1 ? places[0] : `{${places.join(",")}}`;
152
+ };
153
+ exports.expandPattern = expandPattern;
154
+ // Only a `location` subtree names PLACES. A filter's other strings are values
155
+ // (`equals: "@angular/core"` names a package, not a file), so they stay as written.
156
+ const LOCATION_KEY = "location";
157
+ const rewritePatterns = (value, aliases, inside) => {
158
+ if (typeof value === "string")
159
+ return inside ? expandPattern(aliases, value) : value;
160
+ if ((0, field_1.isList)(value))
161
+ return value.map((item) => rewritePatterns(item, aliases, inside));
162
+ if (!(0, field_1.isObj)(value))
163
+ return value;
164
+ const out = {};
165
+ for (const [key, item] of Object.entries(value)) {
166
+ out[key] = rewritePatterns(item, aliases, inside || key === LOCATION_KEY);
167
+ }
168
+ return out;
169
+ };
170
+ // A filter with every `location` pattern expanded. A filter is plain data, so the
171
+ // rewrite is a copy — the raw config stays as written.
172
+ const expandLocationFilters = (filter, aliases) => rewritePatterns(filter, aliases, false);
173
+ exports.expandLocationFilters = expandLocationFilters;
@@ -0,0 +1,2 @@
1
+ declare const article: (word: string, capital?: boolean) => string;
2
+ export { article };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.article = void 0;
4
+ // `a` / `an` for a word — the ONE place English grammar about the indefinite
5
+ // article lives, so no message has to repeat the rule.
6
+ const article = (word, capital = false) => {
7
+ const an = /^[aeiou]/i.test(String(word));
8
+ if (!capital)
9
+ return an ? "an" : "a";
10
+ return an ? "An" : "A";
11
+ };
12
+ exports.article = article;
@@ -0,0 +1,12 @@
1
+ import type { QueryFilter, QueryScope } from "@md-code/follow-architecture/entities/architecture";
2
+ import type { FieldValue } from "@md-code/follow-architecture/utils/field";
3
+ type Definition = {
4
+ name: string;
5
+ infer: QueryFilter;
6
+ };
7
+ declare const definitionsOf: (defs: Record<string, {
8
+ infer?: QueryFilter;
9
+ }> | null | undefined) => Definition[];
10
+ declare const firstMatch: (subject: FieldValue, defs: readonly Definition[], scope: QueryScope) => string | null;
11
+ export { definitionsOf, firstMatch };
12
+ export type { Definition };
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.firstMatch = exports.definitionsOf = void 0;
4
+ // A CLASSIFICATION is one mechanism: definitions are tried in DECLARED ORDER
5
+ // against a subject, and the FIRST whose `infer` filter matches names it. A
6
+ // code entity classifies a piece of code (`code-entities/connector`), a file's own
7
+ // facts (`code-entities/classify`), and the entities a folder's files hold
8
+ // (`nodes/similar`) — all three ask the same question of the same filter
9
+ // engine, so the walk lives here once. What the definitions ARE and what a
10
+ // match MEANS is the caller's own; nothing here knows entities.
11
+ const queries_1 = require("@md-code/follow-architecture/entities/queries");
12
+ // The definitions a record of `{ infer }` specs declares, in the record's own
13
+ // (YAML) order. A spec without an infer filter can never match.
14
+ const definitionsOf = (defs) => Object.entries(defs ?? {}).map(([name, def]) => ({ name, infer: def?.infer ?? null }));
15
+ exports.definitionsOf = definitionsOf;
16
+ // The first definition whose infer matches the subject, or null. A null/absent
17
+ // infer never matches — a definition that recognises nothing names nothing.
18
+ const firstMatch = (subject, defs, scope) => {
19
+ for (const def of defs) {
20
+ if (def.infer != null && (0, queries_1.matches)(subject, def.infer, scope))
21
+ return def.name;
22
+ }
23
+ return null;
24
+ };
25
+ exports.firstMatch = firstMatch;
@@ -0,0 +1,25 @@
1
+ import { type FieldValue } from "./field";
2
+ interface LoadConfigsOptions {
3
+ repoRoot?: string;
4
+ configs?: Record<string, string>;
5
+ }
6
+ interface ConfigEntry {
7
+ path: string;
8
+ abs: string;
9
+ data: FieldValue;
10
+ }
11
+ interface ConfigIssue {
12
+ key: string;
13
+ path: string;
14
+ message?: string;
15
+ }
16
+ interface LoadConfigsResult {
17
+ values: Record<string, ConfigEntry | null>;
18
+ missing: ConfigIssue[];
19
+ errors: ConfigIssue[];
20
+ }
21
+ declare const loadConfigs: ({ repoRoot, configs }: LoadConfigsOptions) => LoadConfigsResult;
22
+ declare const configFacts: ({ values }: {
23
+ values: Record<string, ConfigEntry | null>;
24
+ }) => Record<string, FieldValue>;
25
+ export { loadConfigs, configFacts };
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.configFacts = exports.loadConfigs = void 0;
37
+ // The tool's own configs, declared in the ESLint RULE OPTIONS (and in the CLI
38
+ // flags) — never in `architecture.yaml`. The architecture says what the code may
39
+ // be; the rule says where its own inputs live:
40
+ //
41
+ // "md-code/follow-architecture": ["error", { configs: { tailwind: "…" } }]
42
+ //
43
+ // Two answers are the caller's business, not the rule's:
44
+ // missing — the key was declared and the file is not there
45
+ // errors — the file is there and cannot be read or parsed
46
+ // Both name the KEY and the PATH, because "no config" and "a config with nothing
47
+ // in it" produce the same wrong conclusions and must not look alike.
48
+ const fs = __importStar(require("node:fs"));
49
+ const path = __importStar(require("node:path"));
50
+ const node_module_1 = require("node:module");
51
+ const field_1 = require("./field");
52
+ // `require` for the runtime, taken from `node:module` so the config loader can
53
+ // still read a JS config module without the linter treating it as a require call.
54
+ const requireModule = (0, node_module_1.createRequire)(__filename);
55
+ // A JSON file is data; a JS module is data too — loaded by the runtime, not
56
+ // re-implemented here.
57
+ const readOf = (abs) => {
58
+ if (/\.json$/i.test(abs)) {
59
+ const parsed = JSON.parse(fs.readFileSync(abs, "utf8"));
60
+ return parsed;
61
+ }
62
+ // The module cache is fine for a config: it is read once per run.
63
+ const loaded = requireModule(abs);
64
+ return (0, field_1.isRecordValue)(loaded) && loaded.default !== undefined ? loaded.default : loaded;
65
+ };
66
+ const loadConfigs = ({ repoRoot, configs }) => {
67
+ const values = {};
68
+ const missing = [];
69
+ const errors = [];
70
+ for (const [key, rel] of Object.entries(configs ?? {})) {
71
+ const abs = path.isAbsolute(rel) ? rel : path.resolve(repoRoot ?? ".", rel);
72
+ if (!fs.existsSync(abs)) {
73
+ values[key] = null;
74
+ missing.push({ key, path: rel });
75
+ continue;
76
+ }
77
+ try {
78
+ values[key] = { path: rel, abs, data: readOf(abs) };
79
+ }
80
+ catch (error) {
81
+ const e = error;
82
+ values[key] = null;
83
+ errors.push({ key, path: rel, message: (e.message ?? "").split("\n")[0] });
84
+ }
85
+ }
86
+ return { values, missing, errors };
87
+ };
88
+ exports.loadConfigs = loadConfigs;
89
+ // What a rule sees: `configs.tailwind` is the data, `null` when a declared key
90
+ // could not be read, and the whole object absent when nothing was declared.
91
+ const configFacts = ({ values }) => {
92
+ const facts = {};
93
+ for (const [key, value] of Object.entries(values))
94
+ facts[key] = value ? value.data : null;
95
+ return facts;
96
+ };
97
+ exports.configFacts = configFacts;