@repometry/cli 0.0.0-dev.0 → 0.0.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 -3
  3. package/package.json +65 -2
  4. package/target/main/resources/language-catalog.json +61 -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 +530 -0
  15. package/target/main/resources/report/json/repository-summary-v1.schema.json +337 -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 +131 -0
  96. package/target/main/ts/compose/analysis-results.d.ts +42 -0
  97. package/target/main/ts/compose/analysis-results.js +84 -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 +125 -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 +77 -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 +26 -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 +36 -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,113 @@
1
+ import { checkMetaManifest } from '../../report/json/validation/metabranch.js';
2
+ import { GitBlobReader, gitTreeFiles } from './git.js';
3
+ import { qualitySummary } from '@repometry/core/internal/model/quality-summary.js';
4
+ import { utf8 } from '@repometry/core/internal/model/snapshot.js';
5
+ import { compareReports, readStoredReport, validSubjectId } from '../../report/json/validation/report.js';
6
+ import { headerSummary } from '../../report/json/store/local-store.js';
7
+ import { ObjectCache, objectPath, storedObjects } from '../../report/json/store/report-tree.js';
8
+ import { commitSummary, expandSummaryCatalog, needsMaintainabilityRefresh, orderSummaries } from '../../report/json/projections/commit-summary.js';
9
+ import { validateSummaryIndex } from '../../report/json/validation/summary-validation.js';
10
+ /** Reads a report store straight from a Git revision of a storage branch, without a checkout. */
11
+ export class GitReportReader {
12
+ directory;
13
+ revision;
14
+ snapshot;
15
+ cache = new ObjectCache();
16
+ blobs;
17
+ constructor(directory, revision) {
18
+ this.directory = directory;
19
+ this.revision = revision;
20
+ this.blobs = new GitBlobReader(directory);
21
+ }
22
+ async read(subject) {
23
+ if (subject.kind !== 'commit' || !validSubjectId('commit', subject.id))
24
+ throw new Error('Metabranch reports require a full source commit ID');
25
+ const tree = await this.pinnedSnapshot();
26
+ const text = await this.text(tree, `commits/${subject.id}/report.json`);
27
+ if (text === undefined)
28
+ throw Object.assign(new Error(`No report for ${subject.id} in ${this.revision}`), { code: 'ENOENT' });
29
+ return readStoredReport(text, subject, this.objects(tree));
30
+ }
31
+ async list() {
32
+ const reports = [];
33
+ for (const id of await this.reportIds(await this.pinnedSnapshot()))
34
+ reports.push(await this.read({ kind: 'commit', id }));
35
+ return reports.sort(compareReports);
36
+ }
37
+ async listSummaries() {
38
+ const tree = await this.pinnedSnapshot();
39
+ const [ids, index] = await Promise.all([this.reportIds(tree), this.text(tree, 'summary.json')]);
40
+ if (index !== undefined) {
41
+ const value = JSON.parse(index);
42
+ if (!validateSummaryIndex(value))
43
+ throw new Error(`Invalid Repometry summary in ${this.revision}`);
44
+ const shas = new Set(value.commits.map(row => row.sha));
45
+ if (shas.size === value.commits.length && ids.length === shas.size && ids.every(id => shas.has(id))
46
+ && value.commits.every(row => row.revision && row.counts && !row.detail)) {
47
+ return this.refreshMaintainability(expandSummaryCatalog(value));
48
+ }
49
+ }
50
+ // Without a complete summary.json, each report's first line carries its summary row.
51
+ const rows = [];
52
+ for (const id of ids) {
53
+ const text = await this.text(tree, `commits/${id}/report.json`);
54
+ if (text !== undefined)
55
+ rows.push(headerSummary(text, id) ?? commitSummary(await readStoredReport(text, { kind: 'commit', id }, this.objects(tree))));
56
+ }
57
+ return orderSummaries(rows);
58
+ }
59
+ refreshMaintainability(rows) {
60
+ if (!rows.some(needsMaintainabilityRefresh))
61
+ return rows;
62
+ return Promise.all(rows.map(async (row) => {
63
+ if (!needsMaintainabilityRefresh(row))
64
+ return row;
65
+ const report = await this.read({ kind: 'commit', id: row.sha });
66
+ return { ...row, quality: { ...row.quality, maintainability: qualitySummary(report).maintainability } };
67
+ }));
68
+ }
69
+ async reportIds(tree) {
70
+ return (await gitTreeFiles(this.directory, tree, 'commits')).flatMap(({ path }) => {
71
+ const id = /^commits\/([a-f0-9]+)\/report\.json$/.exec(path)?.[1];
72
+ return id && validSubjectId('commit', id) ? [id] : [];
73
+ });
74
+ }
75
+ async text(tree, path) {
76
+ const [blob] = await this.blobs.read([`${tree}:${path}`]);
77
+ return blob === undefined ? undefined : utf8(blob);
78
+ }
79
+ objects(tree) {
80
+ return treeObjects(this.blobs, tree, this.cache);
81
+ }
82
+ pinnedSnapshot() {
83
+ this.snapshot ??= this.resolveSnapshot().catch(error => {
84
+ this.snapshot = undefined;
85
+ throw error;
86
+ });
87
+ return this.snapshot;
88
+ }
89
+ async resolveSnapshot() {
90
+ const tree = await pinnedTree(this.blobs, this.directory, this.revision);
91
+ const manifest = await this.text(tree, 'manifest.json');
92
+ if (manifest === undefined)
93
+ throw new Error(`No Repometry manifest in ${this.revision}`);
94
+ checkMetaManifest(manifest);
95
+ return tree;
96
+ }
97
+ }
98
+ /** Report objects as a storage branch revision holds them, to read or to restore a local store from. */
99
+ export async function gitReportObjects(directory, revision) {
100
+ const blobs = new GitBlobReader(directory);
101
+ return treeObjects(blobs, await pinnedTree(blobs, directory, revision));
102
+ }
103
+ /** The tree a revision names, a commit's root tree or the tree itself, so later reads cannot move with the branch. */
104
+ async function pinnedTree(blobs, directory, revision) {
105
+ const tree = await blobs.id(`${revision}^{tree}`);
106
+ if (tree === undefined)
107
+ throw new Error(`${revision} is not a commit or tree in ${directory}`);
108
+ return tree;
109
+ }
110
+ function treeObjects(blobs, tree, cache) {
111
+ return storedObjects(ids => blobs.read(ids.map(id => `${tree}:${objectPath(id)}`)), cache);
112
+ }
113
+ //# sourceMappingURL=git-reader.js.map
@@ -0,0 +1,47 @@
1
+ import type { SourceSnapshot } from '@repometry/core/internal/model/snapshot.js';
2
+ import { GitBlobHistory } from './blob-history.js';
3
+ export declare function gitRoot(directory: string): Promise<string>;
4
+ export declare function physicalGitRoot(directory: string): Promise<string>;
5
+ export declare function gitText(directory: string, args: readonly string[], timeout?: number): Promise<string>;
6
+ export declare function gitUtf8(directory: string, args: readonly string[], timeout?: number): Promise<string>;
7
+ export declare function gitWorkingTreePaths(directory: string): Promise<readonly string[] | undefined>;
8
+ export declare function resolveGitCommit(directory: string, revision: string): Promise<string>;
9
+ /** Commits on the first-parent line of `head` after `base`, oldest first. */
10
+ export declare function firstParentRange(directory: string, base: string, head: string): Promise<{
11
+ readonly base: string;
12
+ readonly head: string;
13
+ readonly commits: readonly string[];
14
+ }>;
15
+ interface GitFile {
16
+ readonly path: string;
17
+ readonly oid: string;
18
+ readonly size?: number;
19
+ }
20
+ export declare function gitTreeFiles(directory: string, commit: string, prefix?: string, includeSize?: boolean): Promise<readonly GitFile[]>;
21
+ /**
22
+ * Reads blobs named like `<tree>:<path>` through one long-lived `git cat-file --batch`: requests stream in and answers
23
+ * come back in order. A name Git cannot find reads as undefined. The process keeps Node alive only while it owes answers.
24
+ */
25
+ export declare class GitBlobReader {
26
+ private readonly directory;
27
+ private child?;
28
+ private readonly pending;
29
+ private chunks;
30
+ constructor(directory: string);
31
+ read(names: readonly string[]): Promise<(Buffer | undefined)[]>;
32
+ /** The ID of the object a name resolves to, such as the tree of `<revision>^{tree}`. */
33
+ id(name: string): Promise<string | undefined>;
34
+ private request;
35
+ private start;
36
+ private receive;
37
+ private answer;
38
+ private stop;
39
+ }
40
+ export interface GitSelection {
41
+ readonly excludes: (path: string) => boolean;
42
+ readonly isSource: (path: string) => boolean;
43
+ readonly claims?: (path: string) => boolean;
44
+ readonly history?: GitBlobHistory;
45
+ }
46
+ export declare function readGitCommit(directory: string, revision: string, { excludes, isSource, claims, history }: GitSelection): Promise<SourceSnapshot>;
47
+ export {};
@@ -0,0 +1,289 @@
1
+ import { realpath } from 'node:fs/promises';
2
+ import { execFile, spawn } from 'node:child_process';
3
+ import { promisify } from 'node:util';
4
+ import { comparePaths, isExcludedDirectory, utf8 } from '@repometry/core/internal/model/snapshot.js';
5
+ import { binaryProbeBytes, isClaimedText, maxClaimedFileBytes } from '@repometry/core/internal/model/source.js';
6
+ import { isGeneratedSource } from '@repometry/core/internal/profile/exclusions.js';
7
+ import { gitExecutable } from './git-executable.js';
8
+ import { GitBlobHistory, gitBlobBatchBytes } from './blob-history.js';
9
+ const git = promisify(execFile);
10
+ const maxBuffer = gitBlobBatchBytes;
11
+ const oidPattern = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/;
12
+ const baseEnv = { ...process.env, GIT_NO_LAZY_FETCH: '1' };
13
+ function gitEnvironment() {
14
+ return { ...baseEnv, PATH: process.env.PATH };
15
+ }
16
+ export async function gitRoot(directory) {
17
+ try {
18
+ return (await gitText(directory, ['rev-parse', '--show-toplevel'])).replace(/\r?\n$/, '');
19
+ }
20
+ catch (error) {
21
+ const detail = error instanceof Error ? error.message : String(error);
22
+ const reason = `${directory} is not a Git repository`;
23
+ throw new Error(process.env.REPOMETRY_DEBUG === '1' ? `${reason}\n${detail}` : reason, { cause: error });
24
+ }
25
+ }
26
+ export async function physicalGitRoot(directory) {
27
+ return realpath(await gitRoot(directory));
28
+ }
29
+ export async function gitText(directory, args, timeout) {
30
+ const { stdout } = await git(gitExecutable(), ['--no-replace-objects', ...args], { cwd: directory, env: gitEnvironment(), maxBuffer, timeout });
31
+ return stdout;
32
+ }
33
+ export async function gitUtf8(directory, args, timeout) {
34
+ const result = await git(gitExecutable(), ['--no-replace-objects', ...args], { cwd: directory, env: gitEnvironment(), encoding: 'buffer', maxBuffer, timeout });
35
+ return utf8(result.stdout);
36
+ }
37
+ export async function gitWorkingTreePaths(directory) {
38
+ try {
39
+ const { stdout } = await git(gitExecutable(), ['--no-replace-objects', 'ls-files', '--cached', '--others', '--exclude-standard', '-z', '--', '.'], { cwd: directory, env: { ...gitEnvironment(), LC_ALL: 'C' }, encoding: 'buffer', maxBuffer });
40
+ return [...new Set(utf8(stdout).split('\0').filter(Boolean))];
41
+ }
42
+ catch (error) {
43
+ if (error instanceof Error && ('code' in error && error.code === 'ENOENT'
44
+ || 'stderr' in error && /fatal: not a git repository\b/.test(String(error.stderr))))
45
+ return undefined;
46
+ throw error;
47
+ }
48
+ }
49
+ export async function resolveGitCommit(directory, revision) {
50
+ let output;
51
+ try {
52
+ output = await gitText(directory, ['rev-parse', '--verify', '--end-of-options', `${revision}^{commit}`]);
53
+ }
54
+ catch (error) {
55
+ const detail = error instanceof Error ? error.message : String(error);
56
+ const reason = /not a git repository/i.test(detail) ? `${directory} is not a Git repository` : `${revision} is not a commit in ${directory}`;
57
+ throw new Error(process.env.REPOMETRY_DEBUG === '1' ? `${reason}\n${detail}` : reason, { cause: error });
58
+ }
59
+ const id = output.trim();
60
+ if (!oidPattern.test(id))
61
+ throw new Error('Git returned an invalid commit ID');
62
+ return id;
63
+ }
64
+ /** Commits on the first-parent line of `head` after `base`, oldest first. */
65
+ export async function firstParentRange(directory, base, head) {
66
+ const [from, to] = await Promise.all([resolveGitCommit(directory, base), resolveGitCommit(directory, head)]);
67
+ const commits = (await gitText(directory, ['rev-list', '--first-parent', '--reverse', `${from}..${to}`])).split('\n').filter(Boolean);
68
+ if (!commits.every(id => oidPattern.test(id)))
69
+ throw new Error('Git returned an invalid commit ID');
70
+ return { base: from, head: to, commits };
71
+ }
72
+ export async function gitTreeFiles(directory, commit, prefix, includeSize = false) {
73
+ if (!oidPattern.test(commit))
74
+ throw new Error('A full commit object ID is required');
75
+ const args = ['--no-replace-objects', '--literal-pathspecs', 'ls-tree', '-r', '-z', '--full-tree'];
76
+ if (includeSize)
77
+ args.push('--long');
78
+ args.push(commit);
79
+ if (prefix !== undefined)
80
+ args.push('--', prefix);
81
+ const tree = await git(gitExecutable(), args, { cwd: directory, env: gitEnvironment(), encoding: 'buffer', maxBuffer });
82
+ const entries = [];
83
+ for (const entry of utf8(tree.stdout).split('\0')) {
84
+ if (!entry)
85
+ continue;
86
+ const tab = entry.indexOf('\t');
87
+ const header = entry.slice(0, tab);
88
+ const match = /^100(?:644|755) blob ([a-f0-9]+)(?: +([0-9]+|-))?$/.exec(header);
89
+ const oid = match?.[1];
90
+ const path = entry.slice(tab + 1);
91
+ const size = Number(match?.[2]);
92
+ if (oid && oidPattern.test(oid))
93
+ entries.push({ path, oid, ...(Number.isSafeInteger(size) ? { size } : {}) });
94
+ }
95
+ return entries;
96
+ }
97
+ /**
98
+ * Reads blobs named like `<tree>:<path>` through one long-lived `git cat-file --batch`: requests stream in and answers
99
+ * come back in order. A name Git cannot find reads as undefined. The process keeps Node alive only while it owes answers.
100
+ */
101
+ export class GitBlobReader {
102
+ directory;
103
+ child;
104
+ pending = [];
105
+ chunks = [];
106
+ constructor(directory) {
107
+ this.directory = directory;
108
+ }
109
+ read(names) {
110
+ return Promise.all(names.map(name => this.request(name, 'blob')));
111
+ }
112
+ /** The ID of the object a name resolves to, such as the tree of `<revision>^{tree}`. */
113
+ id(name) {
114
+ return this.request(name, 'id');
115
+ }
116
+ request(name, want) {
117
+ return new Promise((resolve, reject) => {
118
+ if (/[\r\n]/.test(name))
119
+ throw new Error('Invalid Git object name');
120
+ const child = this.child ?? this.start();
121
+ if (this.pending.length === 0)
122
+ setHeld(child, true);
123
+ this.pending.push({ name, want, resolve, reject });
124
+ child.stdin.write(`${name}\n`);
125
+ });
126
+ }
127
+ start() {
128
+ const child = spawn(gitExecutable(), ['--no-replace-objects', 'cat-file', '--batch'], { cwd: this.directory, env: gitEnvironment() });
129
+ const errors = [];
130
+ child.stdout.on('data', (chunk) => this.receive(chunk));
131
+ child.stderr.on('data', (chunk) => errors.push(chunk));
132
+ const stop = (error) => this.stop(child, error);
133
+ child.on('error', stop);
134
+ child.stdin.on('error', stop);
135
+ child.on('close', () => stop(new Error(`git cat-file stopped: ${Buffer.concat(errors).toString('utf8').trim()}`)));
136
+ setHeld(child, false);
137
+ this.child = child;
138
+ return child;
139
+ }
140
+ receive(chunk) {
141
+ this.chunks.push(chunk);
142
+ let buffer = this.chunks.length === 1 ? chunk : Buffer.concat(this.chunks);
143
+ for (let request = this.pending[0]; request; request = this.pending[0]) {
144
+ const end = buffer.indexOf(10);
145
+ if (end < 0)
146
+ break;
147
+ const header = buffer.toString('utf8', 0, end);
148
+ if (header === `${request.name} missing`) {
149
+ buffer = buffer.subarray(end + 1);
150
+ this.answer(undefined);
151
+ continue;
152
+ }
153
+ const [, id, type, length] = /^([a-f0-9]+) ([a-z]+) (\d+)$/.exec(header) ?? [];
154
+ const size = Number(length);
155
+ if (!Number.isSafeInteger(size) || (request.want === 'blob' && type !== 'blob')) {
156
+ this.stop(this.child, new Error(`Unexpected Git object: ${request.name}`));
157
+ return;
158
+ }
159
+ if (buffer.length < end + size + 2)
160
+ break;
161
+ const blob = Buffer.from(buffer.subarray(end + 1, end + 1 + size));
162
+ buffer = buffer.subarray(end + size + 2);
163
+ this.answer(request.want === 'blob' ? blob : id);
164
+ }
165
+ this.chunks = buffer.length ? [buffer] : [];
166
+ }
167
+ answer(value) {
168
+ const request = this.pending.shift();
169
+ if (this.pending.length === 0 && this.child)
170
+ setHeld(this.child, false);
171
+ request.resolve(value);
172
+ }
173
+ stop(child, error) {
174
+ if (this.child !== child)
175
+ return;
176
+ this.child = undefined;
177
+ this.chunks = [];
178
+ for (const request of this.pending.splice(0))
179
+ request.reject(error);
180
+ child.kill();
181
+ }
182
+ }
183
+ /** A reader with nothing to answer must not keep the process running. */
184
+ function setHeld(child, held) {
185
+ for (const handle of [child, child.stdout, child.stdin, child.stderr]) {
186
+ if (held)
187
+ handle.ref();
188
+ else
189
+ handle.unref();
190
+ }
191
+ }
192
+ export async function readGitCommit(directory, revision, { excludes, isSource, claims, history }) {
193
+ const id = await resolveGitCommit(directory, revision);
194
+ const tracked = (await gitTreeFiles(directory, id, undefined, true)).filter(({ path }) => !path.split('/').slice(0, -1).some(isExcludedDirectory) && !excludes(path));
195
+ const entries = tracked.filter(({ path }) => isSource(path));
196
+ const claimed = tracked.filter(({ path }) => !isSource(path) && claims?.(path));
197
+ const large = claimed.filter(({ size }) => size !== undefined && size > maxClaimedFileBytes);
198
+ const binary = new Set();
199
+ for (const { path, oid } of large)
200
+ if (await isBinaryBlob(directory, oid))
201
+ binary.add(path);
202
+ const oversized = new Set(large.filter(({ path }) => !binary.has(path)).map(({ path }) => path));
203
+ const skipped = new Set(large.map(({ path }) => path));
204
+ const requested = claimed.filter(({ path }) => !skipped.has(path));
205
+ const blobs = await (history ?? new GitBlobHistory()).read(blobRequests(tracked.filter(({ path }) => !skipped.has(path)), entries, requested), ids => readBlobs(directory, ids));
206
+ const generated = new Set();
207
+ const files = entries.flatMap(({ path, oid }) => {
208
+ const bytes = blobs.get(oid)?.bytes;
209
+ if (!bytes)
210
+ throw new Error(`Git blob unavailable: ${oid}`);
211
+ if (!isGeneratedSource(bytes))
212
+ return [{ path, bytes: snapshotBytes(bytes, history) }];
213
+ generated.add(path);
214
+ return [];
215
+ });
216
+ for (const { path, oid } of requested) {
217
+ const bytes = blobs.get(oid)?.bytes;
218
+ if (bytes && isClaimedText(bytes))
219
+ files.push({ path, bytes: snapshotBytes(bytes, history) });
220
+ }
221
+ files.sort((left, right) => comparePaths(left.path, right.path));
222
+ const inventory = tracked.filter(({ path }) => !generated.has(path)).map(({ path, oid, size }) => ({ path, lines: blobs.get(oid)?.lines ?? null, ...(size === undefined ? {} : { bytes: size }) }));
223
+ const blobIds = new Map(tracked.map(({ path, oid }) => [path, oid]));
224
+ return { subject: { kind: 'commit', id }, files, blobIds, inventory, generatedExcluded: [...generated].sort(comparePaths),
225
+ ...(oversized.size ? { oversizedClaims: [...oversized].sort(comparePaths) } : {}) };
226
+ }
227
+ /** Whether the start of a blob holds a NUL byte; git is stopped once it has sent enough to tell. */
228
+ function isBinaryBlob(directory, oid) {
229
+ return new Promise((resolve, reject) => {
230
+ const child = spawn(gitExecutable(), ['--no-replace-objects', 'cat-file', 'blob', oid], { cwd: directory, env: gitEnvironment(), stdio: ['ignore', 'pipe', 'ignore'] });
231
+ let head = Buffer.alloc(0);
232
+ child.on('error', reject);
233
+ child.stdout.on('error', () => { });
234
+ child.stdout.on('data', (chunk) => {
235
+ head = Buffer.concat([head, chunk]);
236
+ if (head.length >= binaryProbeBytes)
237
+ child.kill();
238
+ });
239
+ child.on('close', () => resolve(head.subarray(0, binaryProbeBytes).includes(0)));
240
+ });
241
+ }
242
+ function snapshotBytes(bytes, history) {
243
+ // Inspectors receive mutable byte arrays. Keep retained Git data independent of those inputs.
244
+ return history === undefined ? bytes : Buffer.from(bytes);
245
+ }
246
+ function blobRequests(tracked, sources, claimed) {
247
+ const required = new Set(sources.map(({ oid }) => oid));
248
+ const contents = new Set([...required, ...claimed.map(({ oid }) => oid)]);
249
+ const byId = new Map(tracked.map(({ oid, size }) => [oid, size]));
250
+ const requests = [];
251
+ for (const [id, size] of byId) {
252
+ if (size !== undefined && size + 128 <= maxBuffer) {
253
+ requests.push({ id, estimatedBytes: size + 128, contents: contents.has(id) });
254
+ }
255
+ else if (required.has(id)) {
256
+ requests.push({ id, estimatedBytes: maxBuffer, contents: true });
257
+ }
258
+ }
259
+ return requests;
260
+ }
261
+ async function readBlobs(directory, ids) {
262
+ const command = git(gitExecutable(), ['--no-replace-objects', 'cat-file', '--batch'], { cwd: directory, env: gitEnvironment(), encoding: 'buffer', maxBuffer });
263
+ command.child.stdin?.on('error', () => { });
264
+ command.child.stdin?.end(`${ids.join('\n')}\n`);
265
+ const { stdout } = await command.catch((error) => {
266
+ if (error instanceof Error && 'code' in error && typeof error.code === 'number'
267
+ && 'stderr' in error && Buffer.isBuffer(error.stderr)) {
268
+ throw new Error(`git cat-file failed: ${error.stderr.toString('utf8').trim()}`, { cause: error });
269
+ }
270
+ throw error;
271
+ });
272
+ const blobs = new Map();
273
+ let cursor = 0;
274
+ for (const oid of ids) {
275
+ const end = stdout.indexOf(10, cursor);
276
+ if (end < 0)
277
+ throw new Error(`Missing Git blob header: ${oid}`);
278
+ const match = /^([a-f0-9]+) blob (\d+)$/.exec(stdout.toString('ascii', cursor, end));
279
+ const size = Number(match?.[2]);
280
+ const from = end + 1;
281
+ const to = from + size;
282
+ if (match?.[1] !== oid || !Number.isSafeInteger(size) || stdout[to] !== 10)
283
+ throw new Error(`Invalid Git blob: ${oid}`);
284
+ blobs.set(oid, stdout.subarray(from, to));
285
+ cursor = to + 1;
286
+ }
287
+ return blobs;
288
+ }
289
+ //# sourceMappingURL=git.js.map
@@ -0,0 +1,17 @@
1
+ import type { GitSelection } from './git.js';
2
+ import type { InventoryObserver } from './local.js';
3
+ export interface SourceSelection {
4
+ readonly directory: string;
5
+ readonly output: string;
6
+ readonly source: {
7
+ readonly workingTree: true;
8
+ } | {
9
+ readonly revision: string;
10
+ };
11
+ }
12
+ export declare function readInspectionSource(request: SourceSelection, selection: GitSelection, inventory?: InventoryObserver): Promise<{
13
+ root: string;
14
+ snapshot: import("@repometry/core/internal/model/source.js").SourceSnapshot;
15
+ excludedOutput: string | null;
16
+ output: string;
17
+ }>;
@@ -0,0 +1,36 @@
1
+ import { realpath } from 'node:fs/promises';
2
+ import { basename, dirname, join, relative, resolve, sep } from 'node:path';
3
+ import { gitRoot, gitWorkingTreePaths, readGitCommit } from './git.js';
4
+ import { containsPath, readWorkingTree } from './local.js';
5
+ export async function readInspectionSource(request, selection, inventory) {
6
+ const { excludes, isSource, claims } = selection;
7
+ const root = await realpath('workingTree' in request.source ? request.directory : await gitRoot(request.directory));
8
+ const output = await physicalPath(resolve(request.output));
9
+ if (containsPath(output, root) || output.split(sep).includes('.git')) {
10
+ throw new Error('Choose a dedicated report directory outside Git metadata');
11
+ }
12
+ const snapshot = 'workingTree' in request.source
13
+ ? await readWorkingTree(root, output, excludes, isSource, claims, await gitWorkingTreePaths(root), inventory)
14
+ : await readGitCommit(root, request.source.revision, selection);
15
+ if (inventory && snapshot.subject.kind === 'commit') {
16
+ for (const { path } of snapshot.inventory ?? [])
17
+ inventory.record(path);
18
+ }
19
+ const excludedOutput = snapshot.subject.kind === 'working-tree' && containsPath(root, output)
20
+ ? relative(root, output).split(sep).join('/') : null;
21
+ return { root, snapshot, excludedOutput, output };
22
+ }
23
+ async function physicalPath(path) {
24
+ try {
25
+ return await realpath(path);
26
+ }
27
+ catch (error) {
28
+ if (!(error instanceof Error && 'code' in error && error.code === 'ENOENT'))
29
+ throw error;
30
+ const parent = dirname(path);
31
+ if (parent === path)
32
+ throw error;
33
+ return join(await physicalPath(parent), basename(path));
34
+ }
35
+ }
36
+ //# sourceMappingURL=inspection-source.js.map
@@ -0,0 +1,6 @@
1
+ import type { LineChanges } from '@repometry/core/internal/model/changes.js';
2
+ /**
3
+ * The changed lines of every regular file between two commits, on both sides, following renames. A binary file, or one
4
+ * whose line breaks Git and parsers may count differently, changes as a whole.
5
+ */
6
+ export declare function readLineChanges(repository: string, base: string, head: string): Promise<LineChanges>;
@@ -0,0 +1,57 @@
1
+ import { addedRanges, diffMethod, oid, patchHunks, rawChanges, regularFile, removedRanges, stableDiff } from './changes.js';
2
+ import { GitBlobReader, gitText, gitUtf8 } from './git.js';
3
+ /**
4
+ * The changed lines of every regular file between two commits, on both sides, following renames. A binary file, or one
5
+ * whose line breaks Git and parsers may count differently, changes as a whole.
6
+ */
7
+ export async function readLineChanges(repository, base, head) {
8
+ if (!oid.test(base) || !oid.test(head))
9
+ throw new Error('Git diff requires full commit IDs');
10
+ if (base === head)
11
+ return { files: [] };
12
+ const raw = await gitUtf8(repository, ['diff', ...stableDiff, '--raw', '-z', '--no-abbrev',
13
+ `--find-renames=${diffMethod.renameThresholdPercent}%`, `-l${diffMethod.renameLimit}`, base, head, '--']);
14
+ const blobs = new GitBlobReader(repository);
15
+ const files = [];
16
+ // One file at a time: a large change must not start a Git process per file at once.
17
+ for (const change of rawChanges(raw)) {
18
+ const file = await fileChange(repository, blobs, change);
19
+ if (file)
20
+ files.push(file);
21
+ }
22
+ return { files };
23
+ }
24
+ async function fileChange(repository, blobs, change) {
25
+ const path = regularFile.test(change.mode) ? change.path : null;
26
+ const { previous } = change;
27
+ if (path === null && previous === undefined)
28
+ return undefined;
29
+ const text = (id) => id === undefined ? Promise.resolve('') : blobs.read([id]).then(([bytes]) => lineText(bytes));
30
+ const [headText, baseText] = await Promise.all([text(path === null ? undefined : change.oid), text(previous?.oid)]);
31
+ const file = { path, previous: previous?.path ?? null };
32
+ if (headText === undefined || baseText === undefined)
33
+ return { ...file, added: [], removed: [], whole: true, hunks: [] };
34
+ if (path === null || previous === undefined) {
35
+ return { ...file, added: wholeRange(headText), removed: wholeRange(baseText), whole: false, hunks: [] };
36
+ }
37
+ const patch = await gitText(repository, ['diff', ...stableDiff, '--text', '--unified=0', '--inter-hunk-context=0', previous.oid, change.oid, '--']);
38
+ return { ...file, added: addedRanges(patch), removed: removedRanges(patch), whole: false, hunks: patchHunks(patch) };
39
+ }
40
+ /** Text whose lines Git numbers the same way parsers do, or undefined. */
41
+ function lineText(bytes) {
42
+ if (bytes === undefined)
43
+ return undefined;
44
+ let text;
45
+ try {
46
+ text = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(bytes);
47
+ }
48
+ catch {
49
+ return undefined;
50
+ }
51
+ return /\0|\r(?!\n)|[\u2028\u2029]/.test(text) ? undefined : text;
52
+ }
53
+ function wholeRange(text) {
54
+ const count = text.split('\n').length - Number(text.endsWith('\n'));
55
+ return text === '' ? [] : [{ first: 1, last: count }];
56
+ }
57
+ //# sourceMappingURL=line-changes.js.map
@@ -0,0 +1,5 @@
1
+ export declare function readLocalSources(repository: string, cache?: string): {
2
+ read(revision: string, path: string, signal?: AbortSignal): Promise<Uint8Array | undefined>;
3
+ close: () => void;
4
+ };
5
+ export declare function sourceRemotes(repository: string): Promise<string[]>;
@@ -0,0 +1,48 @@
1
+ import { utf8 } from '@repometry/core/internal/model/snapshot.js';
2
+ import { validSubjectId } from '@repometry/core/internal/model/report.js';
3
+ import { isSourcePathname } from '@repometry/core/internal/ports/source-provider.js';
4
+ import { cacheRoot } from '../cache/root.js';
5
+ import { GitBlobBatch } from './blob-batch.js';
6
+ import { gitText, gitTreeFiles } from './git.js';
7
+ import { cachedBlob } from './source-cache.js';
8
+ export function readLocalSources(repository, cache = cacheRoot()) {
9
+ const git = new GitBlobBatch(repository);
10
+ const known = new Map();
11
+ return {
12
+ async read(revision, path, signal) {
13
+ if (!validSubjectId('commit', revision) || !isSourcePathname(path))
14
+ return undefined;
15
+ const key = revision + '\0' + path;
16
+ let oid = known.get(key);
17
+ if (oid === undefined) {
18
+ oid = gitTreeFiles(repository, revision, path).then(entries => entries.find(entry => entry.path === path)?.oid).catch(error => {
19
+ known.delete(key);
20
+ if (error instanceof Error && 'code' in error && typeof error.code === 'number')
21
+ return undefined;
22
+ throw error;
23
+ });
24
+ known.set(key, oid);
25
+ }
26
+ const id = await oid;
27
+ if (!id)
28
+ return undefined;
29
+ signal?.throwIfAborted();
30
+ const bytes = await cachedBlob(cache, id, () => git.read(id, signal));
31
+ if (!bytes || bytes.includes(0))
32
+ return undefined;
33
+ try {
34
+ utf8(bytes);
35
+ return bytes;
36
+ }
37
+ catch {
38
+ return undefined;
39
+ }
40
+ },
41
+ close: () => git.close(),
42
+ };
43
+ }
44
+ export async function sourceRemotes(repository) {
45
+ const origins = await gitText(repository, ['remote', 'get-url', '--all', 'origin']).catch(() => '');
46
+ return origins.split(/\r?\n/).filter(Boolean);
47
+ }
48
+ //# sourceMappingURL=local-sources.js.map
@@ -0,0 +1,7 @@
1
+ import type { SourceSnapshot } from '@repometry/core/internal/model/snapshot.js';
2
+ export declare function containsPath(parent: string, path: string): boolean;
3
+ export interface InventoryObserver {
4
+ candidate(path: string): boolean;
5
+ record(path: string): void;
6
+ }
7
+ export declare function readWorkingTree(directory: string, output: string, excludes: (path: string) => boolean, isSource: (path: string) => boolean, claims?: (path: string) => boolean, gitPaths?: readonly string[], inventory?: InventoryObserver): Promise<SourceSnapshot>;