@repometry/cli 0.0.0-stage → 0.1.0

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 (415) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +70 -2
  3. package/package.json +75 -4
  4. package/target/main/resources/language-catalog.json +77 -0
  5. package/target/main/resources/report/json/compact-json-v1.schema.json +24 -0
  6. package/target/main/resources/report/json/comparison-v1.schema.json +65 -0
  7. package/target/main/resources/report/json/config-v2.schema.json +224 -0
  8. package/target/main/resources/report/json/diff-coverage-v1.schema.json +55 -0
  9. package/target/main/resources/report/json/file-metrics-v1.schema.json +157 -0
  10. package/target/main/resources/report/json/metabranch-v1.schema.json +9 -0
  11. package/target/main/resources/report/json/metric-catalog-v1.schema.json +31 -0
  12. package/target/main/resources/report/json/pull-review-v1.schema.json +97 -0
  13. package/target/main/resources/report/json/pull-review-v2.schema.json +100 -0
  14. package/target/main/resources/report/json/report-v2.schema.json +534 -0
  15. package/target/main/resources/report/json/repository-summary-v1.schema.json +341 -0
  16. package/target/main/resources/report/json/viewer-inspection-v1.schema.json +534 -0
  17. package/target/main/resources/viewer/files.css +616 -0
  18. package/target/main/resources/viewer/index.html +120 -0
  19. package/target/main/resources/viewer/projects.html +52 -0
  20. package/target/main/resources/viewer/styles.css +579 -0
  21. package/target/main/resources/viewer/viewer-pulls.css +64 -0
  22. package/target/main/ts/api/cache/root.d.ts +2 -0
  23. package/target/main/ts/api/cache/root.js +21 -0
  24. package/target/main/ts/api/gh/github.d.ts +4 -0
  25. package/target/main/ts/api/gh/github.js +47 -0
  26. package/target/main/ts/api/git/blob-batch.d.ts +10 -0
  27. package/target/main/ts/api/git/blob-batch.js +107 -0
  28. package/target/main/ts/api/git/blob-history.d.ts +20 -0
  29. package/target/main/ts/api/git/blob-history.js +54 -0
  30. package/target/main/ts/api/git/changes.d.ts +27 -0
  31. package/target/main/ts/api/git/changes.js +117 -0
  32. package/target/main/ts/api/git/commit-metadata.d.ts +2 -0
  33. package/target/main/ts/api/git/commit-metadata.js +46 -0
  34. package/target/main/ts/api/git/git-churn.d.ts +9 -0
  35. package/target/main/ts/api/git/git-churn.js +72 -0
  36. package/target/main/ts/api/git/git-executable.d.ts +1 -0
  37. package/target/main/ts/api/git/git-executable.js +31 -0
  38. package/target/main/ts/api/git/git-reader.d.ts +24 -0
  39. package/target/main/ts/api/git/git-reader.js +113 -0
  40. package/target/main/ts/api/git/git.d.ts +47 -0
  41. package/target/main/ts/api/git/git.js +289 -0
  42. package/target/main/ts/api/git/inspection-source.d.ts +17 -0
  43. package/target/main/ts/api/git/inspection-source.js +36 -0
  44. package/target/main/ts/api/git/line-changes.d.ts +6 -0
  45. package/target/main/ts/api/git/line-changes.js +57 -0
  46. package/target/main/ts/api/git/local-sources.d.ts +5 -0
  47. package/target/main/ts/api/git/local-sources.js +48 -0
  48. package/target/main/ts/api/git/local.d.ts +7 -0
  49. package/target/main/ts/api/git/local.js +106 -0
  50. package/target/main/ts/api/git/source-cache.d.ts +1 -0
  51. package/target/main/ts/api/git/source-cache.js +42 -0
  52. package/target/main/ts/api/import/cobertura.d.ts +2 -0
  53. package/target/main/ts/api/import/cobertura.js +160 -0
  54. package/target/main/ts/api/import/coverage-xml.d.ts +7 -0
  55. package/target/main/ts/api/import/coverage-xml.js +135 -0
  56. package/target/main/ts/api/import/finding-import.d.ts +9 -0
  57. package/target/main/ts/api/import/finding-import.js +227 -0
  58. package/target/main/ts/api/import/go-cover.d.ts +13 -0
  59. package/target/main/ts/api/import/go-cover.js +150 -0
  60. package/target/main/ts/api/import/lcov-files.d.ts +12 -0
  61. package/target/main/ts/api/import/lcov-files.js +53 -0
  62. package/target/main/ts/api/import/profile-file.d.ts +4 -0
  63. package/target/main/ts/api/import/profile-file.js +17 -0
  64. package/target/main/ts/api/process/docker-tool-runner.d.ts +13 -0
  65. package/target/main/ts/api/process/docker-tool-runner.js +92 -0
  66. package/target/main/ts/api/process/failure.d.ts +1 -0
  67. package/target/main/ts/api/process/failure.js +12 -0
  68. package/target/main/ts/api/process/plugin.d.ts +13 -0
  69. package/target/main/ts/api/process/plugin.js +100 -0
  70. package/target/main/ts/api/process/tool-snapshot.d.ts +3 -0
  71. package/target/main/ts/api/process/tool-snapshot.js +26 -0
  72. package/target/main/ts/cli/arguments.d.ts +28 -0
  73. package/target/main/ts/cli/arguments.js +109 -0
  74. package/target/main/ts/cli/config.d.ts +63 -0
  75. package/target/main/ts/cli/config.js +165 -0
  76. package/target/main/ts/cli/imports.d.ts +9 -0
  77. package/target/main/ts/cli/imports.js +37 -0
  78. package/target/main/ts/cli/main.d.ts +2 -0
  79. package/target/main/ts/cli/main.js +4 -0
  80. package/target/main/ts/cli/range-inspection.d.ts +38 -0
  81. package/target/main/ts/cli/range-inspection.js +34 -0
  82. package/target/main/ts/cli/range-jobs.d.ts +23 -0
  83. package/target/main/ts/cli/range-jobs.js +152 -0
  84. package/target/main/ts/cli/range-worker.d.ts +1 -0
  85. package/target/main/ts/cli/range-worker.js +40 -0
  86. package/target/main/ts/cli/reporting.d.ts +42 -0
  87. package/target/main/ts/cli/reporting.js +98 -0
  88. package/target/main/ts/cli/revisions.d.ts +6 -0
  89. package/target/main/ts/cli/revisions.js +16 -0
  90. package/target/main/ts/cli/run.d.ts +2 -0
  91. package/target/main/ts/cli/run.js +306 -0
  92. package/target/main/ts/cli/store.d.ts +13 -0
  93. package/target/main/ts/cli/store.js +39 -0
  94. package/target/main/ts/compose/analysis-report.d.ts +6 -0
  95. package/target/main/ts/compose/analysis-report.js +132 -0
  96. package/target/main/ts/compose/analysis-results.d.ts +46 -0
  97. package/target/main/ts/compose/analysis-results.js +119 -0
  98. package/target/main/ts/compose/analysis-steps.d.ts +23 -0
  99. package/target/main/ts/compose/analysis-steps.js +217 -0
  100. package/target/main/ts/compose/analyze-snapshot.d.ts +7 -0
  101. package/target/main/ts/compose/analyze-snapshot.js +21 -0
  102. package/target/main/ts/compose/attach-churn.d.ts +2 -0
  103. package/target/main/ts/compose/attach-churn.js +50 -0
  104. package/target/main/ts/compose/built-ins.d.ts +6 -0
  105. package/target/main/ts/compose/built-ins.js +12 -0
  106. package/target/main/ts/compose/diff-coverage.d.ts +25 -0
  107. package/target/main/ts/compose/diff-coverage.js +82 -0
  108. package/target/main/ts/compose/distribution.d.ts +17 -0
  109. package/target/main/ts/compose/distribution.js +13 -0
  110. package/target/main/ts/compose/docker-image.d.ts +5 -0
  111. package/target/main/ts/compose/docker-image.js +49 -0
  112. package/target/main/ts/compose/file-selection.d.ts +9 -0
  113. package/target/main/ts/compose/file-selection.js +38 -0
  114. package/target/main/ts/compose/history-cache.d.ts +31 -0
  115. package/target/main/ts/compose/history-cache.js +62 -0
  116. package/target/main/ts/compose/inspect.d.ts +34 -0
  117. package/target/main/ts/compose/inspect.js +51 -0
  118. package/target/main/ts/compose/inspection-coverage.d.ts +9 -0
  119. package/target/main/ts/compose/inspection-coverage.js +9 -0
  120. package/target/main/ts/compose/js-plugin.d.ts +113 -0
  121. package/target/main/ts/compose/js-plugin.js +99 -0
  122. package/target/main/ts/compose/language-discovery.d.ts +12 -0
  123. package/target/main/ts/compose/language-discovery.js +51 -0
  124. package/target/main/ts/compose/languages.d.ts +64 -0
  125. package/target/main/ts/compose/languages.js +98 -0
  126. package/target/main/ts/compose/load-plugins.d.ts +6 -0
  127. package/target/main/ts/compose/load-plugins.js +71 -0
  128. package/target/main/ts/compose/parser-order.d.ts +20 -0
  129. package/target/main/ts/compose/parser-order.js +90 -0
  130. package/target/main/ts/compose/phases.d.ts +140 -0
  131. package/target/main/ts/compose/phases.js +147 -0
  132. package/target/main/ts/compose/plugin-list.d.ts +37 -0
  133. package/target/main/ts/compose/plugin-list.js +30 -0
  134. package/target/main/ts/compose/plugin-manifest.d.ts +14 -0
  135. package/target/main/ts/compose/plugin-manifest.js +50 -0
  136. package/target/main/ts/compose/plugin-options.d.ts +2 -0
  137. package/target/main/ts/compose/plugin-options.js +29 -0
  138. package/target/main/ts/compose/plugin-reference.d.ts +9 -0
  139. package/target/main/ts/compose/plugin-reference.js +40 -0
  140. package/target/main/ts/compose/plugin-requirements.d.ts +5 -0
  141. package/target/main/ts/compose/plugin-requirements.js +83 -0
  142. package/target/main/ts/compose/plugin-scope.d.ts +9 -0
  143. package/target/main/ts/compose/plugin-scope.js +60 -0
  144. package/target/main/ts/compose/process-plugins.d.ts +89 -0
  145. package/target/main/ts/compose/process-plugins.js +74 -0
  146. package/target/main/ts/compose/registered-plugin.d.ts +17 -0
  147. package/target/main/ts/compose/registered-plugin.js +8 -0
  148. package/target/main/ts/compose/review.d.ts +26 -0
  149. package/target/main/ts/compose/review.js +54 -0
  150. package/target/main/ts/compose/schema-error.d.ts +2 -0
  151. package/target/main/ts/compose/schema-error.js +16 -0
  152. package/target/main/ts/compose/sources.d.ts +2 -0
  153. package/target/main/ts/compose/sources.js +32 -0
  154. package/target/main/ts/compose/structure-measures.d.ts +9 -0
  155. package/target/main/ts/compose/structure-measures.js +63 -0
  156. package/target/main/ts/index.d.ts +8 -0
  157. package/target/main/ts/index.js +5 -0
  158. package/target/main/ts/plugin.d.ts +2 -0
  159. package/target/main/ts/plugin.js +2 -0
  160. package/target/main/ts/plugins/built-in.d.ts +3 -0
  161. package/target/main/ts/plugins/built-in.js +19 -0
  162. package/target/main/ts/plugins/coverage/coverage.d.ts +11 -0
  163. package/target/main/ts/plugins/coverage/coverage.js +289 -0
  164. package/target/main/ts/plugins/coverage/diff-coverage.d.ts +3 -0
  165. package/target/main/ts/plugins/coverage/diff-coverage.js +85 -0
  166. package/target/main/ts/plugins/duplication/duplication.d.ts +2 -0
  167. package/target/main/ts/plugins/duplication/duplication.js +95 -0
  168. package/target/main/ts/plugins/language-js/babel-provider.d.ts +10 -0
  169. package/target/main/ts/plugins/language-js/babel-provider.js +54 -0
  170. package/target/main/ts/plugins/language-js/clone-candidates.d.ts +3 -0
  171. package/target/main/ts/plugins/language-js/clone-candidates.js +65 -0
  172. package/target/main/ts/plugins/language-js/code-lines.d.ts +6 -0
  173. package/target/main/ts/plugins/language-js/code-lines.js +36 -0
  174. package/target/main/ts/plugins/language-js/extensions.d.ts +1 -0
  175. package/target/main/ts/plugins/language-js/extensions.js +3 -0
  176. package/target/main/ts/plugins/language-js/function-facts.d.ts +9 -0
  177. package/target/main/ts/plugins/language-js/function-facts.js +74 -0
  178. package/target/main/ts/plugins/language-js/js-security.d.ts +4 -0
  179. package/target/main/ts/plugins/language-js/js-security.js +497 -0
  180. package/target/main/ts/plugins/language-js/qualified-names.d.ts +11 -0
  181. package/target/main/ts/plugins/language-js/qualified-names.js +63 -0
  182. package/target/main/ts/plugins/language-js/structural-observations.d.ts +9 -0
  183. package/target/main/ts/plugins/language-js/structural-observations.js +85 -0
  184. package/target/main/ts/plugins/language-js/syntax.d.ts +2 -0
  185. package/target/main/ts/plugins/language-js/syntax.js +11 -0
  186. package/target/main/ts/plugins/maintainability/maintainability.d.ts +2 -0
  187. package/target/main/ts/plugins/maintainability/maintainability.js +38 -0
  188. package/target/main/ts/plugins/maintainability/structural-smells.d.ts +3 -0
  189. package/target/main/ts/plugins/maintainability/structural-smells.js +17 -0
  190. package/target/main/ts/plugins/security/actions-security.d.ts +2 -0
  191. package/target/main/ts/plugins/security/actions-security.js +581 -0
  192. package/target/main/ts/plugins/security/dockerfile.d.ts +2 -0
  193. package/target/main/ts/plugins/security/dockerfile.js +487 -0
  194. package/target/main/ts/plugins/security/npm-supply-chain.d.ts +4 -0
  195. package/target/main/ts/plugins/security/npm-supply-chain.js +368 -0
  196. package/target/main/ts/plugins/security/secrets.d.ts +12 -0
  197. package/target/main/ts/plugins/security/secrets.js +254 -0
  198. package/target/main/ts/plugins/source/forges.d.ts +4 -0
  199. package/target/main/ts/plugins/source/forges.js +80 -0
  200. package/target/main/ts/plugins/structure/structure.d.ts +2 -0
  201. package/target/main/ts/plugins/structure/structure.js +42 -0
  202. package/target/main/ts/report/html/app/viewer-chart-bars.d.ts +13 -0
  203. package/target/main/ts/report/html/app/viewer-chart-bars.js +59 -0
  204. package/target/main/ts/report/html/app/viewer-chart-label.d.ts +15 -0
  205. package/target/main/ts/report/html/app/viewer-chart-label.js +43 -0
  206. package/target/main/ts/report/html/app/viewer-chart-line.d.ts +33 -0
  207. package/target/main/ts/report/html/app/viewer-chart-line.js +88 -0
  208. package/target/main/ts/report/html/app/viewer-chart-points.d.ts +52 -0
  209. package/target/main/ts/report/html/app/viewer-chart-points.js +65 -0
  210. package/target/main/ts/report/html/app/viewer-chart-scale.d.ts +21 -0
  211. package/target/main/ts/report/html/app/viewer-chart-scale.js +93 -0
  212. package/target/main/ts/report/html/app/viewer-chart-svg.d.ts +28 -0
  213. package/target/main/ts/report/html/app/viewer-chart-svg.js +41 -0
  214. package/target/main/ts/report/html/app/viewer-chart-time.d.ts +26 -0
  215. package/target/main/ts/report/html/app/viewer-chart-time.js +150 -0
  216. package/target/main/ts/report/html/app/viewer-chart-tip.d.ts +4 -0
  217. package/target/main/ts/report/html/app/viewer-chart-tip.js +210 -0
  218. package/target/main/ts/report/html/app/viewer-chart-x.d.ts +12 -0
  219. package/target/main/ts/report/html/app/viewer-chart-x.js +50 -0
  220. package/target/main/ts/report/html/app/viewer-chart.d.ts +7 -0
  221. package/target/main/ts/report/html/app/viewer-chart.js +50 -0
  222. package/target/main/ts/report/html/app/viewer-code-map.d.ts +27 -0
  223. package/target/main/ts/report/html/app/viewer-code-map.js +176 -0
  224. package/target/main/ts/report/html/app/viewer-columns.d.ts +40 -0
  225. package/target/main/ts/report/html/app/viewer-columns.js +97 -0
  226. package/target/main/ts/report/html/app/viewer-commit-picker.d.ts +12 -0
  227. package/target/main/ts/report/html/app/viewer-commit-picker.js +229 -0
  228. package/target/main/ts/report/html/app/viewer-commits.d.ts +32 -0
  229. package/target/main/ts/report/html/app/viewer-commits.js +81 -0
  230. package/target/main/ts/report/html/app/viewer-controls.d.ts +43 -0
  231. package/target/main/ts/report/html/app/viewer-controls.js +141 -0
  232. package/target/main/ts/report/html/app/viewer-copy.d.ts +17 -0
  233. package/target/main/ts/report/html/app/viewer-copy.js +64 -0
  234. package/target/main/ts/report/html/app/viewer-data.d.ts +24 -0
  235. package/target/main/ts/report/html/app/viewer-data.js +78 -0
  236. package/target/main/ts/report/html/app/viewer-diagnostics.d.ts +4 -0
  237. package/target/main/ts/report/html/app/viewer-diagnostics.js +60 -0
  238. package/target/main/ts/report/html/app/viewer-dom.d.ts +27 -0
  239. package/target/main/ts/report/html/app/viewer-dom.js +99 -0
  240. package/target/main/ts/report/html/app/viewer-file-aside.d.ts +15 -0
  241. package/target/main/ts/report/html/app/viewer-file-aside.js +134 -0
  242. package/target/main/ts/report/html/app/viewer-file-figures.d.ts +17 -0
  243. package/target/main/ts/report/html/app/viewer-file-figures.js +65 -0
  244. package/target/main/ts/report/html/app/viewer-file-source.d.ts +7 -0
  245. package/target/main/ts/report/html/app/viewer-file-source.js +119 -0
  246. package/target/main/ts/report/html/app/viewer-files.d.ts +11 -0
  247. package/target/main/ts/report/html/app/viewer-files.js +40 -0
  248. package/target/main/ts/report/html/app/viewer-filter.d.ts +65 -0
  249. package/target/main/ts/report/html/app/viewer-filter.js +161 -0
  250. package/target/main/ts/report/html/app/viewer-hotspots.d.ts +4 -0
  251. package/target/main/ts/report/html/app/viewer-hotspots.js +133 -0
  252. package/target/main/ts/report/html/app/viewer-inspection.d.ts +69 -0
  253. package/target/main/ts/report/html/app/viewer-inspection.js +38 -0
  254. package/target/main/ts/report/html/app/viewer-issue-group.d.ts +27 -0
  255. package/target/main/ts/report/html/app/viewer-issue-group.js +174 -0
  256. package/target/main/ts/report/html/app/viewer-issues.d.ts +4 -0
  257. package/target/main/ts/report/html/app/viewer-issues.js +173 -0
  258. package/target/main/ts/report/html/app/viewer-language-bar.d.ts +11 -0
  259. package/target/main/ts/report/html/app/viewer-language-bar.js +76 -0
  260. package/target/main/ts/report/html/app/viewer-languages.d.ts +35 -0
  261. package/target/main/ts/report/html/app/viewer-languages.js +97 -0
  262. package/target/main/ts/report/html/app/viewer-layout.d.ts +14 -0
  263. package/target/main/ts/report/html/app/viewer-layout.js +134 -0
  264. package/target/main/ts/report/html/app/viewer-line-coverage.d.ts +47 -0
  265. package/target/main/ts/report/html/app/viewer-line-coverage.js +108 -0
  266. package/target/main/ts/report/html/app/viewer-locations.d.ts +16 -0
  267. package/target/main/ts/report/html/app/viewer-locations.js +31 -0
  268. package/target/main/ts/report/html/app/viewer-map-scale.d.ts +26 -0
  269. package/target/main/ts/report/html/app/viewer-map-scale.js +147 -0
  270. package/target/main/ts/report/html/app/viewer-map-shape.d.ts +42 -0
  271. package/target/main/ts/report/html/app/viewer-map-shape.js +102 -0
  272. package/target/main/ts/report/html/app/viewer-metric-format.d.ts +23 -0
  273. package/target/main/ts/report/html/app/viewer-metric-format.js +93 -0
  274. package/target/main/ts/report/html/app/viewer-metric-registry.d.ts +47 -0
  275. package/target/main/ts/report/html/app/viewer-metric-registry.js +138 -0
  276. package/target/main/ts/report/html/app/viewer-metrics-view.d.ts +4 -0
  277. package/target/main/ts/report/html/app/viewer-metrics-view.js +159 -0
  278. package/target/main/ts/report/html/app/viewer-metrics.d.ts +51 -0
  279. package/target/main/ts/report/html/app/viewer-metrics.js +195 -0
  280. package/target/main/ts/report/html/app/viewer-overview-cards.d.ts +12 -0
  281. package/target/main/ts/report/html/app/viewer-overview-cards.js +121 -0
  282. package/target/main/ts/report/html/app/viewer-overview-hotspots.d.ts +9 -0
  283. package/target/main/ts/report/html/app/viewer-overview-hotspots.js +173 -0
  284. package/target/main/ts/report/html/app/viewer-overview-lead.d.ts +12 -0
  285. package/target/main/ts/report/html/app/viewer-overview-lead.js +116 -0
  286. package/target/main/ts/report/html/app/viewer-profile-badges.d.ts +11 -0
  287. package/target/main/ts/report/html/app/viewer-profile-badges.js +119 -0
  288. package/target/main/ts/report/html/app/viewer-profile-table.d.ts +29 -0
  289. package/target/main/ts/report/html/app/viewer-profile-table.js +124 -0
  290. package/target/main/ts/report/html/app/viewer-profile.d.ts +13 -0
  291. package/target/main/ts/report/html/app/viewer-profile.js +180 -0
  292. package/target/main/ts/report/html/app/viewer-projects.d.ts +1 -0
  293. package/target/main/ts/report/html/app/viewer-projects.js +90 -0
  294. package/target/main/ts/report/html/app/viewer-pull-sections.d.ts +4 -0
  295. package/target/main/ts/report/html/app/viewer-pull-sections.js +118 -0
  296. package/target/main/ts/report/html/app/viewer-pull-trend.d.ts +5 -0
  297. package/target/main/ts/report/html/app/viewer-pull-trend.js +63 -0
  298. package/target/main/ts/report/html/app/viewer-pulls.d.ts +2 -0
  299. package/target/main/ts/report/html/app/viewer-pulls.js +92 -0
  300. package/target/main/ts/report/html/app/viewer-query-field.d.ts +19 -0
  301. package/target/main/ts/report/html/app/viewer-query-field.js +203 -0
  302. package/target/main/ts/report/html/app/viewer-route.d.ts +34 -0
  303. package/target/main/ts/report/html/app/viewer-route.js +55 -0
  304. package/target/main/ts/report/html/app/viewer-shell.d.ts +20 -0
  305. package/target/main/ts/report/html/app/viewer-shell.js +113 -0
  306. package/target/main/ts/report/html/app/viewer-source-view.d.ts +49 -0
  307. package/target/main/ts/report/html/app/viewer-source-view.js +150 -0
  308. package/target/main/ts/report/html/app/viewer-source.d.ts +27 -0
  309. package/target/main/ts/report/html/app/viewer-source.js +57 -0
  310. package/target/main/ts/report/html/app/viewer-suggest.d.ts +13 -0
  311. package/target/main/ts/report/html/app/viewer-suggest.js +91 -0
  312. package/target/main/ts/report/html/app/viewer-sunburst.d.ts +5 -0
  313. package/target/main/ts/report/html/app/viewer-sunburst.js +40 -0
  314. package/target/main/ts/report/html/app/viewer-table-cells.d.ts +25 -0
  315. package/target/main/ts/report/html/app/viewer-table-cells.js +135 -0
  316. package/target/main/ts/report/html/app/viewer-table-rows.d.ts +56 -0
  317. package/target/main/ts/report/html/app/viewer-table-rows.js +97 -0
  318. package/target/main/ts/report/html/app/viewer-tokenizer.d.ts +15 -0
  319. package/target/main/ts/report/html/app/viewer-tokenizer.js +241 -0
  320. package/target/main/ts/report/html/app/viewer-totals.d.ts +20 -0
  321. package/target/main/ts/report/html/app/viewer-totals.js +100 -0
  322. package/target/main/ts/report/html/app/viewer-treemap.d.ts +24 -0
  323. package/target/main/ts/report/html/app/viewer-treemap.js +112 -0
  324. package/target/main/ts/report/html/app/viewer-trend-data.d.ts +54 -0
  325. package/target/main/ts/report/html/app/viewer-trend-data.js +109 -0
  326. package/target/main/ts/report/html/app/viewer-trend-nav.d.ts +5 -0
  327. package/target/main/ts/report/html/app/viewer-trend-nav.js +86 -0
  328. package/target/main/ts/report/html/app/viewer-trend-points.d.ts +30 -0
  329. package/target/main/ts/report/html/app/viewer-trend-points.js +128 -0
  330. package/target/main/ts/report/html/app/viewer-trend-series.d.ts +32 -0
  331. package/target/main/ts/report/html/app/viewer-trend-series.js +128 -0
  332. package/target/main/ts/report/html/app/viewer-trends.d.ts +5 -0
  333. package/target/main/ts/report/html/app/viewer-trends.js +89 -0
  334. package/target/main/ts/report/html/app/viewer.d.ts +1 -0
  335. package/target/main/ts/report/html/app/viewer.js +222 -0
  336. package/target/main/ts/report/html/site/badges.d.ts +11 -0
  337. package/target/main/ts/report/html/site/badges.js +72 -0
  338. package/target/main/ts/report/html/site/export-site.d.ts +16 -0
  339. package/target/main/ts/report/html/site/export-site.js +129 -0
  340. package/target/main/ts/report/html/site/exported-server.d.ts +6 -0
  341. package/target/main/ts/report/html/site/exported-server.js +72 -0
  342. package/target/main/ts/report/html/site/local-server.d.ts +7 -0
  343. package/target/main/ts/report/html/site/local-server.js +59 -0
  344. package/target/main/ts/report/html/site/projects.d.ts +1 -0
  345. package/target/main/ts/report/html/site/projects.js +69 -0
  346. package/target/main/ts/report/html/site/server.d.ts +4 -0
  347. package/target/main/ts/report/html/site/server.js +65 -0
  348. package/target/main/ts/report/html/site/source-route.d.ts +6 -0
  349. package/target/main/ts/report/html/site/source-route.js +23 -0
  350. package/target/main/ts/report/json/projections/commit-summary.d.ts +13 -0
  351. package/target/main/ts/report/json/projections/commit-summary.js +126 -0
  352. package/target/main/ts/report/json/projections/components.d.ts +4 -0
  353. package/target/main/ts/report/json/projections/components.js +30 -0
  354. package/target/main/ts/report/json/projections/file-metrics.d.ts +4 -0
  355. package/target/main/ts/report/json/projections/file-metrics.js +260 -0
  356. package/target/main/ts/report/json/projections/ignore-view.d.ts +2 -0
  357. package/target/main/ts/report/json/projections/ignore-view.js +13 -0
  358. package/target/main/ts/report/json/projections/inspection-context.d.ts +5 -0
  359. package/target/main/ts/report/json/projections/inspection-context.js +104 -0
  360. package/target/main/ts/report/json/projections/inspection-details.d.ts +14 -0
  361. package/target/main/ts/report/json/projections/inspection-details.js +98 -0
  362. package/target/main/ts/report/json/projections/metric-values.d.ts +14 -0
  363. package/target/main/ts/report/json/projections/metric-values.js +104 -0
  364. package/target/main/ts/report/json/projections/profile-selectors.d.ts +8 -0
  365. package/target/main/ts/report/json/projections/profile-selectors.js +34 -0
  366. package/target/main/ts/report/json/projections/security-summary.d.ts +11 -0
  367. package/target/main/ts/report/json/projections/security-summary.js +22 -0
  368. package/target/main/ts/report/json/store/directory.d.ts +3 -0
  369. package/target/main/ts/report/json/store/directory.js +19 -0
  370. package/target/main/ts/report/json/store/local-store.d.ts +25 -0
  371. package/target/main/ts/report/json/store/local-store.js +214 -0
  372. package/target/main/ts/report/json/store/object-store.d.ts +14 -0
  373. package/target/main/ts/report/json/store/object-store.js +73 -0
  374. package/target/main/ts/report/json/store/operation-cache.d.ts +8 -0
  375. package/target/main/ts/report/json/store/operation-cache.js +32 -0
  376. package/target/main/ts/report/json/store/pull-review-store.d.ts +2 -0
  377. package/target/main/ts/report/json/store/pull-review-store.js +33 -0
  378. package/target/main/ts/report/json/store/replace-file.d.ts +1 -0
  379. package/target/main/ts/report/json/store/replace-file.js +35 -0
  380. package/target/main/ts/report/json/store/report-tree.d.ts +46 -0
  381. package/target/main/ts/report/json/store/report-tree.js +295 -0
  382. package/target/main/ts/report/json/store/store-check.d.ts +32 -0
  383. package/target/main/ts/report/json/store/store-check.js +153 -0
  384. package/target/main/ts/report/json/validation/metabranch.d.ts +4 -0
  385. package/target/main/ts/report/json/validation/metabranch.js +11 -0
  386. package/target/main/ts/report/json/validation/report.d.ts +20 -0
  387. package/target/main/ts/report/json/validation/report.js +82 -0
  388. package/target/main/ts/report/json/validation/summary-validation.d.ts +4 -0
  389. package/target/main/ts/report/json/validation/summary-validation.js +30 -0
  390. package/target/main/ts/report/json/wire/compact-json.d.ts +11 -0
  391. package/target/main/ts/report/json/wire/compact-json.js +76 -0
  392. package/target/main/ts/report/json/wire/component-model.d.ts +9 -0
  393. package/target/main/ts/report/json/wire/component-model.js +1 -0
  394. package/target/main/ts/report/json/wire/domain-types.d.ts +2 -0
  395. package/target/main/ts/report/json/wire/domain-types.js +1 -0
  396. package/target/main/ts/report/json/wire/file-metrics-model.d.ts +81 -0
  397. package/target/main/ts/report/json/wire/file-metrics-model.js +1 -0
  398. package/target/main/ts/report/json/wire/inspection-context-model.d.ts +31 -0
  399. package/target/main/ts/report/json/wire/inspection-context-model.js +1 -0
  400. package/target/main/ts/report/json/wire/inspection-details-model.d.ts +87 -0
  401. package/target/main/ts/report/json/wire/inspection-details-model.js +1 -0
  402. package/target/main/ts/report/json/wire/project-model.d.ts +7 -0
  403. package/target/main/ts/report/json/wire/project-model.js +1 -0
  404. package/target/main/ts/report/json/wire/public-history-model.d.ts +37 -0
  405. package/target/main/ts/report/json/wire/public-history-model.js +5 -0
  406. package/target/main/ts/report/json/wire/pull-review-model.d.ts +54 -0
  407. package/target/main/ts/report/json/wire/pull-review-model.js +3 -0
  408. package/target/main/ts/report/json/wire/summary-model.d.ts +45 -0
  409. package/target/main/ts/report/json/wire/summary-model.js +1 -0
  410. package/target/main/ts/report/markdown/pull-review.d.ts +5 -0
  411. package/target/main/ts/report/markdown/pull-review.js +132 -0
  412. package/target/main/ts/report.d.ts +23 -0
  413. package/target/main/ts/report.js +12 -0
  414. package/target/main/ts/runtime.d.ts +17 -0
  415. package/target/main/ts/runtime.js +30 -0
@@ -0,0 +1,21 @@
1
+ import { rm } from 'node:fs/promises';
2
+ import { homedir } from 'node:os';
3
+ import { join, resolve } from 'node:path';
4
+ export function cacheRoot(env = process.env, system = process.platform, home = homedir()) {
5
+ if (env.REPOMETRY_CACHE_DIR)
6
+ return resolve(env.REPOMETRY_CACHE_DIR);
7
+ if (env.XDG_CACHE_HOME)
8
+ return resolve(env.XDG_CACHE_HOME, 'repometry');
9
+ if (system === 'darwin')
10
+ return join(home, 'Library', 'Caches', 'repometry');
11
+ if (system === 'win32' && env.LOCALAPPDATA)
12
+ return resolve(env.LOCALAPPDATA, 'repometry', 'cache');
13
+ return join(home, '.cache', 'repometry');
14
+ }
15
+ export async function clearCaches(root) {
16
+ // Also clean the parser cache used by older Repometry versions.
17
+ const directories = ['sources', 'go-parsers-v1'];
18
+ await Promise.all(directories.map(directory => rm(join(root, directory), { recursive: true, force: true })));
19
+ return directories;
20
+ }
21
+ //# sourceMappingURL=root.js.map
@@ -0,0 +1,4 @@
1
+ import type { PullReview } from '@repometry/core/internal/model/pull-review.js';
2
+ /** The number of the pull request whose event started this GitHub Actions run, if any. */
3
+ export declare function gitHubPullRequest(): Promise<number | undefined>;
4
+ export declare function writeGitHubReview(review: PullReview, markdown: string, repository: string): Promise<void>;
@@ -0,0 +1,47 @@
1
+ import { appendFile, readFile, realpath } from 'node:fs/promises';
2
+ import { isAbsolute, relative, resolve, sep } from 'node:path';
3
+ import { isRecord } from '@repometry/core/internal/engine/plugin.js';
4
+ import { annotationLimit } from '@repometry/core/internal/model/pull-review.js';
5
+ /** The number of the pull request whose event started this GitHub Actions run, if any. */
6
+ export async function gitHubPullRequest() {
7
+ const path = process.env.GITHUB_EVENT_PATH;
8
+ if (!path)
9
+ return undefined;
10
+ const event = JSON.parse(await readFile(path, 'utf8'));
11
+ const pull = isRecord(event) ? event.pull_request : undefined;
12
+ const number = isRecord(pull) ? pull.number : undefined;
13
+ return typeof number === 'number' && Number.isSafeInteger(number) && number > 0 ? number : undefined;
14
+ }
15
+ export async function writeGitHubReview(review, markdown, repository) {
16
+ const summary = process.env.GITHUB_STEP_SUMMARY;
17
+ if (!summary)
18
+ throw new Error('GitHub reporting requires GITHUB_STEP_SUMMARY');
19
+ await appendFile(summary, markdown);
20
+ const annotate = await annotator(repository);
21
+ review.issues.filter(issue => issue.effect === 'new' || issue.effect === 'worsened').slice(0, annotationLimit)
22
+ .forEach(({ effect, finding }) => annotate('error', `Repometry: ${effect} issue`, finding, finding.message));
23
+ review.coverage.uncovered.slice(0, annotationLimit).forEach(({ path, first, last }) => annotate('warning', 'Repometry: not covered', { path, line: first, endLine: last }, `Changed lines ${first}${last > first ? `–${last}` : ''} are not covered`));
24
+ }
25
+ /** Writes workflow annotations for paths inside the checkout, relative to the workspace GitHub shows them in. */
26
+ async function annotator(repository) {
27
+ const [workspace, root] = await Promise.all([realpath(process.env.GITHUB_WORKSPACE ?? process.cwd()), realpath(repository)]);
28
+ const prefix = relative(workspace, root);
29
+ const inside = !isAbsolute(prefix) && !prefix.split(sep).includes('..');
30
+ return (kind, title, { path, line, endLine }, message) => {
31
+ if (!inside || path === undefined)
32
+ return;
33
+ const checkoutPath = relative(workspace, resolve(root, path));
34
+ if (isAbsolute(checkoutPath) || checkoutPath.split(sep).includes('..'))
35
+ return;
36
+ const properties = [`file=${property(checkoutPath.split(sep).join('/'))}`,
37
+ ...line === undefined ? [] : [`line=${line}`, `endLine=${endLine ?? line}`], `title=${property(title)}`];
38
+ process.stderr.write(`::${kind} ${properties.join(',')}::${data(message)}\n`);
39
+ };
40
+ }
41
+ function data(value) {
42
+ return value.replaceAll('%', '%25').replaceAll('\r', '%0D').replaceAll('\n', '%0A');
43
+ }
44
+ function property(value) {
45
+ return data(value).replaceAll(':', '%3A').replaceAll(',', '%2C');
46
+ }
47
+ //# sourceMappingURL=github.js.map
@@ -0,0 +1,10 @@
1
+ export declare class GitBlobBatch {
2
+ private readonly directory;
3
+ private session?;
4
+ private tail;
5
+ private timer?;
6
+ constructor(directory: string);
7
+ read(oid: string, signal?: AbortSignal): Promise<Buffer | undefined>;
8
+ close(): void;
9
+ private readOne;
10
+ }
@@ -0,0 +1,107 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { validSubjectId } from '@repometry/core/internal/model/report.js';
3
+ import { gitExecutable } from './git-executable.js';
4
+ const idleTimeout = 10_000;
5
+ const maxBlobBytes = 64 * 1024 * 1024;
6
+ export class GitBlobBatch {
7
+ directory;
8
+ session;
9
+ tail = Promise.resolve();
10
+ timer;
11
+ constructor(directory) {
12
+ this.directory = directory;
13
+ }
14
+ read(oid, signal) {
15
+ if (!validSubjectId('commit', oid))
16
+ throw new Error('Invalid source blob ID');
17
+ const pending = this.tail.then(() => this.readOne(oid, signal));
18
+ this.tail = pending.catch(() => undefined);
19
+ return pending;
20
+ }
21
+ close() {
22
+ clearTimeout(this.timer);
23
+ this.session?.close();
24
+ this.session = undefined;
25
+ }
26
+ async readOne(oid, signal) {
27
+ signal?.throwIfAborted();
28
+ clearTimeout(this.timer);
29
+ const session = this.session ??= new BlobSession(this.directory);
30
+ const abort = () => this.close();
31
+ signal?.addEventListener('abort', abort, { once: true });
32
+ try {
33
+ return await session.read(oid);
34
+ }
35
+ catch (error) {
36
+ this.close();
37
+ throw error;
38
+ }
39
+ finally {
40
+ signal?.removeEventListener('abort', abort);
41
+ if (this.session)
42
+ this.timer = setTimeout(() => this.close(), idleTimeout).unref();
43
+ }
44
+ }
45
+ }
46
+ class BlobSession {
47
+ child;
48
+ chunks;
49
+ buffer = Buffer.alloc(0);
50
+ constructor(directory) {
51
+ this.child = spawn(gitExecutable(), ['--no-replace-objects', 'cat-file', '--batch'], { cwd: directory });
52
+ this.child.stderr.resume();
53
+ this.child.stdin.on('error', () => { });
54
+ this.child.on('error', error => this.child.stdout.destroy(error));
55
+ this.chunks = this.child.stdout[Symbol.asyncIterator]();
56
+ }
57
+ close() {
58
+ this.child.stdin.end();
59
+ this.child.kill();
60
+ }
61
+ async read(oid) {
62
+ await new Promise((resolve, reject) => this.child.stdin.write(oid + '\n', error => error ? reject(error) : resolve()));
63
+ const header = await this.header();
64
+ if (header === oid + ' missing')
65
+ return undefined;
66
+ const parsed = /^([a-f0-9]+) blob ([0-9]+)$/.exec(header);
67
+ const size = Number(parsed?.[2]);
68
+ if (parsed?.[1] !== oid || !Number.isSafeInteger(size))
69
+ throw new Error('Invalid Git source blob response');
70
+ if (size > maxBlobBytes)
71
+ throw new Error('Git source blob exceeds the read limit');
72
+ const bytes = Buffer.allocUnsafe(size);
73
+ let offset = 0;
74
+ while (offset < size) {
75
+ if (this.buffer.length === 0)
76
+ this.buffer = await this.chunk();
77
+ const copied = this.buffer.copy(bytes, offset, 0, size - offset);
78
+ offset += copied;
79
+ this.buffer = this.buffer.subarray(copied);
80
+ }
81
+ if (this.buffer.length === 0)
82
+ this.buffer = await this.chunk();
83
+ if (this.buffer[0] !== 10)
84
+ throw new Error('Invalid Git source blob terminator');
85
+ this.buffer = this.buffer.subarray(1);
86
+ return bytes;
87
+ }
88
+ async header() {
89
+ let index = this.buffer.indexOf(10);
90
+ while (index < 0) {
91
+ if (this.buffer.length > 256)
92
+ throw new Error('Invalid Git source blob header');
93
+ this.buffer = Buffer.concat([this.buffer, await this.chunk()]);
94
+ index = this.buffer.indexOf(10);
95
+ }
96
+ const header = this.buffer.toString('ascii', 0, index);
97
+ this.buffer = this.buffer.subarray(index + 1);
98
+ return header;
99
+ }
100
+ async chunk() {
101
+ const result = await this.chunks.next();
102
+ if (result.done)
103
+ throw new Error('Git source reader stopped');
104
+ return result.value;
105
+ }
106
+ }
107
+ //# sourceMappingURL=blob-batch.js.map
@@ -0,0 +1,20 @@
1
+ export interface BlobRequest {
2
+ readonly id: string;
3
+ readonly estimatedBytes: number;
4
+ readonly contents: boolean;
5
+ }
6
+ interface BlobFacts {
7
+ readonly lines: number | null;
8
+ readonly bytes?: Buffer;
9
+ }
10
+ type ReadBlobs = (ids: readonly string[]) => Promise<ReadonlyMap<string, Buffer>>;
11
+ export declare const gitBlobBatchBytes: number;
12
+ /** Keeps only inventory facts and requested bytes from the preceding snapshot. */
13
+ export declare class GitBlobHistory {
14
+ private readonly maxBatchBytes;
15
+ private previous;
16
+ constructor(maxBatchBytes?: number);
17
+ read(requests: readonly BlobRequest[], read: ReadBlobs): Promise<ReadonlyMap<string, BlobFacts>>;
18
+ private missingRequests;
19
+ }
20
+ export {};
@@ -0,0 +1,54 @@
1
+ import { textLineCount } from '@repometry/core/internal/model/snapshot.js';
2
+ export const gitBlobBatchBytes = 64 * 1024 * 1024;
3
+ /** Keeps only inventory facts and requested bytes from the preceding snapshot. */
4
+ export class GitBlobHistory {
5
+ maxBatchBytes;
6
+ previous = new Map();
7
+ constructor(maxBatchBytes = gitBlobBatchBytes) {
8
+ this.maxBatchBytes = maxBatchBytes;
9
+ }
10
+ async read(requests, read) {
11
+ const current = new Map();
12
+ const missing = this.missingRequests(requests, current);
13
+ for (const batch of blobBatches(missing, this.maxBatchBytes))
14
+ await readBatch(batch, read, current);
15
+ this.previous = current;
16
+ return current;
17
+ }
18
+ missingRequests(requests, current) {
19
+ const missing = [];
20
+ for (const request of requests) {
21
+ const facts = this.previous.get(request.id);
22
+ if (!facts || (request.contents && facts.bytes === undefined))
23
+ missing.push(request);
24
+ else
25
+ current.set(request.id, request.contents ? facts : { lines: facts.lines });
26
+ }
27
+ return missing;
28
+ }
29
+ }
30
+ async function readBatch(requests, read, current) {
31
+ const blobs = await read(requests.map(({ id }) => id));
32
+ for (const { id, contents } of requests) {
33
+ const bytes = blobs.get(id);
34
+ if (!bytes)
35
+ throw new Error(`Git blob unavailable: ${id}`);
36
+ current.set(id, { lines: textLineCount(bytes), ...(contents ? { bytes: Buffer.from(bytes) } : {}) });
37
+ }
38
+ }
39
+ function* blobBatches(requests, maxBytes) {
40
+ let batch = [];
41
+ let estimatedBytes = 0;
42
+ for (const request of requests) {
43
+ if (batch.length && estimatedBytes + request.estimatedBytes > maxBytes) {
44
+ yield batch;
45
+ batch = [];
46
+ estimatedBytes = 0;
47
+ }
48
+ batch.push(request);
49
+ estimatedBytes += request.estimatedBytes;
50
+ }
51
+ if (batch.length)
52
+ yield batch;
53
+ }
54
+ //# sourceMappingURL=blob-history.js.map
@@ -0,0 +1,27 @@
1
+ import type { SourceSnapshot } from '@repometry/core/internal/model/snapshot.js';
2
+ import type { GitChanges, LineHunk, LineRange } from '@repometry/core/internal/model/changes.js';
3
+ export type { GitChanges, LineRange } from '@repometry/core/internal/model/changes.js';
4
+ export declare const oid: RegExp;
5
+ export declare const regularFile: RegExp;
6
+ export declare const diffMethod: {
7
+ readonly algorithm: 'myers';
8
+ readonly indentHeuristic: false;
9
+ readonly renameThresholdPercent: 50;
10
+ readonly renameLimit: 1000;
11
+ };
12
+ export declare const stableDiff: readonly ['--no-color', '--no-ext-diff', '--no-textconv', "--diff-algorithm=myers", '--no-indent-heuristic'];
13
+ export declare function findMergeBase(repository: string, base: string, head: string): Promise<string>;
14
+ export declare function readChanges(repository: string, base: string, head: SourceSnapshot, excludes: (path: string) => boolean, isSource: (path: string) => boolean): Promise<GitChanges>;
15
+ interface RawChange {
16
+ readonly path: string;
17
+ readonly mode: string;
18
+ readonly oid: string;
19
+ readonly previous?: {
20
+ readonly path: string;
21
+ readonly oid: string;
22
+ };
23
+ }
24
+ export declare function rawChanges(text: string): readonly RawChange[];
25
+ export declare function addedRanges(patch: string): readonly LineRange[];
26
+ export declare function removedRanges(patch: string): readonly LineRange[];
27
+ export declare function patchHunks(patch: string): readonly LineHunk[];
@@ -0,0 +1,117 @@
1
+ import { gitText, gitUtf8 } from './git.js';
2
+ import { physicalLines, utf8 } from '@repometry/core/internal/model/snapshot.js';
3
+ export const oid = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/;
4
+ export const regularFile = /^100(?:644|755)$/;
5
+ export const diffMethod = { algorithm: 'myers', indentHeuristic: false, renameThresholdPercent: 50, renameLimit: 1000 };
6
+ export const stableDiff = ['--no-color', '--no-ext-diff', '--no-textconv', `--diff-algorithm=${diffMethod.algorithm}`, '--no-indent-heuristic'];
7
+ export async function findMergeBase(repository, base, head) {
8
+ if (!oid.test(base) || !oid.test(head))
9
+ throw new Error('Merge base requires full commit IDs');
10
+ let found;
11
+ try {
12
+ found = await gitText(repository, ['merge-base', '--all', base, head]);
13
+ }
14
+ catch (error) {
15
+ if (error instanceof Error && 'code' in error && error.code === 1) {
16
+ throw new Error('No merge base found. Make the histories of both commits available locally, for example with fetch-depth: 0 on actions/checkout.');
17
+ }
18
+ throw error;
19
+ }
20
+ const candidates = found.trim().split(/\s+/);
21
+ const first = candidates[0];
22
+ if (candidates.length !== 1 || !first || !oid.test(first))
23
+ throw new Error('The selected commits need one unambiguous merge base');
24
+ return first;
25
+ }
26
+ export async function readChanges(repository, base, head, excludes, isSource) {
27
+ if (!oid.test(base) || head.subject.kind !== 'commit' || !oid.test(head.subject.id))
28
+ throw new Error('Git diff requires full commit IDs');
29
+ const files = new Map();
30
+ const gaps = new Map();
31
+ if (base === head.subject.id)
32
+ return { files, gaps };
33
+ const contents = new Map(head.files.map(file => [file.path, file.bytes]));
34
+ const raw = await gitUtf8(repository, ['diff', ...stableDiff, '--raw', '-z', '--no-abbrev',
35
+ `--find-renames=${diffMethod.renameThresholdPercent}%`, `-l${diffMethod.renameLimit}`, base, head.subject.id, '--']);
36
+ for (const change of rawChanges(raw)) {
37
+ const bytes = contents.get(change.path);
38
+ if (!bytes || !regularFile.test(change.mode))
39
+ continue;
40
+ const before = change.previous && isSource(change.previous.path) && !excludes(change.previous.path)
41
+ ? change.previous.oid : undefined;
42
+ if (before === change.oid)
43
+ continue;
44
+ let source;
45
+ try {
46
+ source = utf8(bytes);
47
+ }
48
+ catch {
49
+ gaps.set(change.path, 'Changed source is not valid UTF-8');
50
+ continue;
51
+ }
52
+ if (/\0|\r(?!\n)|[\u2028\u2029]/.test(source)) {
53
+ gaps.set(change.path, 'Git and LCOV line coordinates may differ for this file');
54
+ continue;
55
+ }
56
+ const length = physicalLines(source);
57
+ const ranges = before
58
+ ? addedRanges(await gitText(repository, ['diff', ...stableDiff, '--text', '--unified=0', '--inter-hunk-context=0', before, change.oid, '--']))
59
+ : (length === 0 ? [] : [{ first: 1, last: length }]);
60
+ if (ranges.some(range => range.last > length))
61
+ throw new Error('Git reported changes beyond the source lines');
62
+ if (ranges.length > 0)
63
+ files.set(change.path, ranges);
64
+ }
65
+ return { files, gaps };
66
+ }
67
+ export function rawChanges(text) {
68
+ if (text === '')
69
+ return [];
70
+ const fields = text.split('\0');
71
+ if (fields.pop() !== '')
72
+ throw new Error('Invalid Git raw diff terminator');
73
+ const changes = [];
74
+ for (let i = 0; i < fields.length;) {
75
+ const header = /^:(\d{6}) (\d{6}) ([a-f0-9]+) ([a-f0-9]+) ([ACDMRT])\d*$/.exec(fields[i++] ?? '');
76
+ const oldPath = fields[i++];
77
+ const status = header?.[5];
78
+ const path = status === 'C' || status === 'R' ? fields[i++] : oldPath;
79
+ const oldId = header?.[3];
80
+ const newId = header?.[4];
81
+ const mode = header?.[2];
82
+ if (!oldPath || !path || !mode || !oldId || !newId || !oid.test(oldId) || !oid.test(newId)) {
83
+ throw new Error('Invalid Git raw diff entry');
84
+ }
85
+ const previous = status !== 'A' && status !== 'C' && regularFile.test(header[1])
86
+ ? { path: oldPath, oid: oldId } : undefined;
87
+ changes.push({ path, mode, oid: newId, previous });
88
+ }
89
+ return changes;
90
+ }
91
+ export function addedRanges(patch) {
92
+ return lineRanges(patchHunks(patch).map(hunk => hunk.head));
93
+ }
94
+ export function removedRanges(patch) {
95
+ return lineRanges(patchHunks(patch).map(hunk => hunk.base));
96
+ }
97
+ export function patchHunks(patch) {
98
+ return patch.split('\n').flatMap(line => {
99
+ const match = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(?: |$)/.exec(line);
100
+ return match ? [{ base: { first: Number(match[1]), count: Number(match[2] ?? 1) },
101
+ head: { first: Number(match[3]), count: Number(match[4] ?? 1) } }] : [];
102
+ });
103
+ }
104
+ /** The changed lines of one side of the hunks, which Git reports in order and without overlap. */
105
+ function lineRanges(sides) {
106
+ const ranges = [];
107
+ for (const { first, count } of sides) {
108
+ if (count === 0)
109
+ continue;
110
+ const last = first + count - 1;
111
+ if (first < 1 || !Number.isSafeInteger(last) || first <= (ranges.at(-1)?.last ?? 0))
112
+ throw new Error('Invalid Git diff hunk range');
113
+ ranges.push({ first, last });
114
+ }
115
+ return ranges;
116
+ }
117
+ //# sourceMappingURL=changes.js.map
@@ -0,0 +1,2 @@
1
+ import type { ReadCommitMetadata } from '../../report/json/projections/commit-summary.js';
2
+ export declare function commitMetadataReader(repository: string): ReadCommitMetadata;
@@ -0,0 +1,46 @@
1
+ import { gitText } from './git.js';
2
+ export function commitMetadataReader(repository) {
3
+ return async (revisions) => {
4
+ const result = new Map();
5
+ for (let start = 0; start < revisions.length; start += 128) {
6
+ const batch = revisions.slice(start, start + 128);
7
+ const log = await gitText(repository, ['log', '--ignore-missing', '--no-walk=unsorted', '-z', '--no-show-signature',
8
+ '--format=%H%x00%cI%x00%an%x00%ae%x00%B', ...batch, '--']);
9
+ const fields = log.split('\0');
10
+ for (let index = 0; index + 4 < fields.length; index += 5) {
11
+ const [sha, date, name, email, message] = fields.slice(index, index + 5);
12
+ const time = Date.parse(date);
13
+ result.set(sha, { ...(Number.isFinite(time) ? { committedAt: new Date(time).toISOString() } : {}),
14
+ subject: message.split(/\r?\n/, 1)[0], author: { name, email } });
15
+ }
16
+ }
17
+ const requested = new Set(revisions);
18
+ for (const [sha, tags] of await tagsByCommit(repository)) {
19
+ if (requested.has(sha))
20
+ result.set(sha, { ...result.get(sha), tags });
21
+ }
22
+ return result;
23
+ };
24
+ }
25
+ async function tagsByCommit(repository) {
26
+ const refs = await gitText(repository, ['show-ref', '--tags', '--dereference']).catch((error) => {
27
+ if (error instanceof Error && 'code' in error && error.code === 1)
28
+ return '';
29
+ throw error;
30
+ });
31
+ const tags = new Map();
32
+ for (const line of refs.split('\n')) {
33
+ const match = /^([a-f0-9]+) refs\/tags\/(.+?)(?:\^\{\})?$/.exec(line);
34
+ if (match)
35
+ tags.set(match[2], match[1]);
36
+ }
37
+ const result = new Map();
38
+ for (const tag of [...tags.keys()].sort()) {
39
+ const sha = tags.get(tag);
40
+ const names = result.get(sha) ?? [];
41
+ names.push(tag);
42
+ result.set(sha, names);
43
+ }
44
+ return result;
45
+ }
46
+ //# sourceMappingURL=commit-metadata.js.map
@@ -0,0 +1,9 @@
1
+ import type { ChurnWindow } from '@repometry/core/internal/model/churn.js';
2
+ export { churnSettings } from '@repometry/core/internal/model/churn.js';
3
+ export type { ChurnWindow } from '@repometry/core/internal/model/churn.js';
4
+ interface Churn {
5
+ readonly touches: ReadonlyMap<string, number>;
6
+ readonly window: ChurnWindow;
7
+ }
8
+ export declare function gitChurn(directory: string, commit: string, paths: readonly string[]): Promise<Churn>;
9
+ export declare function summarizeGitHistory(log: string, commit: string, paths: readonly string[], shallow: boolean): Churn;
@@ -0,0 +1,72 @@
1
+ import { gitText, gitUtf8 } from './git.js';
2
+ import { churnSettings } from '@repometry/core/internal/model/churn.js';
3
+ export { churnSettings } from '@repometry/core/internal/model/churn.js';
4
+ const maxTimeMs = 8000;
5
+ const oid = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/;
6
+ export async function gitChurn(directory, commit, paths) {
7
+ if (!oid.test(commit))
8
+ throw new Error('Git history requires a full commit ID');
9
+ const [log, shallow] = await Promise.all([
10
+ gitUtf8(directory, ['-c', 'log.showRoot=false', 'log', '--first-parent', '--diff-merges=first-parent',
11
+ `--max-count=${churnSettings.maxCommits + 1}`, '--format=%x00%H %ct %P', '--name-only', '-z',
12
+ '--no-renames', '--no-notes', '--no-color', '--no-ext-diff', '--no-textconv', commit, '--'], maxTimeMs),
13
+ gitText(directory, ['rev-parse', '--is-shallow-repository'], maxTimeMs),
14
+ ]);
15
+ return summarizeGitHistory(log, commit, paths, shallow.trim() === 'true');
16
+ }
17
+ export function summarizeGitHistory(log, commit, paths, shallow) {
18
+ const touches = new Map(paths.map(path => [path, 0]));
19
+ let visited = 0;
20
+ let commits = 0;
21
+ let endingAt;
22
+ let capReached = false;
23
+ for (const record of gitRecords(log)) {
24
+ if (endingAt === undefined && record.sha !== commit)
25
+ throw new Error('Git history did not start at the inspected commit');
26
+ endingAt ??= record.timestamp;
27
+ if (visited++ >= churnSettings.maxCommits) {
28
+ capReached = true;
29
+ break;
30
+ }
31
+ // Only commits with a parent, inside the window that ends at the inspected commit, count.
32
+ if (!record.hasParent || record.timestamp < endingAt - churnSettings.lookbackDays * 86400 || record.timestamp > endingAt)
33
+ continue;
34
+ commits++;
35
+ for (const path of new Set(record.paths))
36
+ if (touches.has(path))
37
+ touches.set(path, touches.get(path) + 1);
38
+ }
39
+ if (endingAt === undefined)
40
+ throw new Error('Empty Git history');
41
+ return {
42
+ touches: shallow && commits === 0 ? new Map() : touches,
43
+ window: { endingAt: new Date(endingAt * 1000).toISOString(), commits, shallow, capReached },
44
+ };
45
+ }
46
+ /** The records of `git log -z --format=%x00%H %ct %P --name-only`: a header field, then path fields up to an empty one. */
47
+ function* gitRecords(log) {
48
+ const fields = log.split('\0');
49
+ if (fields[0] !== '' || fields.at(-1) !== '')
50
+ throw new Error('Invalid Git history record');
51
+ let index = 1;
52
+ while (index < fields.length - 1) {
53
+ const header = recordHeader(fields[index++]);
54
+ const paths = [];
55
+ // Git starts each record's path list on a new line.
56
+ for (; index < fields.length && fields[index] !== ''; index++)
57
+ paths.push(paths.length ? fields[index] : fields[index].replace(/^\n/, ''));
58
+ index++;
59
+ yield { ...header, paths };
60
+ }
61
+ }
62
+ function recordHeader(field) {
63
+ const [sha, date, ...parents] = field.split(' ');
64
+ const timestamp = Number(date);
65
+ const hasParent = parents.length > 0 && parents.every(parent => oid.test(parent));
66
+ const root = parents.length === 1 && parents[0] === '';
67
+ const named = sha !== undefined && oid.test(sha) && date !== undefined && /^\d+$/.test(date);
68
+ if (!named || !Number.isSafeInteger(timestamp) || (!hasParent && !root))
69
+ throw new Error('Invalid Git history record');
70
+ return { sha: sha, timestamp, hasParent };
71
+ }
72
+ //# sourceMappingURL=git-churn.js.map
@@ -0,0 +1 @@
1
+ export declare function gitExecutable(path?: string | undefined): string;
@@ -0,0 +1,31 @@
1
+ import { accessSync, constants, statSync } from 'node:fs';
2
+ import { delimiter, isAbsolute, join } from 'node:path';
3
+ let resolved;
4
+ export function gitExecutable(path = process.env.PATH) {
5
+ if (resolved && resolved.path === path)
6
+ return resolved.executable;
7
+ const executable = findGit(path);
8
+ resolved = { path, executable };
9
+ return executable;
10
+ }
11
+ function findGit(path) {
12
+ // Preserve native lookup for Windows and for PATH entries relative to the child's working directory.
13
+ if (process.platform === 'win32' || path === undefined)
14
+ return 'git';
15
+ for (const directory of path.split(delimiter)) {
16
+ if (!isAbsolute(directory))
17
+ return 'git';
18
+ const candidate = join(directory, 'git');
19
+ try {
20
+ if (!statSync(candidate).isFile())
21
+ continue;
22
+ accessSync(candidate, constants.X_OK);
23
+ return candidate;
24
+ }
25
+ catch {
26
+ // Continue searching when this entry cannot run Git.
27
+ }
28
+ }
29
+ return 'git';
30
+ }
31
+ //# sourceMappingURL=git-executable.js.map
@@ -0,0 +1,24 @@
1
+ import type { Subject } from '@repometry/core/internal/model/snapshot.js';
2
+ import type { ObjectSource } from '../../report/json/store/report-tree.js';
3
+ import type { Report, ReportReader } from '../../report/json/validation/report.js';
4
+ import type { CommitSummary } from '../../report/json/wire/summary-model.js';
5
+ /** Reads a report store straight from a Git revision of a storage branch, without a checkout. */
6
+ export declare class GitReportReader implements ReportReader {
7
+ private readonly directory;
8
+ private readonly revision;
9
+ private snapshot?;
10
+ private readonly cache;
11
+ private readonly blobs;
12
+ constructor(directory: string, revision: string);
13
+ read(subject: Subject): Promise<Report>;
14
+ list(): Promise<readonly Report[]>;
15
+ listSummaries(): Promise<readonly CommitSummary[]>;
16
+ private refreshMaintainability;
17
+ private reportIds;
18
+ private text;
19
+ private objects;
20
+ private pinnedSnapshot;
21
+ private resolveSnapshot;
22
+ }
23
+ /** Report objects as a storage branch revision holds them, to read or to restore a local store from. */
24
+ export declare function gitReportObjects(directory: string, revision: string): Promise<ObjectSource>;