@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,219 @@
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.MAX_FOLDER = exports.MAX_ZONE = exports.extendZone = exports.closureOf = exports.importersOf = exports.zoneOf = void 0;
37
+ // WHICH FILES A WARM RUN HAS TO READ AGAIN. The summary in the light section
38
+ // answers for the bytes of its own file, but not all of a file's facts are decided
39
+ // there: a type, a usage
40
+ // count or an import is answered by ANOTHER file, and a file that moved changes
41
+ // the answers of its neighbours. So freshness cannot be "the file's own hash
42
+ // matches" — the zone adds everything the change can reach: the imports (what
43
+ // this file reads), the importers (what reads this file) and, transitively, their
44
+ // neighbours, plus the folders those files sit in (a folder-level finding is a
45
+ // statement about the folder's members).
46
+ //
47
+ // A zone that has grown past `MAX_ZONE` files is no longer a neighbourhood: the
48
+ // change touched something everything depends on, and reading the whole scan
49
+ // again is both simpler and no slower.
50
+ //
51
+ // A file that DISAPPEARED is the one change the index cannot report: the index
52
+ // answers only for paths a run names, and the walk no longer names it. It is
53
+ // still visible through the survivors that imported it — those are stale anyway —
54
+ // and its own record is still in the index, which is what names the files IT
55
+ // pointed at: their answers ("who uses me") were decided by a file that no longer
56
+ // exists.
57
+ const fs = __importStar(require("node:fs"));
58
+ const path = __importStar(require("node:path"));
59
+ const fa_index_1 = require("./fa-index");
60
+ // Files read again in one run.
61
+ const MAX_ZONE = 200;
62
+ exports.MAX_ZONE = MAX_ZONE;
63
+ // A directory's own members are part of the zone, but a folder with more files
64
+ // than this is treated as "everything".
65
+ const MAX_FOLDER = 400;
66
+ exports.MAX_FOLDER = MAX_FOLDER;
67
+ // Importers of every file, from the summaries' dependency lists.
68
+ const importersOf = (light, relOf) => {
69
+ const out = new Map();
70
+ for (const [abs, entry] of light) {
71
+ const rel = relOf.get(abs);
72
+ if (rel === undefined)
73
+ continue;
74
+ for (const dep of entry.summary.deps) {
75
+ const list = out.get(dep) ?? [];
76
+ list.push(rel);
77
+ out.set(dep, list);
78
+ }
79
+ }
80
+ return out;
81
+ };
82
+ exports.importersOf = importersOf;
83
+ const expand = (out, queue, rels) => {
84
+ for (const rel of rels) {
85
+ if (out.has(rel))
86
+ continue;
87
+ out.add(rel);
88
+ queue.push(rel);
89
+ }
90
+ };
91
+ // The transitive closure of `seeds` over the given edge sets, stopping once the
92
+ // answer is already too large to be worth narrowing.
93
+ const closureOf = (seeds, edges, limit) => {
94
+ const out = new Set(seeds);
95
+ const queue = [...seeds];
96
+ for (let at = 0; at < queue.length && out.size <= limit; at += 1) {
97
+ for (const next of edges)
98
+ expand(out, queue, next(queue[at]));
99
+ }
100
+ return out;
101
+ };
102
+ exports.closureOf = closureOf;
103
+ // A folder's own members, or null when the folder is too large to treat as a zone.
104
+ const folderMates = (repoFiles, rels) => {
105
+ const dirs = new Set(rels.map((rel) => path.posix.dirname(rel)));
106
+ const out = [];
107
+ for (const rel of repoFiles)
108
+ if (dirs.has(path.posix.dirname(rel)))
109
+ out.push(rel);
110
+ return out.length > MAX_FOLDER ? null : out;
111
+ };
112
+ // A dependency that is not part of the scan is not a lost dependency: an import of
113
+ // `react` resolves into `node_modules`, and a file the scope excluded (another
114
+ // extension, an ignored folder) is still on disk. Only a path that the scan would
115
+ // have covered AND that is no longer there means the file went away.
116
+ const EXISTS = new Map();
117
+ const isGone = (root, rel, known) => {
118
+ if (known.has(rel))
119
+ return false;
120
+ const cached = EXISTS.get(rel);
121
+ if (cached !== undefined)
122
+ return cached;
123
+ const exists = fs.existsSync(path.resolve(root, rel));
124
+ EXISTS.set(rel, exists);
125
+ return !exists;
126
+ };
127
+ // The files that changed since the last run: no summary, a summary this tool
128
+ // cannot use, or one that names a dependency that is gone.
129
+ const staleOf = (args) => {
130
+ const { light, absFiles, repoFiles, root } = args;
131
+ const known = new Set(repoFiles);
132
+ const out = [];
133
+ for (let at = 0; at < absFiles.length; at += 1) {
134
+ const entry = light.get(absFiles[at]);
135
+ const fresh = entry !== undefined && !entry.summary.deps.some((dep) => isGone(root, dep, known));
136
+ if (!fresh)
137
+ out.push(repoFiles[at]);
138
+ }
139
+ return out;
140
+ };
141
+ // The files a gone file pointed at. `null` means the targets cannot be known (the
142
+ // index never held the gone file), and the caller then reads everything.
143
+ const lostTargets = (args) => {
144
+ const { index, light, repoFiles, root } = args;
145
+ const known = new Set(repoFiles);
146
+ const gone = new Set();
147
+ for (const entry of light.values()) {
148
+ for (const dep of entry.summary.deps)
149
+ if (isGone(root, dep, known))
150
+ gone.add(dep);
151
+ }
152
+ if (gone.size === 0)
153
+ return [];
154
+ const targets = [];
155
+ for (const rel of gone) {
156
+ const entry = (0, fa_index_1.lightAt)(index, path.resolve(root, rel));
157
+ if (entry === null)
158
+ return null;
159
+ targets.push(...entry.summary.deps);
160
+ }
161
+ return targets;
162
+ };
163
+ // A file the index has never seen brings facts nobody has read yet — and its
164
+ // imports are facts about OTHER files: an export it starts to use gains a
165
+ // reference, and a reference travels through barrels. So the added file's own
166
+ // dependencies join the zone, and so do theirs while new ones keep appearing.
167
+ // The reverse direction (a file that goes away) needs none of this: `zoneOf`
168
+ // already read the tombstone's deps.
169
+ const depsOfAdded = (added, depsOf, absOf, zone) => {
170
+ const extra = new Set();
171
+ for (const rel of added) {
172
+ for (const dep of depsOf(absOf.get(rel) ?? ""))
173
+ if (!zone.has(dep) && absOf.has(dep))
174
+ extra.add(dep);
175
+ }
176
+ return extra;
177
+ };
178
+ const extendZone = (args, extract) => {
179
+ const { zone, known, depsOf, absOf, repoFiles } = args;
180
+ let added = [...zone].filter((rel) => !known.has(absOf.get(rel) ?? ""));
181
+ let extracted = 0;
182
+ for (;;) {
183
+ const extra = depsOfAdded(added, depsOf, absOf, zone);
184
+ if (extra.size === 0)
185
+ return extracted;
186
+ if (zone.size + extra.size > MAX_ZONE) {
187
+ // The addition pulls in more than a neighbourhood: read everything.
188
+ for (const rel of repoFiles)
189
+ zone.add(rel);
190
+ return extracted + extract(zone);
191
+ }
192
+ for (const rel of extra)
193
+ zone.add(rel);
194
+ extracted += extract(extra);
195
+ added = [...extra];
196
+ }
197
+ };
198
+ exports.extendZone = extendZone;
199
+ // What must be read again, and how many files changed.
200
+ const zoneOf = (args) => {
201
+ const { index, light, absFiles, repoFiles, root } = args;
202
+ const stale = staleOf({ light, absFiles, repoFiles, root });
203
+ const absOf = new Map();
204
+ const relOf = new Map();
205
+ for (let at = 0; at < repoFiles.length; at += 1) {
206
+ absOf.set(repoFiles[at], absFiles[at]);
207
+ relOf.set(absFiles[at], repoFiles[at]);
208
+ }
209
+ const importers = importersOf(light, relOf);
210
+ const depsOfRel = (rel) => light.get(absOf.get(rel) ?? "")?.summary.deps ?? [];
211
+ const importersOfRel = (rel) => importers.get(rel) ?? [];
212
+ const lost = lostTargets({ index, light, repoFiles, root });
213
+ const seeds = lost === null ? [...repoFiles] : [...stale, ...lost];
214
+ const widened = closureOf(seeds, [depsOfRel, importersOfRel], MAX_ZONE);
215
+ const mates = folderMates(repoFiles, [...widened]);
216
+ const zone = mates === null ? new Set(repoFiles) : new Set([...widened, ...mates]);
217
+ return { zone, stale: stale.length };
218
+ };
219
+ exports.zoneOf = zoneOf;
package/dist/main.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { type Args } from "./args";
2
+ import type { Arch, RawArch } from "./entities/architecture";
3
+ import type { RuleOptions } from "./config-options";
4
+ type ArchSections = Pick<RawArch, "nodes" | "entities" | "rules" | "aliases" | "report">;
5
+ declare const buildArchitecture: (raw: ArchSections | null | undefined) => Arch;
6
+ declare const loadArchitecture: (config: string | RawArch | RuleOptions | null | undefined) => Arch;
7
+ declare const canonicalRoot: (dir: string) => string;
8
+ declare const repoOf: (args: Args, cwd: string) => string;
9
+ declare const main: (argv: string[]) => number;
10
+ export { main, loadArchitecture, buildArchitecture, canonicalRoot, repoOf };
package/dist/main.js ADDED
@@ -0,0 +1,411 @@
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.repoOf = exports.canonicalRoot = exports.buildArchitecture = exports.loadArchitecture = exports.main = void 0;
37
+ const fs = __importStar(require("node:fs"));
38
+ const path = __importStar(require("node:path"));
39
+ const remeda_1 = require("remeda");
40
+ const tree_1 = require("./entities/tree");
41
+ const entities_1 = require("./code-entities/entities");
42
+ const normalize_1 = require("./rules/normalize");
43
+ const aliases_1 = require("./aliases");
44
+ const pipeline_1 = require("./pipeline");
45
+ const index_run_1 = require("./index-run");
46
+ const usage_prepare_1 = require("./usage-prepare");
47
+ const fa_store_1 = require("./fa-store");
48
+ const pattern_1 = require("./utils/pattern");
49
+ const cli_report_1 = require("./report/cli-report");
50
+ const scan_run_1 = require("./scan-run");
51
+ const notices_1 = require("./report/notices");
52
+ const user_report_1 = require("./report/user-report");
53
+ const imports_1 = require("./utils/imports");
54
+ const files_1 = require("./utils/files");
55
+ const args_1 = require("./args");
56
+ const keyed_1 = require("./utils/keyed");
57
+ const field_1 = require("./utils/field");
58
+ const schema_1 = require("./entities/schema");
59
+ const configError = __importStar(require("./report/configErrors"));
60
+ const yaml = __importStar(require("js-yaml"));
61
+ // The report layer owns its payload; the input contract is the ONE entity
62
+ // (`entities/overview`), so the rule path and the CLI hand it the same shape.
63
+ const collectOverviewData = user_report_1.collectOverviewData;
64
+ const writeOverview = user_report_1.writeOverview;
65
+ // The nodes section as a list — the shared list-or-map walk, the same one the
66
+ // tree builder reads.
67
+ const nodesOf = (raw) => (0, keyed_1.keyedDefs)(raw.nodes).filter((n) => n != null);
68
+ // Every rule id must be unique, and every entity a node names must exist —
69
+ // a typo would otherwise give a home to an entity nothing ever infers.
70
+ const checkBuilt = (arch) => {
71
+ const ids = arch.rules.map((i) => i.id);
72
+ if (new Set(ids).size !== ids.length)
73
+ throw configError.duplicateRuleIds(ids);
74
+ const known = new Set(Object.keys(arch.entities));
75
+ for (const entity of Object.keys(arch.nodes.entityHomes)) {
76
+ if (!known.has(entity))
77
+ throw configError.nodeEntityUnknown(entity);
78
+ }
79
+ };
80
+ // The tool's own option keys travel in the same bag as the architecture
81
+ // sections (the ESLint rule hands both). They are not sections, and are not
82
+ // shown in the section dictionary.
83
+ const TOOL_KEYS = new Set([
84
+ "config",
85
+ "configs",
86
+ "include",
87
+ "exts",
88
+ "similarity",
89
+ "barrelDepth",
90
+ "ignoreDirs",
91
+ "ignores",
92
+ "exportPath",
93
+ "file",
94
+ "report",
95
+ ]);
96
+ // Old vocabulary is rejected BY NAME — the reader is shown the sections and
97
+ // their meanings, never a guess at what an old key used to mean. `role` on a
98
+ // node or in a `where` entry, `codeRole` as a filter key, and `$codeRole` as a
99
+ // reference are all caught here, before any normalizer can silently ignore them.
100
+ const walkVocabulary = (value) => {
101
+ if (typeof value === "string") {
102
+ if (value.includes("$codeRole"))
103
+ throw configError.legacyReference({ ref: "$codeRole" });
104
+ return;
105
+ }
106
+ if (Array.isArray(value)) {
107
+ for (const item of value)
108
+ walkVocabulary(item);
109
+ return;
110
+ }
111
+ if (!(0, field_1.isObj)(value))
112
+ return;
113
+ for (const [key, item] of Object.entries(value)) {
114
+ if (key === "role")
115
+ throw configError.legacyRoleKey();
116
+ if (key === "codeRole")
117
+ throw configError.legacyFilterKey();
118
+ walkVocabulary(item);
119
+ }
120
+ };
121
+ const assertCurrentVocabulary = (raw) => {
122
+ for (const key of Object.keys(raw)) {
123
+ if (schema_1.SCHEMA.top.includes(key) || TOOL_KEYS.has(key))
124
+ continue;
125
+ throw configError.unknownTopKey({ key });
126
+ }
127
+ walkVocabulary(raw);
128
+ };
129
+ const buildArchitecture = (raw) => {
130
+ if (!(0, field_1.isObj)(raw))
131
+ throw configError.notAnObject();
132
+ const config = raw;
133
+ assertCurrentVocabulary(config);
134
+ if (!nodesOf(config).length)
135
+ throw configError.withoutNodes();
136
+ // The alias map is read ONCE, before anything that can name a place: node
137
+ // names, rule globs, `location` filters and the import resolver all ask the
138
+ // same `utils/aliases` reader, so a specifier means the same everywhere.
139
+ const aliases = (0, aliases_1.normalizeAliases)(config.aliases ?? {});
140
+ const entities = config.entities ? (0, entities_1.normalizeEntities)(config.entities, aliases) : {};
141
+ const tree = (0, tree_1.buildTree)(config.nodes, aliases);
142
+ const rules = (0, remeda_1.pipe)(config.rules ?? [], (0, remeda_1.map)((i) => (0, normalize_1.normalizeRule)(i, new Set(Object.keys(entities)), aliases)));
143
+ const arch = {
144
+ nodes: tree,
145
+ entities,
146
+ rules,
147
+ aliases,
148
+ // The config as written, for consumers that show it back (the overview).
149
+ raw: config,
150
+ };
151
+ checkBuilt(arch);
152
+ return arch;
153
+ };
154
+ exports.buildArchitecture = buildArchitecture;
155
+ // An architecture file is DATA — YAML or JSON. JSON is valid YAML, so the
156
+ // extension decides nothing and there is ONE parser. The parser's answer is
157
+ // plain data; the typed view is taken here at the boundary (the same pattern
158
+ // the tree uses for the structure renders), and `buildArchitecture` validates
159
+ // it — a non-object is not a config, and says so.
160
+ const parseArchitecture = (text, file) => {
161
+ try {
162
+ const loaded = yaml.load(text, { filename: file });
163
+ return loaded;
164
+ }
165
+ catch (error) {
166
+ const e = error;
167
+ throw configError.unparseable({ reason: describeParse(e) });
168
+ }
169
+ };
170
+ // Where the file itself is wrong — a missing comma, a tab used as indentation.
171
+ // The parser knows the position; the reader needs it, so it travels in the
172
+ // sentence.
173
+ const describeParse = (error) => {
174
+ const reason = String(error.reason ?? error.message ?? error).split("\n")[0];
175
+ const at = error.mark ? ` (line ${error.mark.line + 1}, column ${error.mark.column + 1})` : "";
176
+ return `${reason}${at}`;
177
+ };
178
+ // Every failure between "here is a path" and "here is a usable architecture"
179
+ // happens inside ONE call, so the file is named in ONE place: the sentence says
180
+ // what the key claims, but only the path says which architecture to open. A
181
+ // config error stays a sentence; a bug keeps its stack and never pretends to be
182
+ // about the config.
183
+ const naming = (file, run) => {
184
+ try {
185
+ return run();
186
+ }
187
+ catch (error) {
188
+ const e = error;
189
+ if (e.isConfigError)
190
+ e.message = `${e.message}\n in ${file}`;
191
+ throw error;
192
+ }
193
+ };
194
+ const readConfigText = (file) => {
195
+ try {
196
+ return fs.readFileSync(file, "utf8");
197
+ }
198
+ catch (error) {
199
+ const e = error;
200
+ throw configError.unreadable({ code: e.code });
201
+ }
202
+ };
203
+ // A config may arrive as a path, as the raw object, or as the rule's own
204
+ // options bag (which carries the architecture's sections beside the tool's).
205
+ // All three are read here: a `file` key names a path to load; anything else is
206
+ // built from the sections it carries. The sections view is taken at this
207
+ // boundary — the record's keys are the data the normalizers validate.
208
+ const loadArchitecture = (config) => {
209
+ if ((0, field_1.isObj)(config) && typeof config.file === "string")
210
+ return loadArchitecture(config.file);
211
+ if (typeof config !== "string") {
212
+ const sections = config ?? {};
213
+ return buildArchitecture(sections);
214
+ }
215
+ const file = path.resolve(process.cwd(), config);
216
+ return naming(file, () => buildArchitecture(parseArchitecture(readConfigText(file), file)));
217
+ };
218
+ exports.loadArchitecture = loadArchitecture;
219
+ // `--barrel-depth <n>`: a positive integer, or the reader is told why not.
220
+ const barrelDepthArg = (raw) => {
221
+ const depth = Number(raw);
222
+ if (!Number.isInteger(depth) || depth < 1)
223
+ throw configError.limitNotPositiveInteger({ key: "--barrel-depth", value: raw });
224
+ return depth;
225
+ };
226
+ // One `--files` entry: a FILE, or a FOLDER with the scanned files it holds.
227
+ // A folder used to match nothing — the entry was dropped for not being a file and
228
+ // the report came back empty. `scanned` is the universe, so a folder can never
229
+ // pull in a file the scan does not read.
230
+ const filesOfEntry = (repoRoot, scanned, entry) => {
231
+ const abs = path.resolve(repoRoot, entry);
232
+ if (!fs.existsSync(abs))
233
+ return [];
234
+ if (fs.statSync(abs).isFile())
235
+ return [abs];
236
+ const prefix = abs.endsWith(path.sep) ? abs : `${abs}${path.sep}`;
237
+ return scanned.filter((file) => file.startsWith(prefix));
238
+ };
239
+ // The files a run checks: `--files` restricts the scan to the given files
240
+ // (agent stop-hooks lint only changed files); otherwise every scanned file.
241
+ const collectedFiles = (repoRoot, scanned, files) => {
242
+ if (files.length) {
243
+ return (0, remeda_1.pipe)(files, (0, remeda_1.flatMap)((entry) => filesOfEntry(repoRoot, scanned, entry)), (0, remeda_1.map)((abs) => ({ abs, rel: (0, imports_1.toRel)(repoRoot, abs) })));
244
+ }
245
+ return (0, remeda_1.pipe)(scanned, (0, remeda_1.map)((abs) => ({ abs, rel: (0, imports_1.toRel)(repoRoot, abs) })));
246
+ };
247
+ // The run's findings: every checked file, one shared dedupe store. The files are
248
+ // checked against the ONE project over the scan — `references` asks across files,
249
+ // so a per-file project would answer "nobody uses this" for a name the rest of
250
+ // the repo calls.
251
+ // What the index did, for `FA_INDEX_VERBOSE`; a failed write is always reported,
252
+ // because the run then keeps its findings but forgets them.
253
+ const reportIndex = (stats, file) => {
254
+ if (process.env.FA_INDEX_VERBOSE) {
255
+ console.error(`fa index: ${stats.mode} stale=${stats.stale} zone=${stats.zone} extracted=${stats.extracted} written=${stats.written} chunks=${stats.chunks} compacted=${stats.compactions} pruned=${stats.pruned} bytes=${stats.bytes}`);
256
+ }
257
+ if (stats.warning !== null)
258
+ console.error(`follow-architecture: ${stats.warning}`);
259
+ // Not a failure: the records are in the file and the file keeps its size. Said
260
+ // once per run, in the index's words, only when there is a file to name.
261
+ if (stats.compactionWarning !== null && file !== undefined)
262
+ console.error(`follow-architecture: ${(0, fa_store_1.compactionLine)(file, stats.compactionWarning)}`);
263
+ };
264
+ // The files `--files` named that the scan never saw: those are checked the plain
265
+ // way, because nothing about them is in the index.
266
+ const outsideOf = (files, shouldCheck, inside) => (0, remeda_1.pipe)(files, (0, remeda_1.filter)((f) => shouldCheck(f.rel) && !inside.has(f.abs)));
267
+ const runFindings = (files, run) => {
268
+ const dedupe = new Map();
269
+ // The scan's own answers first: with an index the run reads what it already
270
+ // knows and only looks at what changed. Null means this run has no usable
271
+ // index, and the plain path below reads every file.
272
+ // `--files` narrows what is REPORTED, not what the repo answers: the index still
273
+ // covers every scanned file, so a dependency outside the list is still known.
274
+ const reported = new Set((0, remeda_1.pipe)(files, (0, remeda_1.filter)((f) => run.shouldCheck(f.rel)), (0, remeda_1.map)((f) => f.rel)));
275
+ const indexed = (0, index_run_1.runIndexed)({
276
+ arch: run.arch,
277
+ repoFiles: run.repoFiles,
278
+ absFiles: run.scanned,
279
+ scope: run.scope,
280
+ option: run.index,
281
+ usage: run.usage,
282
+ dedupe,
283
+ shouldCheck: (abs) => reported.has((0, imports_1.toRel)(run.arch.repoRoot ?? ".", abs)),
284
+ });
285
+ if (indexed !== null)
286
+ reportIndex(indexed.stats, run.index);
287
+ // Who answers `references`, and — for the plain path below, which reads every
288
+ // file — the name counts that answer it without a project.
289
+ (0, usage_prepare_1.prepareUsage)(run.usage, run.arch.repoRoot ?? ".", run.repoFiles);
290
+ const project = (0, scan_run_1.wholeRepoProject)();
291
+ // `--files` may name a file outside the scan scope: that one is checked the
292
+ // plain way, exactly as before.
293
+ const inside = new Set(run.scanned);
294
+ const outside = indexed === null ? [] : outsideOf(files, run.shouldCheck, inside);
295
+ const findings = indexed !== null
296
+ ? [
297
+ ...indexed.findings,
298
+ ...(0, remeda_1.pipe)(outside, (0, remeda_1.flatMap)((f) => (0, pipeline_1.checkFile)(f.abs, run.arch, project, run.repoFiles, dedupe))),
299
+ ]
300
+ : (0, remeda_1.pipe)(files, (0, remeda_1.filter)((f) => run.shouldCheck(f.rel)), (0, remeda_1.flatMap)((f) => (0, pipeline_1.checkFile)(f.abs, run.arch, project, run.repoFiles, dedupe)));
301
+ const orphans = (0, remeda_1.pipe)(files, (0, remeda_1.filter)((f) => !run.shouldCheck(f.rel)), (0, remeda_1.map)((f) => f.rel), (r) => [...r].sort());
302
+ return { findings, orphans };
303
+ };
304
+ const writeOverviewReport = (args, run) => {
305
+ const data = collectOverviewData({
306
+ arch: run.arch,
307
+ findings: run.findings,
308
+ orphans: run.orphans,
309
+ files: run.repoFiles,
310
+ repoFiles: run.repoFiles,
311
+ repoRoot: run.repoRoot,
312
+ architecturePath: typeof run.configPath === "string" ? run.configPath : null,
313
+ project: run.project,
314
+ });
315
+ const written = writeOverview(data, path.resolve(run.repoRoot, args.overview));
316
+ console.log(`wrote ${path.relative(run.repoRoot, written.path)} (${run.findings.length} findings, ${Math.round(written.bytes / 1024)} kB)`);
317
+ const caveats = (0, cli_report_1.renderNotices)((0, notices_1.takeNotices)());
318
+ if (caveats)
319
+ console.log(caveats);
320
+ return args.check && run.findings.length > 0 ? 1 : 0;
321
+ };
322
+ const writeTextReport = (args, run) => {
323
+ const rewritten = (0, cli_report_1.renderReport)(run.findings, run.repoRoot, { orphans: run.orphans });
324
+ const text = `${rewritten}${(0, cli_report_1.renderNotices)((0, notices_1.takeNotices)())}`;
325
+ if (args.out) {
326
+ fs.writeFileSync(args.out, text);
327
+ console.log(`wrote ${args.out} (${run.findings.length} findings)`);
328
+ }
329
+ else {
330
+ console.log(text);
331
+ }
332
+ return args.check && run.findings.length > 0 ? 1 : 0;
333
+ };
334
+ const configOf = (args, cwd) => typeof args.config === "string" ? path.resolve(cwd, args.config) : args.config;
335
+ // ONE DIRECTORY, ONE NAME. The index is keyed by the repo root, and the same
336
+ // directory answers to several names: a symlinked home reaches it as `/home/...`
337
+ // or as `/var/home/...`, and the CLI and the editor's server each pick their own.
338
+ // An index written under one spelling was foreign under the other, so the rule
339
+ // silently re-read the whole repo on its first pull — a `--config` path the shell
340
+ // spelled one way and the server another were two repos. Both entry points
341
+ // canonicalise the root BEFORE it becomes a file path, so the file, the header and
342
+ // every abs path in it agree.
343
+ const canonicalRoot = (dir) => {
344
+ try {
345
+ return fs.realpathSync(dir);
346
+ }
347
+ catch {
348
+ return dir;
349
+ }
350
+ };
351
+ exports.canonicalRoot = canonicalRoot;
352
+ // The repo starts where the architecture file is — the SAME anchor the ESLint
353
+ // rule uses — so `--config ../arch.yaml` scans the repo that file describes.
354
+ // An explicit `--cwd` still decides where the scan begins.
355
+ const repoOf = (args, cwd) => {
356
+ if (typeof args.config !== "string" || args.cwd != null)
357
+ return canonicalRoot(cwd);
358
+ return canonicalRoot(path.dirname(path.resolve(cwd, args.config)));
359
+ };
360
+ exports.repoOf = repoOf;
361
+ const main = (argv) => {
362
+ const args = (0, args_1.parseArgs)(argv);
363
+ if (args.help) {
364
+ console.log("usage: follow-architecture [--config <path>] [--ext <.ext>]... [--ignore <glob>]... [--ignore-dir <name>]... [--files <path>]... [--out <path>] [--overview [path]] [--index <path|off>] [--usage <checker|index>] [--barrel-depth <n>] [--check]");
365
+ return 0;
366
+ }
367
+ const cwd = path.resolve(args.cwd ?? process.cwd());
368
+ const configPath = configOf(args, cwd);
369
+ const repoRoot = repoOf(args, cwd);
370
+ const arch = loadArchitecture(configPath);
371
+ arch.repoRoot = repoRoot;
372
+ // How far a name may travel through barrels before the walk stops. A TOOL
373
+ // option (`--barrel-depth`, the rule's `barrelDepth`), never a config section:
374
+ // where a name is judged is the law, not a per-repo budget.
375
+ if (args.barrelDepth !== undefined)
376
+ arch.barrelDepth = barrelDepthArg(args.barrelDepth);
377
+ const shouldCheck = (0, tree_1.matchers)(arch);
378
+ // Scan scope is the TOOL's: its defaults, extended by `--ext`, never by the
379
+ // architecture (which describes code, not how to find it).
380
+ const exts = [...new Set([...pattern_1.DEFAULT_EXTS, ...(args.ext ?? [])])];
381
+ const ignoreDirs = [...new Set([...pattern_1.DEFAULT_IGNORE_DIRS, ...(args.ignoreDir ?? [])])];
382
+ // Repo-relative paths the tool does not read at all — the apps, the platform
383
+ // packages and the tooling outside the contract — extended by `--ignore`.
384
+ const ignoreGlobs = [...new Set([...pattern_1.DEFAULT_IGNORE_PATHS, ...(args.ignore ?? [])])];
385
+ // ONE walk: the scan list, the repo file list and the ts-morph project are the
386
+ // same set of files. `references` asks who uses a name ACROSS files.
387
+ const scanned = (0, files_1.collectFiles)(repoRoot, { exts, ignoreDirs, ignoreGlobs });
388
+ // The scan's file list decides which project holds what: per-file work reads the
389
+ // shards this run opens, whole-repo questions read the one project over `scanned`.
390
+ (0, scan_run_1.openRun)({ repoRoot, arch, absFiles: scanned });
391
+ const collected = collectedFiles(repoRoot, scanned, args.files);
392
+ // `repoFiles` is the FULL repo file list (for import resolution and folder
393
+ // facts), even when `--files` restricts which files are CHECKED.
394
+ const repoFiles = (0, remeda_1.pipe)(scanned, (0, remeda_1.map)((abs) => (0, imports_1.toRel)(repoRoot, abs)));
395
+ const scope = { exts, ignoreDirs, ignoreGlobs };
396
+ const { findings, orphans } = runFindings(collected, {
397
+ arch,
398
+ repoFiles,
399
+ shouldCheck,
400
+ scanned,
401
+ scope,
402
+ index: args.index,
403
+ usage: args.usage,
404
+ });
405
+ const code = args.overview
406
+ ? writeOverviewReport({ overview: args.overview, check: args.check }, { arch, findings, orphans, repoFiles, repoRoot, configPath, project: (0, scan_run_1.wholeRepoProject)() })
407
+ : writeTextReport({ out: args.out, check: args.check }, { findings, orphans, repoRoot });
408
+ (0, scan_run_1.endRun)();
409
+ return code;
410
+ };
411
+ exports.main = main;
@@ -0,0 +1,3 @@
1
+ import type { Arch, ArchChild } from "@md-code/follow-architecture/entities/architecture";
2
+ declare const entitiesOfChild: (arch: Arch, child: ArchChild | null | undefined) => string[];
3
+ export { entitiesOfChild };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.entitiesOfChild = void 0;
4
+ const entitiesOfChild = (arch, child) => {
5
+ if (!child)
6
+ return [];
7
+ if (child.entities?.length)
8
+ return child.entities;
9
+ const target = child.nodeSlug ? arch.nodes.bySlug[child.nodeSlug] : null;
10
+ return target?.entities ?? [];
11
+ };
12
+ exports.entitiesOfChild = entitiesOfChild;