@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,57 @@
1
+ /**
2
+ * Fills a locator's template. A path keeps its slashes under {path} and loses them under {path:component}, as the
3
+ * GitLab API wants. A fragment that names {line} is dropped when there is no line, so the link opens the file.
4
+ */
5
+ export function expandLocator(template, { revision, path, line }) {
6
+ const hash = template.indexOf('#');
7
+ const fragment = hash < 0 ? '' : template.slice(hash);
8
+ const base = hash < 0 ? template : template.slice(0, hash);
9
+ const kept = line === undefined && fragment.includes('{line}') ? '' : fragment;
10
+ const values = {
11
+ revision: encodeURIComponent(revision),
12
+ 'path:component': encodeURIComponent(path),
13
+ path: path.split('/').map(encodeURIComponent).join('/'),
14
+ line: String(line),
15
+ };
16
+ return (base + kept).replace(/\{(revision|path:component|path|line)\}/g, (_, name) => values[name]);
17
+ }
18
+ /** A locator the viewer can use: a fetch URL that is web or site-relative, and a page link only over http(s). */
19
+ export function sourceLocator(value) {
20
+ if (typeof value !== 'object' || value === null)
21
+ return undefined;
22
+ const { provider, url, web } = value;
23
+ if (typeof provider !== 'string' || typeof url !== 'string' || !url.includes('{path'))
24
+ return undefined;
25
+ if (/^[a-z][a-z\d+.-]*:/i.test(url) && !/^https?:\/\//i.test(url))
26
+ return undefined;
27
+ return { provider, url, ...(typeof web === 'string' && /^https?:\/\//i.test(web) ? { web } : {}) };
28
+ }
29
+ const providerNames = { github: 'GitHub', gitlab: 'GitLab', bitbucket: 'Bitbucket', gitea: 'Gitea' };
30
+ let locator;
31
+ const requests = new Map();
32
+ /** The export's locator, from the summary; none means the report has no source navigation. */
33
+ export function useSources(value) {
34
+ locator = value;
35
+ }
36
+ /**
37
+ * The file's text at the commit, or null when it cannot be had: no locator, a private repository, a commit that was
38
+ * never pushed, a network failure. Nothing is requested until a file or an excerpt opens; each URL is fetched once.
39
+ */
40
+ export function loadSource(sha, path) {
41
+ if (!locator)
42
+ return Promise.resolve(null);
43
+ const url = expandLocator(locator.url, { revision: sha, path });
44
+ let request = requests.get(url);
45
+ if (!request) {
46
+ request = fetch(url).then(response => response.ok ? response.text() : null).catch(() => null);
47
+ requests.set(url, request);
48
+ }
49
+ return request;
50
+ }
51
+ /** The page that shows the file on its forge, when the export names one. */
52
+ export function sourcePage(sha, path, line) {
53
+ if (!locator?.web)
54
+ return null;
55
+ const name = providerNames[locator.provider.toLowerCase()] ?? locator.provider.charAt(0).toUpperCase() + locator.provider.slice(1);
56
+ return { href: expandLocator(locator.web, { revision: sha, path, line }), provider: name };
57
+ }
@@ -0,0 +1,13 @@
1
+ import type { FileMetricsReport } from '../../json/wire/file-metrics-model.js';
2
+ import type { Clause, FileFacts } from './viewer-filter.js';
3
+ type FileEntry = FileMetricsReport['files'][number];
4
+ export interface Suggestion {
5
+ readonly group: string;
6
+ readonly label: string;
7
+ readonly detail?: string;
8
+ readonly clause: Clause;
9
+ readonly color?: string;
10
+ }
11
+ /** What the field offers for the typed text: the facets of this codebase first, then conditions, then the path. */
12
+ export declare function suggest(text: string, files: readonly FileEntry[], facts: FileFacts, chosen: readonly Clause[]): Suggestion[];
13
+ export {};
@@ -0,0 +1,91 @@
1
+ import { clauseLabel, parseWord, pluginMeasureList, sameClause } from './viewer-filter.js';
2
+ import { isIgnored, isLockfile, languageColor, languageOf, lockfilesLabel } from './viewer-languages.js';
3
+ /** Ready-made conditions offered before anything is typed: the questions people ask of a codebase most. */
4
+ const presets = [
5
+ { text: 'complexity>10', label: 'Complex functions' },
6
+ { text: 'coverage<80%', label: 'Under 80% covered' },
7
+ { text: 'duplication>0', label: 'Has duplication' },
8
+ { text: 'remediation>0', label: 'Has technical debt' },
9
+ { text: 'changes>0', label: 'Changed recently' },
10
+ { text: 'has:findings', label: 'Has findings' },
11
+ ];
12
+ /** The kinds of clause that read as a condition when typed out whole. */
13
+ const conditionKinds = new Set(['measure', 'has', 'analysed', 'lockfile']);
14
+ function quantity(total) {
15
+ return `${total.toLocaleString()} ${total === 1 ? 'file' : 'files'}`;
16
+ }
17
+ /** A facet is offered while nothing is typed, or when the text is in its name or begins its key. */
18
+ function offered(typing, name, key) {
19
+ return !typing.query || name.toLowerCase().includes(typing.query) || key.startsWith(typing.query);
20
+ }
21
+ function tallied(names) {
22
+ const counts = new Map();
23
+ for (const name of names)
24
+ counts.set(name, (counts.get(name) ?? 0) + 1);
25
+ return counts;
26
+ }
27
+ function languageSuggestions(files, typing) {
28
+ const counts = [...tallied(files.map(file => languageOf(file)))].sort((a, b) => b[1] - a[1]);
29
+ return counts.flatMap(([language, total]) => {
30
+ const clause = { kind: 'lang', value: language };
31
+ if (typing.taken(clause) || !offered(typing, language, 'lang'))
32
+ return [];
33
+ return [{ group: 'Languages', label: language, detail: quantity(total), clause, color: languageColor(language) }];
34
+ });
35
+ }
36
+ function componentSuggestions(facts, typing) {
37
+ return [...tallied([...facts.components.values()].flat())].flatMap(([name, total]) => {
38
+ const clause = { kind: 'component', value: name };
39
+ if (typing.taken(clause) || !offered(typing, name, 'component'))
40
+ return [];
41
+ return [{ group: 'Components', label: name, detail: quantity(total), clause }];
42
+ });
43
+ }
44
+ /** Files only counted, never read by a plugin, and lockfiles, are one condition away once the text names them. */
45
+ function categorySuggestions(files, typing) {
46
+ const { query } = typing;
47
+ const named = (words) => query.length >= 3
48
+ && words.some(phrase => phrase.startsWith(query) || (phrase.includes(' ') && phrase.includes(query)));
49
+ const categories = [
50
+ { label: 'Ignored files', clause: { kind: 'analysed', value: 'no' }, total: files.filter(isIgnored).length,
51
+ words: ['ignored files', 'ignored:yes', 'not analysed', 'analysed:no'] },
52
+ { label: lockfilesLabel, clause: { kind: 'lockfile', value: 'yes' }, total: files.filter(file => isLockfile(file.path)).length,
53
+ words: ['lockfiles', 'lockfile:yes'] },
54
+ ];
55
+ return categories.flatMap(({ label, clause, total, words }) => total && !typing.taken(clause) && named(words) ? [{ group: 'Conditions', label, detail: quantity(total), clause }] : []);
56
+ }
57
+ /** Other plugins' metrics are offered once the typed text names them; the presets stay Repometry's own. */
58
+ function conditionSuggestions(typing) {
59
+ const { query, taken } = typing;
60
+ const plugins = query ? pluginMeasureList().flatMap(([key, { label }]) => {
61
+ const clause = { kind: 'measure', measure: key, operator: '>', value: 0 };
62
+ if (taken(clause) || !(key.startsWith(query) || label.toLowerCase().includes(query)))
63
+ return [];
64
+ return [{ group: 'Conditions', label: `${label} above zero`, detail: `${label} > 0`, clause }];
65
+ }) : [];
66
+ const ready = presets.flatMap(preset => {
67
+ const clause = parseWord(preset.text);
68
+ const { key, value } = clauseLabel(clause);
69
+ const fits = !query || preset.label.toLowerCase().includes(query) || preset.text.startsWith(query) || key.toLowerCase().includes(query);
70
+ return !taken(clause) && fits ? [{ group: 'Conditions', label: preset.label, detail: `${key} ${value}`, clause }] : [];
71
+ });
72
+ return [...plugins, ...ready];
73
+ }
74
+ /** A condition typed out whole is offered as itself; otherwise the plugins' metrics and the presets are. */
75
+ function typedSuggestions(typed, typing) {
76
+ if (!typed || !conditionKinds.has(typed.kind) || typing.taken(typed))
77
+ return conditionSuggestions(typing);
78
+ const { key, value } = clauseLabel(typed);
79
+ return [{ group: 'Conditions', label: `${key} ${value}`, clause: typed }];
80
+ }
81
+ /** What the field offers for the typed text: the facets of this codebase first, then conditions, then the path. */
82
+ export function suggest(text, files, facts, chosen) {
83
+ const trimmed = text.trim();
84
+ const typing = { query: trimmed.toLowerCase(), taken: clause => chosen.some(other => sameClause(other, clause)) };
85
+ const typed = typing.query ? parseWord(trimmed) : null;
86
+ // A path is offered for any text that reads as no other kind of chip.
87
+ const path = typing.query && (!typed || typed.kind === 'path')
88
+ ? [{ group: 'Path', label: `Path contains “${trimmed}”`, clause: { kind: 'path', value: trimmed } }] : [];
89
+ return [...languageSuggestions(files, typing), ...componentSuggestions(facts, typing), ...categorySuggestions(files, typing),
90
+ ...typedSuggestions(typed, typing), ...path];
91
+ }
@@ -0,0 +1,5 @@
1
+ import type { Branch, MapDraw } from './viewer-map-shape.js';
2
+ /** The tree as rings: each level one ring further out, each wedge as wide as its share of its parent's lines. */
3
+ export declare function drawRings(map: MapDraw, children: readonly Branch[], first: number, last: number, level: number): void;
4
+ /** The ring's hole holds the total the map is sized by. */
5
+ export declare function centerLabel(total: number, units: string): SVGGElement;
@@ -0,0 +1,40 @@
1
+ import { count, svgElement } from './viewer-dom.js';
2
+ import { chartCenter, innerRadius, outerRadius, sectorPath } from './viewer-map-shape.js';
3
+ /** Wedges thinner than this angle, or past this many, are left out: they could be neither seen nor pointed at. */
4
+ const thinnest = 0.018;
5
+ const mostWedges = 144;
6
+ /** The tree as rings: each level one ring further out, each wedge as wide as its share of its parent's lines. */
7
+ export function drawRings(map, children, first, last, level) {
8
+ if (level >= map.depth)
9
+ return;
10
+ const ring = (outerRadius - innerRadius) / map.depth;
11
+ const total = children.reduce((sum, branch) => sum + branch.area, 0);
12
+ const scale = (last - first) / total;
13
+ let start = first;
14
+ for (const branch of children) {
15
+ const end = start + branch.area * scale;
16
+ if (end - start >= thinnest && map.drawn < mostWedges) {
17
+ const radius = innerRadius + level * ring;
18
+ map.tile(branch, sectorPath(radius, radius + ring, start, end));
19
+ drawRings(map, map.byParent.get(branch.entry.path) ?? [], start, end, level + 1);
20
+ }
21
+ start = end;
22
+ }
23
+ }
24
+ /** The ring's hole holds the total the map is sized by. */
25
+ export function centerLabel(total, units) {
26
+ const center = svgElement('g');
27
+ center.setAttribute('aria-hidden', 'true');
28
+ const value = svgElement('text');
29
+ value.setAttribute('x', String(chartCenter));
30
+ value.setAttribute('y', String(chartCenter + 1));
31
+ value.classList.add('fx-sunburst-value');
32
+ value.textContent = count(total);
33
+ const label = svgElement('text');
34
+ label.setAttribute('x', String(chartCenter));
35
+ label.setAttribute('y', String(chartCenter + 21));
36
+ label.classList.add('fx-sunburst-unit');
37
+ label.textContent = units;
38
+ center.append(value, label);
39
+ return center;
40
+ }
@@ -0,0 +1,25 @@
1
+ import type { ColumnSettings, Columns, MetricColumn } from './viewer-columns.js';
2
+ import type { Group, Row } from './viewer-table-rows.js';
3
+ export interface RowContext {
4
+ readonly group: Group;
5
+ readonly columns: readonly MetricColumn[];
6
+ readonly linkTo: (options?: {
7
+ directory?: string;
8
+ file?: string;
9
+ }) => string;
10
+ readonly selected?: string | undefined;
11
+ }
12
+ /** One row of the Metrics table: its name, with what it is and how many files it holds, then its figures. */
13
+ export declare function metricsRow(row: Row, context: RowContext, open?: () => void): HTMLTableRowElement;
14
+ /** Names a list as people say it: "a, b and c". */
15
+ export declare function spokenList(parts: readonly string[]): string;
16
+ /** The fold at the end of the list: how many entries no plugin read, opening and closing in place. */
17
+ export declare function unreadRow(entries: readonly Row[], span: number, expanded: boolean, toggle: () => void): HTMLTableRowElement;
18
+ /** The table with a sort button per column; a click on the sorted column reverses it. */
19
+ export declare function sortableTable(columns: Columns, settings: ColumnSettings, sorted: () => void): {
20
+ table: HTMLTableElement;
21
+ headers: HTMLTableCellElement[];
22
+ body: HTMLTableSectionElement;
23
+ };
24
+ /** Shows the chosen columns' headers and marks the one the table is sorted by. */
25
+ export declare function markSort(headers: readonly HTMLTableCellElement[], isVisible: (index: number) => boolean, settings: ColumnSettings): void;
@@ -0,0 +1,135 @@
1
+ import { basename, count, element, link, parentPath } from './viewer-dom.js';
2
+ import { duplicationContext } from './viewer-file-figures.js';
3
+ import { isLockfile, languageColor, languageOf } from './viewer-languages.js';
4
+ import { partialNote } from './viewer-totals.js';
5
+ const icons = { file: 'fx-file-icon', folder: 'fx-folder-icon', component: 'fx-component-icon' };
6
+ /** In the flat list the folder is context and the file name is the subject; a long folder wraps after a slash. */
7
+ function flatLabel(path) {
8
+ const slash = path.lastIndexOf('/');
9
+ const label = element('span', 'fx-entry-label');
10
+ if (slash >= 0) {
11
+ const folder = element('span', 'fx-entry-folder');
12
+ for (const part of path.slice(0, slash + 1).split(/(?<=\/)/))
13
+ folder.append(part, element('wbr'));
14
+ label.append(folder);
15
+ }
16
+ label.append(element('span', 'fx-entry-name', path.slice(slash + 1)));
17
+ return label;
18
+ }
19
+ /** A component opens as a filter where it can; the files no component holds are only a label. */
20
+ function componentAnchor(path, open) {
21
+ if (!open)
22
+ return element('span', 'fx-entry fx-entry-muted', path);
23
+ return Object.assign(element('button', 'fx-entry fx-entry-button', path), { type: 'button', onclick: open });
24
+ }
25
+ function entryAnchor(row, context, flat, open) {
26
+ const { entry, kind } = row;
27
+ if (kind === 'component')
28
+ return componentAnchor(entry.path, open);
29
+ const target = kind === 'folder' ? { directory: entry.path } : { directory: parentPath(entry.path), file: entry.path };
30
+ const anchor = link(context.linkTo(target), flat ? '' : basename(entry.path), 'fx-entry');
31
+ if (flat)
32
+ anchor.append(flatLabel(entry.path));
33
+ return anchor;
34
+ }
35
+ function entryIcon(row) {
36
+ const icon = element('span', icons[row.kind]);
37
+ icon.setAttribute('aria-hidden', 'true');
38
+ if (row.kind === 'file')
39
+ icon.style.color = isLockfile(row.entry.path) ? 'var(--lockfile)' : languageColor(languageOf(row.entry));
40
+ return icon;
41
+ }
42
+ function cell(entry, column, files) {
43
+ const result = element('td', 'numeric', column.display(entry));
44
+ if (column.value(entry) === 0)
45
+ result.classList.add('fx-zero');
46
+ if (column.label === 'Duplication')
47
+ result.title = duplicationContext(entry) ?? '';
48
+ const partial = files && column.present ? partialNote(files, column.present) : undefined;
49
+ if (partial) {
50
+ result.classList.add('fx-partial');
51
+ result.title = partial;
52
+ }
53
+ return result;
54
+ }
55
+ /** One row of the Metrics table: its name, with what it is and how many files it holds, then its figures. */
56
+ export function metricsRow(row, context, open) {
57
+ const { entry, kind } = row;
58
+ const result = element('tr');
59
+ const name = element('th', 'fx-path-column');
60
+ name.scope = 'row';
61
+ const anchor = entryAnchor(row, context, kind === 'file' && context.group !== 'folders', open);
62
+ anchor.prepend(entryIcon(row));
63
+ if (kind !== 'component')
64
+ anchor.setAttribute('title', entry.path);
65
+ if (entry.path === context.selected) {
66
+ anchor.setAttribute('aria-current', 'true');
67
+ result.dataset.selected = '';
68
+ }
69
+ name.append(anchor);
70
+ if (kind === 'file' && isLockfile(entry.path))
71
+ name.append(element('span', 'fx-entry-tag', 'Lockfile'));
72
+ if (kind !== 'file' && 'files' in entry)
73
+ name.append(element('span', 'fx-entry-count', count(entry.files)));
74
+ result.append(name, ...context.columns.map(column => cell(entry, column, row.files)));
75
+ return result;
76
+ }
77
+ function counted(total, one, many) {
78
+ return total ? `${count(total)} ${total === 1 ? one : many}` : '';
79
+ }
80
+ /** Names a list as people say it: "a, b and c". */
81
+ export function spokenList(parts) {
82
+ return [parts.slice(0, -1).join(', '), parts.at(-1)].filter(Boolean).join(' and ');
83
+ }
84
+ /** The fold at the end of the list: how many entries no plugin read, opening and closing in place. */
85
+ export function unreadRow(entries, span, expanded, toggle) {
86
+ const lockfiles = entries.filter(row => row.kind === 'file' && isLockfile(row.entry.path)).length;
87
+ const files = entries.filter(row => row.kind === 'file').length - lockfiles;
88
+ const folders = entries.length - files - lockfiles;
89
+ const parts = [counted(lockfiles, 'lockfile', 'lockfiles'), counted(files, 'file', 'files'), counted(folders, 'folder', 'folders')]
90
+ .filter(Boolean);
91
+ const row = element('tr', 'fx-unread');
92
+ const holder = element('td');
93
+ holder.colSpan = span;
94
+ const button = element('button', 'fx-unread-toggle', `${spokenList(parts)} ignored`);
95
+ button.type = 'button';
96
+ button.setAttribute('aria-expanded', String(expanded));
97
+ button.addEventListener('click', toggle);
98
+ holder.append(button);
99
+ row.append(holder);
100
+ return row;
101
+ }
102
+ /** The table with a sort button per column; a click on the sorted column reverses it. */
103
+ export function sortableTable(columns, settings, sorted) {
104
+ const table = element('table', 'fx-table');
105
+ const header = element('tr');
106
+ const thead = element('thead');
107
+ const body = element('tbody');
108
+ const headers = columns.map(({ label }, index) => {
109
+ const th = element('th', index ? 'numeric' : '');
110
+ th.scope = 'col';
111
+ const sort = element('button', 'fx-sort', label);
112
+ sort.type = 'button';
113
+ sort.addEventListener('click', () => {
114
+ settings.ascending = settings.sort === index ? !settings.ascending : index === 0 || (columns[index].ascending ?? false);
115
+ settings.sort = index;
116
+ sorted();
117
+ });
118
+ th.append(sort);
119
+ header.append(th);
120
+ return th;
121
+ });
122
+ thead.append(header);
123
+ table.append(thead, body);
124
+ return { table, headers, body };
125
+ }
126
+ /** Shows the chosen columns' headers and marks the one the table is sorted by. */
127
+ export function markSort(headers, isVisible, settings) {
128
+ headers.forEach((th, index) => {
129
+ th.hidden = !isVisible(index);
130
+ if (index === settings.sort)
131
+ th.setAttribute('aria-sort', settings.ascending ? 'ascending' : 'descending');
132
+ else
133
+ th.removeAttribute('aria-sort');
134
+ });
135
+ }
@@ -0,0 +1,56 @@
1
+ import type { InspectionDetails } from '../../json/wire/inspection-details-model.js';
2
+ import type { Directory, Metrics } from './viewer-inspection.js';
3
+ export type Group = 'folders' | 'files' | 'components';
4
+ export type RowKind = 'folder' | 'file' | 'component';
5
+ export interface Row {
6
+ readonly entry: Metrics;
7
+ readonly kind: RowKind;
8
+ /** The files a folder's or a component's total is made of. */
9
+ readonly files?: readonly Metrics[];
10
+ }
11
+ /** A row of the table, or the fold that stands for the ignored ones. */
12
+ export type DisplayRow = Row | {
13
+ readonly kind: 'unread';
14
+ };
15
+ /** The component row for the files no component claims: it cannot be opened as a filter. */
16
+ export declare const notInComponent = "Not in a component";
17
+ export declare function isGroup(value: string | undefined): value is Group;
18
+ /** Components, each totalled over the chosen files it holds, and a last row for the chosen files none holds. */
19
+ export declare function componentRows(components: NonNullable<InspectionDetails['components']>, files: readonly Metrics[], filtering: boolean): Row[];
20
+ /** A folder's own listing: the folders right under it with their recorded totals, then its files. */
21
+ export declare function folderRows(directories: readonly Directory[], files: readonly Metrics[], directory: string): Row[];
22
+ /** Filtered folders hold only what passes the query, and their totals count only that. */
23
+ export declare function filteredFolderRows(files: readonly Metrics[], directory: string): Row[];
24
+ /** Sorts in place by a column; sorted by path, folders come before files. */
25
+ export declare function sortRows(rows: Row[], byPath: boolean, value: (entry: Metrics) => string | number | null, ascending: boolean): Row[];
26
+ /**
27
+ * The code comes first, whatever the sort: files no plugin read, and folders holding only such files, fold into one
28
+ * row at the end, open or closed. A query that asks for them (`keep`), or a list of nothing else, shows them as they are.
29
+ */
30
+ export declare function foldUnread(rows: readonly Row[], unreadPaths: ReadonlySet<string>, keep: boolean, expanded: boolean): {
31
+ readonly display: readonly DisplayRow[];
32
+ readonly folded: readonly Row[];
33
+ };
34
+ /**
35
+ * The entries a page shows, 1-based, counting rows and not the fold of ignored files, which takes a place in the list
36
+ * but is no entry of its own. None where the page holds only the fold.
37
+ */
38
+ export declare function entryRange(display: readonly {
39
+ readonly kind: string;
40
+ }[], first: number, shown: number): [number, number] | null;
41
+ export interface ListCounts {
42
+ /** The rows of the list, without the fold. */
43
+ readonly rows: number;
44
+ /** Rows and the fold, as the pages hold them. */
45
+ readonly display: number;
46
+ /** The files the query selected, and the files of the folder it searched. */
47
+ readonly files: number;
48
+ readonly scope: number;
49
+ /** The first and last entry of the page, where the list has pages. */
50
+ readonly range: readonly [number, number] | null;
51
+ }
52
+ /**
53
+ * The line under the table. A filtered file list says how many of the folder's files it kept; other lists name the
54
+ * selection only once. An empty list that a hint explains says nothing more.
55
+ */
56
+ export declare function listSummary(group: Group, counts: ListCounts, filtering: boolean, hinted: boolean): string;
@@ -0,0 +1,97 @@
1
+ import { count, inside, parentPath } from './viewer-dom.js';
2
+ import { compareEntries } from './viewer-file-figures.js';
3
+ import { pageSize } from './viewer-inspection.js';
4
+ import { aggregate } from './viewer-totals.js';
5
+ /** The component row for the files no component claims: it cannot be opened as a filter. */
6
+ export const notInComponent = 'Not in a component';
7
+ export function isGroup(value) {
8
+ return value === 'folders' || value === 'files' || value === 'components';
9
+ }
10
+ const folderRow = (entry) => ({ entry, kind: 'folder' });
11
+ const fileRow = (entry) => ({ entry, kind: 'file' });
12
+ /** Components, each totalled over the chosen files it holds, and a last row for the chosen files none holds. */
13
+ export function componentRows(components, files, filtering) {
14
+ const chosen = new Map(files.map(entry => [entry.path, entry]));
15
+ const rows = components.map(({ component, paths }) => ({
16
+ entry: aggregate(component.name, paths.flatMap(path => chosen.get(path) ?? [])), kind: 'component',
17
+ files: paths.flatMap(path => chosen.get(path) ?? [])
18
+ }))
19
+ .filter(row => !filtering || row.entry.files > 0);
20
+ const assigned = new Set(components.flatMap(({ paths }) => paths));
21
+ const rest = files.filter(entry => !assigned.has(entry.path));
22
+ if (rest.length)
23
+ rows.push({ entry: aggregate(notInComponent, rest), kind: 'component', files: rest });
24
+ return rows;
25
+ }
26
+ /** A folder's own listing: the folders right under it with their recorded totals, then its files. */
27
+ export function folderRows(directories, files, directory) {
28
+ const under = (entry) => ({ ...folderRow(entry), files: files.filter(file => inside(file.path, entry.path)) });
29
+ return [...directories.filter(entry => entry.path && parentPath(entry.path) === directory).map(under),
30
+ ...files.filter(entry => parentPath(entry.path) === directory).map(fileRow)];
31
+ }
32
+ /** Filtered folders hold only what passes the query, and their totals count only that. */
33
+ export function filteredFolderRows(files, directory) {
34
+ const below = new Map();
35
+ const here = [];
36
+ const prefix = directory ? `${directory}/` : '';
37
+ for (const entry of files) {
38
+ const rest = entry.path.slice(prefix.length);
39
+ const slash = rest.indexOf('/');
40
+ if (slash < 0)
41
+ here.push(entry);
42
+ else {
43
+ const folder = prefix + rest.slice(0, slash);
44
+ below.set(folder, [...below.get(folder) ?? [], entry]);
45
+ }
46
+ }
47
+ return [...[...below].map(([path, entries]) => ({ ...folderRow(aggregate(path, entries)), files: entries })), ...here.map(fileRow)];
48
+ }
49
+ /** Sorts in place by a column; sorted by path, folders come before files. */
50
+ export function sortRows(rows, byPath, value, ascending) {
51
+ return rows.sort((a, b) => {
52
+ const files = Number(a.kind === 'file') - Number(b.kind === 'file');
53
+ return (byPath ? files : 0) || compareEntries(a.entry, b.entry, value, ascending);
54
+ });
55
+ }
56
+ /**
57
+ * The code comes first, whatever the sort: files no plugin read, and folders holding only such files, fold into one
58
+ * row at the end, open or closed. A query that asks for them (`keep`), or a list of nothing else, shows them as they are.
59
+ */
60
+ export function foldUnread(rows, unreadPaths, keep, expanded) {
61
+ const unread = (row) => row.kind === 'file' ? row.entry.analysed === false : row.kind === 'folder' && unreadPaths.has(row.entry.path);
62
+ const folded = keep ? [] : rows.filter(unread);
63
+ const read = rows.filter(row => !folded.includes(row));
64
+ if (!folded.length || !read.length)
65
+ return { display: rows, folded };
66
+ return { display: [...read, { kind: 'unread' }, ...expanded ? folded : []], folded };
67
+ }
68
+ /**
69
+ * The entries a page shows, 1-based, counting rows and not the fold of ignored files, which takes a place in the list
70
+ * but is no entry of its own. None where the page holds only the fold.
71
+ */
72
+ export function entryRange(display, first, shown) {
73
+ const entries = (from, to) => display.slice(from, to).filter(row => row.kind !== 'unread').length;
74
+ const before = entries(0, first);
75
+ const here = entries(first, first + shown);
76
+ return here ? [before + 1, before + here] : null;
77
+ }
78
+ const nouns = { components: ['component', 'components'], folders: ['entry', 'entries'],
79
+ files: ['file', 'files'] };
80
+ /**
81
+ * The line under the table. A filtered file list says how many of the folder's files it kept; other lists name the
82
+ * selection only once. An empty list that a hint explains says nothing more.
83
+ */
84
+ export function listSummary(group, counts, filtering, hinted) {
85
+ if (counts.rows === 0)
86
+ return hinted ? '' : 'No files match this selection.';
87
+ const [one, many] = nouns[group];
88
+ const paged = counts.display > pageSize;
89
+ const listsFiles = group === 'files' && counts.rows === counts.files;
90
+ const of = filtering && (paged || !listsFiles) ? ` · ${count(counts.files)} of ${count(counts.scope)} files selected` : '';
91
+ const total = `${count(counts.rows)} ${many}${of}`;
92
+ if (paged)
93
+ return counts.range ? `${count(counts.range[0])}–${count(counts.range[1])} of ${total}` : total;
94
+ if (filtering && listsFiles)
95
+ return `${count(counts.rows)} of ${count(counts.scope)} files`;
96
+ return `${count(counts.rows)} ${counts.rows === 1 ? one : many}${of}`;
97
+ }
@@ -0,0 +1,15 @@
1
+ import type { LanguageSyntax } from '../../json/wire/file-metrics-model.js';
2
+ export type TokenKind = '' | 'c' | 's' | 'n' | 'k';
3
+ export type Run = [TokenKind, string];
4
+ /**
5
+ * Splits lines into coloured runs by a language's syntax data: comments, strings, regular expressions, numbers and
6
+ * keywords. It honours escapes and character classes, and where the data asks for regular expressions it tells one from
7
+ * a division by what comes before the slash. State carries across lines, so a block comment or a multi-line string
8
+ * stays coloured to its end. Without syntax a line comes back as plain text.
9
+ */
10
+ export declare function tokenizer(syntax: LanguageSyntax | undefined): (line: string) => Run[];
11
+ export declare function sourceTokenizer(path: string): (line: string) => Run[];
12
+ /** A line's runs as nodes: coloured spans and plain text. */
13
+ export declare function runNodes(lineRuns: readonly Run[]): Node[];
14
+ /** Highlights a file's lines, or a snippet of them, by the syntax of the file's language. */
15
+ export declare function highlighter(path: string): (line: string) => Node[];