@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,222 @@
1
+ import { createCommitPicker } from './viewer-commit-picker.js';
2
+ import { loadViewerData, ViewerSummaryChanged } from './viewer-data.js';
3
+ import { byId, notice } from './viewer-dom.js';
4
+ import { renderFileView } from './viewer-files.js';
5
+ import { useCatalog } from './viewer-metrics.js';
6
+ import { renderInspection, renderQuality, renderScannerContext } from './viewer-overview-cards.js';
7
+ import { overviewStub, renderOverviewHotspots } from './viewer-overview-hotspots.js';
8
+ import { renderLead } from './viewer-overview-lead.js';
9
+ import { renderProfile } from './viewer-profile.js';
10
+ import { renderDiffCoverageTrend } from './viewer-pull-trend.js';
11
+ import { renderPulls } from './viewer-pulls.js';
12
+ import { href, isFilePage, needsDetails, readRoute } from './viewer-route.js';
13
+ import { firstArea, readOptional, renderTrend, showPage, showTab, showTitle, updateDetailsTabs, updateTabs, verdictTabs } from './viewer-shell.js';
14
+ import { loadSource, sourcePage, useSources } from './viewer-source.js';
15
+ import { renderTrendsPage } from './viewer-trends.js';
16
+ const mode = document.querySelector('meta[name="repometry-view"]')?.content;
17
+ showTitle();
18
+ document.querySelector('.skip')?.addEventListener('click', (event) => {
19
+ event.preventDefault();
20
+ byId('main').focus();
21
+ });
22
+ const message = byId('message');
23
+ try {
24
+ const data = await loadViewerData(mode);
25
+ if (data.reports.length === 0)
26
+ message.textContent = 'No commit inspections yet.';
27
+ else
28
+ start(data);
29
+ }
30
+ catch {
31
+ message.textContent = 'Could not load inspection history.';
32
+ }
33
+ function start(data) {
34
+ const { reports, quality, context, counts, pullReviewCount, branch, metrics, sources, loadDetails } = data;
35
+ useCatalog(metrics);
36
+ useSources(sources);
37
+ const commits = new Set(reports.map(report => report.sha));
38
+ const bySha = new Map(reports.map(report => [report.sha, report]));
39
+ const cached = new Map();
40
+ const pending = new Map();
41
+ const compact = window.matchMedia('(max-width: 43rem)');
42
+ const history = { quality, context };
43
+ let pulls;
44
+ let revision = 0;
45
+ let chartMetric = firstArea(data);
46
+ const route = () => readRoute(location.hash, commits, reports[0].sha);
47
+ function selectedDetails(sha) {
48
+ const existing = pending.get(sha);
49
+ if (existing)
50
+ return existing;
51
+ const request = loadDetails(sha).catch(error => {
52
+ if (error instanceof ViewerSummaryChanged && route().sha === sha)
53
+ location.reload();
54
+ return null;
55
+ }).then(asset => {
56
+ if (!asset)
57
+ pending.delete(sha);
58
+ else
59
+ remember(sha, asset);
60
+ return asset;
61
+ });
62
+ pending.set(sha, request);
63
+ return request;
64
+ }
65
+ function remember(sha, asset) {
66
+ cached.set(sha, asset.inspection);
67
+ if (asset.context)
68
+ context[sha] = { ...asset.context, boundary: context[sha]?.boundary ?? asset.context.boundary };
69
+ }
70
+ const commit = createCommitPicker(byId('commit-control'), reports, sha => {
71
+ const { page, view, period } = route();
72
+ location.hash = href({ page, sha, view, period });
73
+ }, branch);
74
+ const markVerdict = verdictTabs(metric => {
75
+ chartMetric = metric;
76
+ const { sha } = route();
77
+ renderTrend(trendData(), bySha.get(sha), chartMetric, compact.matches);
78
+ renderLead(reports, bySha.get(sha), history, chartMetric, cached.get(sha));
79
+ const details = cached.get(sha);
80
+ if (details)
81
+ renderOverviewHotspots(details, sha, chartMetric, context[sha]?.security !== undefined);
82
+ });
83
+ markVerdict(chartMetric);
84
+ byId('inspection-meta').hidden = false;
85
+ commit.hidden = false;
86
+ for (const item of document.querySelectorAll('[data-loaded]'))
87
+ item.hidden = false;
88
+ function loadPulls() {
89
+ pulls ??= readOptional('./pulls.json').then(bundle => bundle?.schema === 'urn:repometry:schema:pull-reviews:1' ? bundle.reviews : null);
90
+ return pulls;
91
+ }
92
+ function trendData() {
93
+ return {
94
+ reports, quality, context, compact: compact.matches, reviews: pullReviewCount,
95
+ link: (sha, view, period) => href({ page: 'trends', sha, view, period }),
96
+ };
97
+ }
98
+ function refreshTabs(page, sha, version, detail) {
99
+ const row = counts[sha];
100
+ const cachedDetail = cached.get(sha);
101
+ if (row)
102
+ updateTabs(page, row.findingCount, row.diagnosticCount);
103
+ else if (cachedDetail)
104
+ updateDetailsTabs(page, cachedDetail);
105
+ showTab('pulls', pullReviewCount > 0 || page === 'pulls');
106
+ void detail?.then(asset => {
107
+ if (!asset || version !== revision)
108
+ return;
109
+ updateDetailsTabs(page, asset.inspection);
110
+ renderScannerContext(context[sha], sha);
111
+ });
112
+ }
113
+ /** Pull request reviews load once, on the first page that needs them. */
114
+ function withPulls(target, version, show) {
115
+ notice(target, 'Loading saved pull request reviews…');
116
+ void loadPulls().then(records => {
117
+ if (version === revision)
118
+ show(records);
119
+ });
120
+ }
121
+ function showTrends(current, report, version) {
122
+ const slot = renderTrendsPage(byId('trends-content'), trendData(), report, current.view, current.period);
123
+ if (!slot)
124
+ return;
125
+ withPulls(slot, version, records => {
126
+ if (records?.length)
127
+ renderDiffCoverageTrend(slot, records);
128
+ else
129
+ notice(slot, 'No saved pull request reviews yet.');
130
+ });
131
+ }
132
+ function showPulls(version) {
133
+ const target = byId('pulls');
134
+ withPulls(target, version, records => {
135
+ if (records)
136
+ renderPulls(target, records);
137
+ else
138
+ notice(target, 'Could not load saved pull request reviews.');
139
+ });
140
+ }
141
+ /** The profile draws at once from the summary, and again with the details: exclusions, rules and ignores. */
142
+ function showSettings(report, version, detail) {
143
+ const newest = reports[0];
144
+ const draw = (details) => renderProfile(byId('settings-content'), {
145
+ report, context: context[report.sha], details,
146
+ latest: { report: newest, quality: quality[newest.sha], context: context[newest.sha] },
147
+ });
148
+ draw(cached.get(report.sha));
149
+ if (!cached.has(report.sha))
150
+ void detail?.then(asset => {
151
+ if (asset && version === revision)
152
+ draw(asset.inspection);
153
+ });
154
+ }
155
+ /** The Overview's hotspots, or a page that reads one inspection, drawn once its details are here. */
156
+ function showDetails(current, report, version, detail) {
157
+ const page = current.page;
158
+ const target = byId(page === 'overview' ? 'overview-hotspot-list' : `${page}-content`);
159
+ const display = (details) => {
160
+ if (isFilePage(page)) {
161
+ renderFileView(target, page, details, {
162
+ directory: current.directory ?? '', file: current.file ?? '', query: current.query, group: current.group, line: current.line,
163
+ category: current.category, level: current.level, rank: current.rank, layer: current.layer,
164
+ source: path => loadSource(report.sha, path),
165
+ sourcePage: (path, line) => sourcePage(report.sha, path, line),
166
+ href: (destination, options) => href({ page: destination, sha: report.sha, ...options }),
167
+ });
168
+ return;
169
+ }
170
+ // The details name the most complex function, so its figure can now lead to its line.
171
+ renderLead(reports, report, history, chartMetric, details);
172
+ renderOverviewHotspots(details, report.sha, chartMetric, context[report.sha]?.security !== undefined);
173
+ };
174
+ const existing = cached.get(report.sha);
175
+ if (existing) {
176
+ display(existing);
177
+ return;
178
+ }
179
+ if (page === 'overview')
180
+ overviewStub(report.sha);
181
+ else
182
+ notice(target, 'Loading inspection details…');
183
+ void detail?.then(asset => {
184
+ if (version !== revision)
185
+ return;
186
+ if (asset)
187
+ display(asset.inspection);
188
+ else
189
+ notice(target, 'Could not load inspection details.');
190
+ });
191
+ }
192
+ function render() {
193
+ const current = route();
194
+ const version = ++revision;
195
+ const report = bySha.get(current.sha);
196
+ const { page } = current;
197
+ commit.set(report.sha);
198
+ commit.hidden = page === 'pulls';
199
+ showPage(current);
200
+ renderInspection(report);
201
+ renderQuality(report, quality[report.sha]);
202
+ if (page === 'overview')
203
+ renderLead(reports, report, history, chartMetric, cached.get(report.sha));
204
+ renderScannerContext(context?.[current.sha], report.sha);
205
+ const detail = needsDetails(page) ? selectedDetails(report.sha) : undefined;
206
+ refreshTabs(page, report.sha, version, detail);
207
+ if (page === 'overview')
208
+ renderTrend(trendData(), report, chartMetric, compact.matches);
209
+ if (page === 'trends')
210
+ showTrends(current, report, version);
211
+ else if (page === 'pulls')
212
+ showPulls(version);
213
+ else if (page === 'settings')
214
+ showSettings(report, version, detail);
215
+ else
216
+ showDetails(current, report, version, detail);
217
+ }
218
+ window.addEventListener('hashchange', render);
219
+ compact.addEventListener('change', render);
220
+ message.hidden = true;
221
+ render();
222
+ }
@@ -0,0 +1,11 @@
1
+ import type { QualitySummary } from '@repometry/core/internal/model/quality-summary.js';
2
+ import type { PublicHistoryEntry } from '../../json/wire/public-history-model.js';
3
+ export interface SecurityCounts {
4
+ readonly critical?: number;
5
+ readonly high: number;
6
+ readonly medium: number;
7
+ readonly low: number;
8
+ readonly unknown: number;
9
+ }
10
+ /** The README badges. Security is available when the inspection recorded scanner counts. */
11
+ export declare function badges(report: PublicHistoryEntry | undefined, quality: QualitySummary | undefined, security?: SecurityCounts): Map<string, Buffer>;
@@ -0,0 +1,72 @@
1
+ import { coverageGrade, securityGrade } from '@repometry/core/internal/model/quality-summary.js';
2
+ const colors = { A: '#5ec269', B: '#74a83a', C: '#d9a400', D: '#ec8a2c', F: '#db4a3f' };
3
+ const unavailable = '#6b7684';
4
+ /** The README badges. Security is available when the inspection recorded scanner counts. */
5
+ export function badges(report, quality, security) {
6
+ const lines = report?.lineCoverage;
7
+ const ratio = lines && lines.total > 0 ? lines.covered / lines.total : null;
8
+ const grade = quality?.maintainability?.grade ?? null;
9
+ const coverage = lines && lines.total > 0 ? `${BigInt(lines.covered) * 100n / BigInt(lines.total)}%` : '—';
10
+ const files = new Map([
11
+ ['coverage.svg', badge('coverage', coverage, ratio === null ? null : coverageGrade(ratio))],
12
+ ['maintainability.svg', badge('maintainability', grade ?? '—', grade)],
13
+ ]);
14
+ if (security) {
15
+ const grade = securityGrade(security);
16
+ files.set('security.svg', badge('security', grade, grade));
17
+ }
18
+ return files;
19
+ }
20
+ function badge(name, value, grade) {
21
+ const fill = grade ? colors[grade] : unavailable;
22
+ const labelTextWidth = Math.round(textWidth(name));
23
+ const valueTextWidth = Math.round(textWidth(value) * 1.12);
24
+ const padding = 7;
25
+ const labelWidth = labelTextWidth + 2 * padding;
26
+ const valueWidth = valueTextWidth + 2 * padding;
27
+ const width = labelWidth + valueWidth;
28
+ const clipId = `${name}-clip`;
29
+ const labelId = `${name}-label`;
30
+ const valueId = `${name}-value`;
31
+ return Buffer.from(`<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="20" viewBox="0 0 ${width} 20" role="img" aria-label="${name}: ${value}">
32
+ <defs>
33
+ <clipPath id="${clipId}"><rect width="${width}" height="20" rx="3"/></clipPath>
34
+ <linearGradient id="${labelId}" x2="0" y2="100%">
35
+ <stop stop-color="#475265"/>
36
+ <stop offset="1" stop-color="#3a4557"/>
37
+ </linearGradient>
38
+ <linearGradient id="${valueId}" x2="0" y2="100%">
39
+ <stop stop-color="#fff" stop-opacity=".06"/>
40
+ <stop offset="1" stop-color="#000" stop-opacity=".06"/>
41
+ </linearGradient>
42
+ </defs>
43
+ <g clip-path="url(#${clipId})">
44
+ <rect width="${labelWidth}" height="20" fill="url(#${labelId})"/>
45
+ <rect x="${labelWidth}" width="${valueWidth}" height="20" fill="${fill}"/>
46
+ <rect x="${labelWidth}" width="${valueWidth}" height="20" fill="url(#${valueId})"/>
47
+ </g>
48
+ <g aria-hidden="true" fill="#fff" font-family="-apple-system,BlinkMacSystemFont,'Segoe UI','Noto Sans',Helvetica,Arial,sans-serif" font-size="11">
49
+ <text x="${padding}" y="14" font-weight="400" textLength="${labelTextWidth}" lengthAdjust="spacingAndGlyphs">${name}</text>
50
+ <text x="${labelWidth + padding}" y="14" font-weight="700" textLength="${valueTextWidth}" lengthAdjust="spacingAndGlyphs">${value}</text>
51
+ </g>
52
+ </svg>\n`);
53
+ }
54
+ function textWidth(text) {
55
+ let width = 0;
56
+ for (const character of text) {
57
+ if (/[ijl]/.test(character))
58
+ width += 3.4;
59
+ else if (/[mwMW]/.test(character))
60
+ width += 7.6;
61
+ else if (/[A-Z]/.test(character))
62
+ width += 7.4;
63
+ else if (/[0-9%]/.test(character))
64
+ width += 6.6;
65
+ else if (character === '—')
66
+ width += 11;
67
+ else
68
+ width += 6.2;
69
+ }
70
+ return width;
71
+ }
72
+ //# sourceMappingURL=badges.js.map
@@ -0,0 +1,16 @@
1
+ import type { ReadCommitMetadata } from '../../json/projections/commit-summary.js';
2
+ import type { CommitSummary, SourceLocator } from '../../json/wire/summary-model.js';
3
+ import type { Report, ReportReader } from '../../json/validation/report.js';
4
+ import type { PullReview } from '../../json/wire/pull-review-model.js';
5
+ import type { InspectionOptions } from '../../json/projections/inspection-details.js';
6
+ export interface SiteOptions extends InspectionOptions {
7
+ readonly title?: string;
8
+ readonly pulls?: readonly PullReview[];
9
+ readonly sources?: SourceLocator;
10
+ readonly branch?: string;
11
+ readonly readCommitMetadata?: ReadCommitMetadata;
12
+ }
13
+ export declare function viewerAssets(rows: readonly CommitSummary[], { title, pulls }: SiteOptions): Promise<Map<string, Buffer<ArrayBufferLike>>>;
14
+ export declare function siteFiles(reports: readonly Report[], options?: SiteOptions): Promise<Map<string, Buffer>>;
15
+ export declare function siteSummary(rows: readonly CommitSummary[], { components, pulls, sources, branch }: SiteOptions, inspectionPath?: (row: CommitSummary) => string | undefined): Buffer;
16
+ export declare function exportSite(reader: ReportReader, destination: string, options?: SiteOptions): Promise<void>;
@@ -0,0 +1,129 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { lstat, mkdir, readFile, readdir, rename, rm, writeFile } from 'node:fs/promises';
3
+ import { join } from 'node:path';
4
+ import { inspectionAsset } from '../../json/projections/inspection-details.js';
5
+ import { validateSummaryIndex } from '../../json/validation/summary-validation.js';
6
+ import { commitSummary, orderSummaries, repositorySummary, withCommitMetadata } from '../../json/projections/commit-summary.js';
7
+ import { packJson } from '../../json/wire/compact-json.js';
8
+ import { comparePaths, digest } from '@repometry/core/internal/model/snapshot.js';
9
+ import { pullReviewsSchema } from '../../json/wire/pull-review-model.js';
10
+ import { badges } from './badges.js';
11
+ const appDirectory = new URL('../app/', import.meta.url);
12
+ const wireDirectory = new URL('../../json/wire/', import.meta.url);
13
+ const resourceDirectory = new URL('../../../../resources/viewer/', import.meta.url);
14
+ async function listViewerAssets() {
15
+ const groups = await Promise.all([
16
+ listAssets(appDirectory, name => name.endsWith('.js')),
17
+ listAssets(wireDirectory, name => name.endsWith('.js')),
18
+ listAssets(resourceDirectory, name => name.endsWith('.css') || name === 'index.html'),
19
+ ]);
20
+ const assets = groups.flat().sort(([left], [right]) => comparePaths(left, right));
21
+ if (new Set(assets.map(([name]) => name)).size !== assets.length) {
22
+ throw new Error('The build contains duplicate viewer asset names');
23
+ }
24
+ return assets;
25
+ }
26
+ async function listAssets(directory, include) {
27
+ const entries = await readdir(directory, { withFileTypes: true });
28
+ return entries.filter(entry => entry.isFile() && include(entry.name))
29
+ .map(({ name }) => [name, new URL(encodeURIComponent(name), directory)]);
30
+ }
31
+ export async function viewerAssets(rows, { title = '', pulls = [] }) {
32
+ const files = new Map(await Promise.all((await listViewerAssets()).map(async ([name, source]) => {
33
+ const bytes = await readFile(source);
34
+ // The published viewer keeps its existing flat URLs for static hosts and open tabs.
35
+ const contents = source.href.startsWith(appDirectory.href)
36
+ ? Buffer.from(bytes.toString('utf8').replace(/(\b(?:from|import)\s*['"]|\bimport\(\s*['"])\.\.\/\.\.\/json\/wire\//g, '$1./'))
37
+ : bytes;
38
+ return [name, contents];
39
+ })));
40
+ const index = files.get('index.html').toString('utf8')
41
+ .replace('name="repometry-project" content=""', () => `name="repometry-project" content="${escapeAttribute(title)}"`);
42
+ files.set('index.html', Buffer.from(index));
43
+ const latest = rows[0];
44
+ for (const [name, data] of badges(latest, latest?.quality, latest?.counts?.security))
45
+ files.set(name, data);
46
+ files.set('pulls.json', Buffer.from(`${JSON.stringify({ schema: pullReviewsSchema, reviews: pulls })}\n`));
47
+ return files;
48
+ }
49
+ export async function siteFiles(reports, options = {}) {
50
+ const commits = reports.filter(report => report.subject.kind === 'commit');
51
+ const rows = orderSummaries(await withCommitMetadata(commits.map(commitSummary), options.readCommitMetadata));
52
+ const files = await viewerAssets(rows, options);
53
+ const details = new Map();
54
+ for (const report of commits) {
55
+ const sha = report.subject.id;
56
+ const data = JSON.stringify(packJson(inspectionAsset(report, options))) + '\n';
57
+ const name = `details/${sha}-${digest(data)}.json`;
58
+ details.set(sha, name);
59
+ files.set(name, Buffer.from(data));
60
+ }
61
+ files.set('summary.json', siteSummary(rows, options, row => details.get(row.sha)));
62
+ return files;
63
+ }
64
+ export function siteSummary(rows, { components, pulls = [], sources, branch }, inspectionPath) {
65
+ const ordered = orderSummaries(rows);
66
+ const commits = ordered.map((current, index) => {
67
+ const { counts, detail, revision, profileDigest, profileBoundary, subject, author, tags, ...row } = current;
68
+ const previous = ordered[index + 1];
69
+ const boundary = !previous ? undefined : !profileDigest || !previous.profileDigest ? 'unavailable'
70
+ : profileDigest === previous.profileDigest ? undefined : 'changed';
71
+ return {
72
+ ...row, subject, author, tags, detail: inspectionPath?.(current),
73
+ counts: counts && { ...counts, componentCount: components?.length ?? 0 },
74
+ ...(boundary === undefined ? {} : { profileBoundary: boundary }),
75
+ };
76
+ });
77
+ const summary = repositorySummary(commits, pulls.length, true);
78
+ return Buffer.from(`${JSON.stringify({ ...summary, ...(branch === undefined ? {} : { source: { branch } }),
79
+ ...(sources ? { sources } : {}) })}\n`);
80
+ }
81
+ export async function exportSite(reader, destination, options = {}) {
82
+ const files = await siteFiles(await reader.list(), options);
83
+ await mkdir(destination, { recursive: true, mode: 0o755 });
84
+ if (!(await lstat(destination)).isDirectory())
85
+ throw new Error('The viewer destination must be a directory');
86
+ const entries = await readdir(destination, { withFileTypes: true });
87
+ const detailDirectory = entries.some(entry => entry.name === 'details' && entry.isDirectory());
88
+ if (entries.some(entry => !(entry.isFile() && files.has(entry.name)) && !(entry.name === 'details' && entry.isDirectory()))) {
89
+ throw new Error('Use a dedicated viewer destination containing only Repometry export files');
90
+ }
91
+ if (detailDirectory) {
92
+ const existing = await readdir(join(destination, 'details'), { withFileTypes: true });
93
+ if (existing.some(entry => !entry.isFile() || !/^(?:[a-f0-9]{40}|[a-f0-9]{64})-[a-f0-9]{64}\.json$/.test(entry.name))) {
94
+ throw new Error('The viewer details directory contains files outside the export');
95
+ }
96
+ }
97
+ if (entries.length > 0) {
98
+ const existing = entries.some(entry => entry.name === 'summary.json')
99
+ ? JSON.parse(await readFile(join(destination, 'summary.json'), 'utf8')) : undefined;
100
+ if (!validateSummaryIndex(existing))
101
+ throw new Error('Choose an empty viewer directory or an existing Repometry export');
102
+ }
103
+ const staging = join(destination, `.export-${randomUUID()}`);
104
+ await mkdir(staging);
105
+ try {
106
+ const hasDetails = [...files.keys()].some(name => name.startsWith('details/'));
107
+ if (hasDetails)
108
+ await mkdir(join(staging, 'details'));
109
+ for (const [name, bytes] of files)
110
+ await writeFile(join(staging, name), bytes, { mode: 0o644 });
111
+ const afterDependencies = ['viewer.js', 'summary.json', 'index.html'];
112
+ const install = (name) => rename(join(staging, name), join(destination, name));
113
+ if (hasDetails && !detailDirectory)
114
+ await mkdir(join(destination, 'details'));
115
+ for (const name of files.keys()) {
116
+ if (!afterDependencies.includes(name))
117
+ await install(name);
118
+ }
119
+ for (const name of afterDependencies)
120
+ await install(name);
121
+ }
122
+ finally {
123
+ await rm(staging, { recursive: true, force: true });
124
+ }
125
+ }
126
+ function escapeAttribute(value) {
127
+ return value.replaceAll('&', '&amp;').replaceAll('"', '&quot;').replaceAll('<', '&lt;').replaceAll('>', '&gt;');
128
+ }
129
+ //# sourceMappingURL=export-site.js.map
@@ -0,0 +1,6 @@
1
+ import type { SourceAccess } from './source-route.js';
2
+ export declare function readExportedSummary(directory: string): Promise<import("../../../report.js").RepositorySummary | undefined>;
3
+ export declare function serveExportedSite(directory: string, port: number, access?: SourceAccess): Promise<{
4
+ url: string;
5
+ close: () => void;
6
+ }>;
@@ -0,0 +1,72 @@
1
+ import { lstat, readFile, realpath } from 'node:fs/promises';
2
+ import { join, sep } from 'node:path';
3
+ import { isRecord } from '@repometry/core/internal/engine/plugin.js';
4
+ import { unpackJson } from '../../json/wire/compact-json.js';
5
+ import { validateSummaryIndex } from '../../json/validation/summary-validation.js';
6
+ import { serveAssets } from './server.js';
7
+ import { sourceResponse } from './source-route.js';
8
+ export async function readExportedSummary(directory) {
9
+ const path = join(directory, 'summary.json');
10
+ const index = join(directory, 'index.html');
11
+ try {
12
+ if (!(await lstat(index)).isFile() || !(await lstat(path)).isFile())
13
+ return undefined;
14
+ const value = JSON.parse(await readFile(path, 'utf8'));
15
+ return validateSummaryIndex(value) ? value : undefined;
16
+ }
17
+ catch (error) {
18
+ if (error instanceof SyntaxError || missing(error))
19
+ return undefined;
20
+ throw error;
21
+ }
22
+ }
23
+ export async function serveExportedSite(directory, port, access) {
24
+ const root = await realpath(directory);
25
+ const summary = await readExportedSummary(root);
26
+ if (!summary)
27
+ throw new Error(`No exported report at ${directory}`);
28
+ const details = new Map(summary.commits.map(row => [row.sha, row.detail]));
29
+ const local = summary.sources?.provider === 'local' && summary.sources.url === './sources/{revision}/{path}' ? access : undefined;
30
+ async function file(name) {
31
+ if (name !== 'summary.json' && name !== 'pulls.json' && !/^[A-Za-z0-9_-]+\.(?:html|css|js|svg)$/.test(name)
32
+ && !/^details\/[a-f0-9]+-[a-f0-9]{64}\.json$/.test(name)) {
33
+ return undefined;
34
+ }
35
+ const path = join(root, name);
36
+ try {
37
+ if (!(await lstat(path)).isFile() || !((await realpath(path)).startsWith(root + sep)))
38
+ return undefined;
39
+ return readFile(path);
40
+ }
41
+ catch (error) {
42
+ if (missing(error))
43
+ return undefined;
44
+ throw error;
45
+ }
46
+ }
47
+ return serveAssets(port, async (name) => {
48
+ if (!name.startsWith('sources/'))
49
+ return file(name);
50
+ return sourceResponse(name, local, async (revision, path) => {
51
+ const detail = details.get(revision);
52
+ if (!detail?.startsWith(`details/${revision}-`))
53
+ return false;
54
+ const bytes = await file(detail);
55
+ if (!bytes)
56
+ return false;
57
+ const asset = unpackJson(JSON.parse(bytes.toString('utf8')));
58
+ if (!isRecord(asset) || asset.schema !== 'urn:repometry:schema:viewer-inspection:1'
59
+ || asset.sha !== revision || !isRecord(asset.inspection))
60
+ return false;
61
+ const { metrics, findings, diagnostics } = asset.inspection;
62
+ return (isRecord(metrics) && listsPath(metrics.files, path)) || listsPath(findings, path) || listsPath(diagnostics, path);
63
+ });
64
+ }, access?.close);
65
+ }
66
+ function listsPath(rows, path) {
67
+ return Array.isArray(rows) && rows.some(row => isRecord(row) && row.path === path);
68
+ }
69
+ function missing(error) {
70
+ return error instanceof Error && 'code' in error && (error.code === 'ENOENT' || error.code === 'ENOTDIR');
71
+ }
72
+ //# sourceMappingURL=exported-server.js.map
@@ -0,0 +1,7 @@
1
+ import type { ReportReader } from '../../json/validation/report.js';
2
+ import type { SiteOptions } from './export-site.js';
3
+ import type { SourceAccess } from './source-route.js';
4
+ export declare function serveSite(reader: ReportReader, port: number, options?: SiteOptions, source?: SourceAccess): Promise<{
5
+ url: string;
6
+ close: () => void;
7
+ }>;
@@ -0,0 +1,59 @@
1
+ import { reportRevision, validSubjectId } from '../../json/validation/report.js';
2
+ import { siteSummary, viewerAssets } from './export-site.js';
3
+ import { inspectionAsset } from '../../json/projections/inspection-details.js';
4
+ import { packJson } from '../../json/wire/compact-json.js';
5
+ import { commitSummary, orderSummaries, withCommitMetadata } from '../../json/projections/commit-summary.js';
6
+ import { serveAssets } from './server.js';
7
+ import { sourceResponse } from './source-route.js';
8
+ export async function serveSite(reader, port, options = {}, source) {
9
+ const indexed = await reader.listSummaries?.();
10
+ const reports = indexed ? [] : await reader.list();
11
+ const commits = new Map(reports.filter(report => report.subject.kind === 'commit').map(report => [report.subject.id, report]));
12
+ const rows = orderSummaries(await withCommitMetadata(indexed ?? [...commits.values()].map(commitSummary), options.readCommitMetadata));
13
+ const files = await viewerAssets(rows, options);
14
+ files.set('index.html', Buffer.from(files.get('index.html').toString('utf8')
15
+ .replace('name="repometry-view" content="private"', 'name="repometry-view" content="local"')));
16
+ files.set('summary.json', siteSummary(rows, options, liveInspectionPath));
17
+ async function read(sha) {
18
+ if (!validSubjectId('commit', sha))
19
+ return undefined;
20
+ if (!indexed)
21
+ return commits.get(sha);
22
+ try {
23
+ return await reader.read({ kind: 'commit', id: sha });
24
+ }
25
+ catch (error) {
26
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
27
+ return undefined;
28
+ throw error;
29
+ }
30
+ }
31
+ async function asset(name) {
32
+ if (name.startsWith('sources/'))
33
+ return sourceResponse(name, source, async (revision, path) => {
34
+ const report = await read(revision);
35
+ return report !== undefined && sourceListed(report, path);
36
+ });
37
+ if (name === 'summary.json' && reader.listSummaries) {
38
+ return siteSummary(await withCommitMetadata(await reader.listSummaries(), options.readCommitMetadata), options, liveInspectionPath);
39
+ }
40
+ const versioned = /^inspection\/([a-f0-9]+)-([a-f0-9]{64})\.json$/.exec(name);
41
+ if (versioned) {
42
+ const inspection = await read(versioned[1]);
43
+ return inspection && reportRevision(inspection) === versioned[2]
44
+ ? Buffer.from(JSON.stringify(packJson(inspectionAsset(inspection, options)))) : undefined;
45
+ }
46
+ return files.get(name);
47
+ }
48
+ return serveAssets(port, asset, source?.close);
49
+ }
50
+ function liveInspectionPath({ sha, revision }) {
51
+ return revision === undefined ? undefined : `inspection/${sha}-${revision}.json`;
52
+ }
53
+ function sourceListed(report, path) {
54
+ return (report.pluginData?.inventory ?? []).some(file => file.path === path)
55
+ || report.measurements.some(row => row.path === path)
56
+ || report.diagnostics.some(row => row.path === path)
57
+ || (report.findings ?? []).some(row => row.path === path || row.related?.some(location => location.path === path));
58
+ }
59
+ //# sourceMappingURL=local-server.js.map
@@ -0,0 +1 @@
1
+ export declare function exportProjects(directory: string): Promise<number>;