pr-checkmate 3.0.4 → 3.2.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 (384) hide show
  1. package/dist/{cli.js → cjs/cli.js} +30 -30
  2. package/dist/{config → cjs/config}/index.d.ts +2 -2
  3. package/dist/{config → cjs/config}/index.js +8 -7
  4. package/dist/{config → cjs/config}/loader.d.ts +1 -1
  5. package/dist/{config → cjs/config}/loader.js +8 -8
  6. package/dist/{core → cjs/core}/checks/dependencies/banned-imports.d.ts +1 -1
  7. package/dist/{core → cjs/core}/checks/dependencies/banned-imports.js +10 -10
  8. package/dist/{core → cjs/core}/checks/dependencies/circular-deps.d.ts +1 -1
  9. package/dist/{core → cjs/core}/checks/dependencies/circular-deps.js +27 -27
  10. package/dist/{core → cjs/core}/checks/dependencies/dependency-check.d.ts +1 -1
  11. package/dist/{core → cjs/core}/checks/dependencies/dependency-check.js +17 -17
  12. package/dist/{core → cjs/core}/checks/dependencies/grype-scan.d.ts +1 -1
  13. package/dist/{core → cjs/core}/checks/dependencies/grype-scan.js +18 -18
  14. package/dist/{core → cjs/core}/checks/dependencies/license-check.d.ts +1 -1
  15. package/dist/{core → cjs/core}/checks/dependencies/license-check.js +12 -12
  16. package/dist/{core → cjs/core}/checks/dependencies/npm-audit.d.ts +1 -1
  17. package/dist/{core → cjs/core}/checks/dependencies/npm-audit.js +14 -14
  18. package/dist/{core → cjs/core}/checks/dependencies/outdated-deps.d.ts +1 -1
  19. package/dist/{core → cjs/core}/checks/dependencies/outdated-deps.js +14 -14
  20. package/dist/{core → cjs/core}/checks/dependencies/vuln-scan.d.ts +1 -1
  21. package/dist/{core → cjs/core}/checks/dependencies/vuln-scan.js +14 -14
  22. package/dist/{core → cjs/core}/checks/findings.d.ts +1 -1
  23. package/dist/{core → cjs/core}/checks/findings.js +16 -16
  24. package/dist/{core → cjs/core}/checks/git/custom-rules.d.ts +1 -1
  25. package/dist/{core → cjs/core}/checks/git/custom-rules.js +19 -19
  26. package/dist/{core → cjs/core}/checks/git/diff-smell.d.ts +2 -2
  27. package/dist/{core → cjs/core}/checks/git/diff-smell.js +13 -13
  28. package/dist/{core → cjs/core}/checks/git/large-files.d.ts +1 -1
  29. package/dist/{core → cjs/core}/checks/git/large-files.js +15 -15
  30. package/dist/{core → cjs/core}/checks/git/leftover-debug.d.ts +1 -1
  31. package/dist/{core → cjs/core}/checks/git/leftover-debug.js +13 -13
  32. package/dist/{core → cjs/core}/checks/git/lockfile-drift.d.ts +1 -1
  33. package/dist/{core → cjs/core}/checks/git/lockfile-drift.js +12 -12
  34. package/dist/{core → cjs/core}/checks/git/merge-conflict.d.ts +1 -1
  35. package/dist/{core → cjs/core}/checks/git/merge-conflict.js +15 -15
  36. package/dist/{core → cjs/core}/checks/git/missing-tests.d.ts +1 -1
  37. package/dist/{core → cjs/core}/checks/git/missing-tests.js +15 -15
  38. package/dist/{core → cjs/core}/checks/git/todo-fixme.d.ts +1 -1
  39. package/dist/{core → cjs/core}/checks/git/todo-fixme.js +11 -11
  40. package/dist/{core → cjs/core}/checks/languages/cpp-format.d.ts +1 -1
  41. package/dist/{core → cjs/core}/checks/languages/cpp-format.js +18 -18
  42. package/dist/{core → cjs/core}/checks/languages/external-checks.d.ts +9 -9
  43. package/dist/{core → cjs/core}/checks/languages/external-checks.js +10 -10
  44. package/dist/{core → cjs/core}/checks/languages/external-runner.d.ts +2 -2
  45. package/dist/{core → cjs/core}/checks/languages/external-runner.js +21 -21
  46. package/dist/{core → cjs/core}/checks/languages/go-format.d.ts +1 -1
  47. package/dist/{core → cjs/core}/checks/languages/go-format.js +21 -21
  48. package/dist/cjs/core/checks/languages/lint.d.ts +2 -0
  49. package/dist/{core → cjs/core}/checks/languages/lint.js +21 -21
  50. package/dist/{core → cjs/core}/checks/languages/prettier.d.ts +1 -1
  51. package/dist/{core → cjs/core}/checks/languages/prettier.js +18 -18
  52. package/dist/{core → cjs/core}/checks/languages/python-format.d.ts +1 -1
  53. package/dist/{core → cjs/core}/checks/languages/python-format.js +14 -14
  54. package/dist/{core → cjs/core}/checks/languages/python-lint.d.ts +1 -1
  55. package/dist/{core → cjs/core}/checks/languages/python-lint.js +13 -13
  56. package/dist/{core → cjs/core}/checks/languages/python-typecheck.d.ts +1 -1
  57. package/dist/{core → cjs/core}/checks/languages/python-typecheck.js +29 -29
  58. package/dist/{core → cjs/core}/checks/languages/typecheck.d.ts +1 -1
  59. package/dist/{core → cjs/core}/checks/languages/typecheck.js +13 -13
  60. package/dist/{core → cjs/core}/checks/pr/commitlint.d.ts +1 -1
  61. package/dist/{core → cjs/core}/checks/pr/commitlint.js +12 -12
  62. package/dist/{core → cjs/core}/checks/pr/pr-body.d.ts +1 -1
  63. package/dist/{core → cjs/core}/checks/pr/pr-body.js +8 -8
  64. package/dist/{core → cjs/core}/checks/pr/pr-size-check.d.ts +1 -1
  65. package/dist/{core → cjs/core}/checks/pr/pr-size-check.js +10 -10
  66. package/dist/{core → cjs/core}/checks/pr/pr-title-lint.d.ts +1 -1
  67. package/dist/{core → cjs/core}/checks/pr/pr-title-lint.js +8 -8
  68. package/dist/{core → cjs/core}/checks/quality/case-collision.d.ts +1 -1
  69. package/dist/{core → cjs/core}/checks/quality/case-collision.js +7 -7
  70. package/dist/{core → cjs/core}/checks/quality/config-validation.d.ts +1 -1
  71. package/dist/{core → cjs/core}/checks/quality/config-validation.js +9 -9
  72. package/dist/{core → cjs/core}/checks/quality/coverage.d.ts +1 -1
  73. package/dist/{core → cjs/core}/checks/quality/coverage.js +4 -4
  74. package/dist/{core → cjs/core}/checks/quality/dead-code.d.ts +1 -1
  75. package/dist/{core → cjs/core}/checks/quality/dead-code.js +23 -23
  76. package/dist/{core → cjs/core}/checks/quality/duplicate-check.d.ts +1 -1
  77. package/dist/{core → cjs/core}/checks/quality/duplicate-check.js +22 -22
  78. package/dist/{core → cjs/core}/checks/quality/license-header.d.ts +1 -1
  79. package/dist/{core → cjs/core}/checks/quality/license-header.js +16 -16
  80. package/dist/{core → cjs/core}/checks/quality/markdown-lint.d.ts +1 -1
  81. package/dist/cjs/core/checks/quality/markdown-lint.js +147 -0
  82. package/dist/{core → cjs/core}/checks/quality/package-size.d.ts +1 -1
  83. package/dist/{core → cjs/core}/checks/quality/package-size.js +12 -12
  84. package/dist/{core → cjs/core}/checks/quality/spellcheck.d.ts +2 -2
  85. package/dist/{core → cjs/core}/checks/quality/spellcheck.js +18 -18
  86. package/dist/{core → cjs/core}/checks/quality/symlinks.d.ts +1 -1
  87. package/dist/{core → cjs/core}/checks/quality/symlinks.js +8 -8
  88. package/dist/{core → cjs/core}/checks/quality/yaml-lint.d.ts +1 -1
  89. package/dist/{core → cjs/core}/checks/quality/yaml-lint.js +12 -12
  90. package/dist/{core → cjs/core}/checks/security/diff-security.d.ts +1 -1
  91. package/dist/{core → cjs/core}/checks/security/diff-security.js +15 -15
  92. package/dist/{core → cjs/core}/checks/security/dockerfile-security.d.ts +1 -1
  93. package/dist/{core → cjs/core}/checks/security/dockerfile-security.js +16 -16
  94. package/dist/{core → cjs/core}/checks/security/migration-safety.d.ts +1 -1
  95. package/dist/{core → cjs/core}/checks/security/migration-safety.js +17 -17
  96. package/dist/{core → cjs/core}/checks/security/security.d.ts +1 -1
  97. package/dist/{core → cjs/core}/checks/security/security.js +21 -21
  98. package/dist/{core → cjs/core}/checks/security/sensitive-file-guard.d.ts +1 -1
  99. package/dist/{core → cjs/core}/checks/security/sensitive-file-guard.js +14 -14
  100. package/dist/{core → cjs/core}/checks/security/workflow-security.d.ts +2 -2
  101. package/dist/{core → cjs/core}/checks/security/workflow-security.js +14 -14
  102. package/dist/{core → cjs/core}/checks/tool-install.d.ts +1 -1
  103. package/dist/{core → cjs/core}/checks/tool-install.js +2 -2
  104. package/dist/{core → cjs/core}/context.d.ts +1 -1
  105. package/dist/{core → cjs/core}/context.js +16 -16
  106. package/dist/cjs/core/index.d.ts +4 -0
  107. package/dist/{core → cjs/core}/index.js +7 -7
  108. package/dist/{core → cjs/core}/install/cache.js +2 -2
  109. package/dist/{core → cjs/core}/install/doctor.d.ts +4 -4
  110. package/dist/{core → cjs/core}/install/doctor.js +34 -34
  111. package/dist/{core → cjs/core}/install/ensure.d.ts +2 -2
  112. package/dist/{core → cjs/core}/install/ensure.js +15 -14
  113. package/dist/{core → cjs/core}/install/lock.js +4 -4
  114. package/dist/{core → cjs/core}/install/prepare.d.ts +4 -4
  115. package/dist/{core → cjs/core}/install/prepare.js +13 -13
  116. package/dist/{core → cjs/core}/install/profiles.d.ts +2 -2
  117. package/dist/{core → cjs/core}/install/profiles.js +1 -1
  118. package/dist/{core → cjs/core}/install/reuse.d.ts +1 -1
  119. package/dist/{core → cjs/core}/install/reuse.js +4 -4
  120. package/dist/{core → cjs/core}/registry.d.ts +1 -1
  121. package/dist/cjs/core/registry.js +112 -0
  122. package/dist/{core → cjs/core}/reporters.d.ts +1 -1
  123. package/dist/{core → cjs/core}/reporters.js +28 -28
  124. package/dist/{core → cjs/core}/run-checks.d.ts +2 -2
  125. package/dist/{core → cjs/core}/run-checks.js +31 -31
  126. package/dist/{core → cjs/core}/targets.d.ts +1 -1
  127. package/dist/{core → cjs/core}/targets.js +20 -20
  128. package/dist/{core → cjs/core}/types.d.ts +3 -3
  129. package/dist/cjs/index.d.ts +12 -0
  130. package/dist/{index.js → cjs/index.js} +18 -18
  131. package/dist/{init.js → cjs/init.js} +68 -56
  132. package/dist/{interfaces → cjs/interfaces}/index.d.ts +3 -3
  133. package/dist/cjs/package.json +1 -0
  134. package/dist/{scripts → cjs/scripts}/copy-configs.js +22 -7
  135. package/dist/{scripts → cjs/scripts}/generate-install-manifests.js +2 -2
  136. package/dist/{scripts → cjs/scripts}/publish-github.js +4 -4
  137. package/dist/{utils → cjs/utils}/detect-language.js +12 -12
  138. package/dist/{utils → cjs/utils}/git.js +2 -2
  139. package/dist/{utils → cjs/utils}/http.js +2 -2
  140. package/dist/cjs/utils/index.d.ts +15 -0
  141. package/dist/{utils → cjs/utils}/index.js +13 -13
  142. package/dist/{utils → cjs/utils}/own-deps.d.ts +2 -0
  143. package/dist/{utils → cjs/utils}/own-deps.js +1 -0
  144. package/dist/{utils → cjs/utils}/package-version.js +2 -1
  145. package/dist/{utils → cjs/utils}/resolve-bin.js +2 -1
  146. package/dist/{utils → cjs/utils}/update-notifier.js +4 -4
  147. package/dist/esm/cli.d.ts +2 -0
  148. package/dist/esm/cli.js +137 -0
  149. package/dist/esm/config/constants.d.ts +153 -0
  150. package/dist/esm/config/constants.js +360 -0
  151. package/dist/esm/config/index.d.ts +40 -0
  152. package/dist/esm/config/index.js +60 -0
  153. package/dist/esm/config/loader.d.ts +6 -0
  154. package/dist/esm/config/loader.js +191 -0
  155. package/dist/esm/config/pr-checkmate-workflow-docker.yml +79 -0
  156. package/dist/esm/config/pr-checkmate-workflow.yml +92 -0
  157. package/dist/esm/core/checks/dependencies/banned-imports.d.ts +2 -0
  158. package/dist/esm/core/checks/dependencies/banned-imports.js +70 -0
  159. package/dist/esm/core/checks/dependencies/circular-deps.d.ts +2 -0
  160. package/dist/esm/core/checks/dependencies/circular-deps.js +155 -0
  161. package/dist/esm/core/checks/dependencies/dependency-check.d.ts +43 -0
  162. package/dist/esm/core/checks/dependencies/dependency-check.js +174 -0
  163. package/dist/esm/core/checks/dependencies/grype-scan.d.ts +22 -0
  164. package/dist/esm/core/checks/dependencies/grype-scan.js +112 -0
  165. package/dist/esm/core/checks/dependencies/license-check.d.ts +2 -0
  166. package/dist/esm/core/checks/dependencies/license-check.js +61 -0
  167. package/dist/esm/core/checks/dependencies/npm-audit.d.ts +6 -0
  168. package/dist/esm/core/checks/dependencies/npm-audit.js +80 -0
  169. package/dist/esm/core/checks/dependencies/outdated-deps.d.ts +2 -0
  170. package/dist/esm/core/checks/dependencies/outdated-deps.js +66 -0
  171. package/dist/esm/core/checks/dependencies/vuln-scan.d.ts +2 -0
  172. package/dist/esm/core/checks/dependencies/vuln-scan.js +54 -0
  173. package/dist/esm/core/checks/findings.d.ts +299 -0
  174. package/dist/esm/core/checks/findings.js +701 -0
  175. package/dist/esm/core/checks/git/custom-rules.d.ts +2 -0
  176. package/dist/esm/core/checks/git/custom-rules.js +106 -0
  177. package/dist/esm/core/checks/git/diff-smell.d.ts +19 -0
  178. package/dist/esm/core/checks/git/diff-smell.js +69 -0
  179. package/dist/esm/core/checks/git/large-files.d.ts +2 -0
  180. package/dist/esm/core/checks/git/large-files.js +112 -0
  181. package/dist/esm/core/checks/git/leftover-debug.d.ts +2 -0
  182. package/dist/esm/core/checks/git/leftover-debug.js +89 -0
  183. package/dist/esm/core/checks/git/lockfile-drift.d.ts +2 -0
  184. package/dist/esm/core/checks/git/lockfile-drift.js +114 -0
  185. package/dist/esm/core/checks/git/merge-conflict.d.ts +2 -0
  186. package/dist/esm/core/checks/git/merge-conflict.js +117 -0
  187. package/dist/esm/core/checks/git/missing-tests.d.ts +2 -0
  188. package/dist/esm/core/checks/git/missing-tests.js +105 -0
  189. package/dist/esm/core/checks/git/todo-fixme.d.ts +7 -0
  190. package/dist/esm/core/checks/git/todo-fixme.js +80 -0
  191. package/dist/esm/core/checks/languages/cpp-format.d.ts +7 -0
  192. package/dist/esm/core/checks/languages/cpp-format.js +91 -0
  193. package/dist/esm/core/checks/languages/external-checks.d.ts +77 -0
  194. package/dist/esm/core/checks/languages/external-checks.js +197 -0
  195. package/dist/esm/core/checks/languages/external-runner.d.ts +119 -0
  196. package/dist/esm/core/checks/languages/external-runner.js +138 -0
  197. package/dist/esm/core/checks/languages/go-format.d.ts +8 -0
  198. package/dist/esm/core/checks/languages/go-format.js +163 -0
  199. package/dist/esm/core/checks/languages/lint.d.ts +2 -0
  200. package/dist/esm/core/checks/languages/lint.js +92 -0
  201. package/dist/esm/core/checks/languages/prettier.d.ts +2 -0
  202. package/dist/esm/core/checks/languages/prettier.js +85 -0
  203. package/dist/esm/core/checks/languages/python-format.d.ts +7 -0
  204. package/dist/esm/core/checks/languages/python-format.js +61 -0
  205. package/dist/esm/core/checks/languages/python-lint.d.ts +9 -0
  206. package/dist/esm/core/checks/languages/python-lint.js +55 -0
  207. package/dist/esm/core/checks/languages/python-typecheck.d.ts +14 -0
  208. package/dist/esm/core/checks/languages/python-typecheck.js +184 -0
  209. package/dist/esm/core/checks/languages/ruff-shared.d.ts +10 -0
  210. package/dist/esm/core/checks/languages/ruff-shared.js +35 -0
  211. package/dist/esm/core/checks/languages/typecheck.d.ts +2 -0
  212. package/dist/esm/core/checks/languages/typecheck.js +61 -0
  213. package/dist/esm/core/checks/pr/commitlint.d.ts +2 -0
  214. package/dist/esm/core/checks/pr/commitlint.js +102 -0
  215. package/dist/esm/core/checks/pr/pr-body.d.ts +2 -0
  216. package/dist/esm/core/checks/pr/pr-body.js +43 -0
  217. package/dist/esm/core/checks/pr/pr-size-check.d.ts +2 -0
  218. package/dist/esm/core/checks/pr/pr-size-check.js +42 -0
  219. package/dist/esm/core/checks/pr/pr-title-lint.d.ts +2 -0
  220. package/dist/esm/core/checks/pr/pr-title-lint.js +31 -0
  221. package/dist/esm/core/checks/quality/case-collision.d.ts +8 -0
  222. package/dist/esm/core/checks/quality/case-collision.js +39 -0
  223. package/dist/esm/core/checks/quality/config-validation.d.ts +11 -0
  224. package/dist/esm/core/checks/quality/config-validation.js +188 -0
  225. package/dist/esm/core/checks/quality/coverage.d.ts +2 -0
  226. package/dist/esm/core/checks/quality/coverage.js +62 -0
  227. package/dist/esm/core/checks/quality/dead-code.d.ts +2 -0
  228. package/dist/esm/core/checks/quality/dead-code.js +124 -0
  229. package/dist/esm/core/checks/quality/duplicate-check.d.ts +2 -0
  230. package/dist/esm/core/checks/quality/duplicate-check.js +141 -0
  231. package/dist/esm/core/checks/quality/license-header.d.ts +7 -0
  232. package/dist/esm/core/checks/quality/license-header.js +81 -0
  233. package/dist/esm/core/checks/quality/markdown-lint.d.ts +2 -0
  234. package/dist/esm/core/checks/quality/markdown-lint.js +141 -0
  235. package/dist/esm/core/checks/quality/package-size.d.ts +36 -0
  236. package/dist/esm/core/checks/quality/package-size.js +196 -0
  237. package/dist/esm/core/checks/quality/spellcheck.d.ts +77 -0
  238. package/dist/esm/core/checks/quality/spellcheck.js +296 -0
  239. package/dist/esm/core/checks/quality/symlinks.d.ts +16 -0
  240. package/dist/esm/core/checks/quality/symlinks.js +57 -0
  241. package/dist/esm/core/checks/quality/yaml-lint.d.ts +20 -0
  242. package/dist/esm/core/checks/quality/yaml-lint.js +116 -0
  243. package/dist/esm/core/checks/security/diff-security.d.ts +2 -0
  244. package/dist/esm/core/checks/security/diff-security.js +354 -0
  245. package/dist/esm/core/checks/security/dockerfile-security.d.ts +2 -0
  246. package/dist/esm/core/checks/security/dockerfile-security.js +98 -0
  247. package/dist/esm/core/checks/security/migration-safety.d.ts +2 -0
  248. package/dist/esm/core/checks/security/migration-safety.js +137 -0
  249. package/dist/esm/core/checks/security/security.d.ts +63 -0
  250. package/dist/esm/core/checks/security/security.js +201 -0
  251. package/dist/esm/core/checks/security/sensitive-file-guard.d.ts +2 -0
  252. package/dist/esm/core/checks/security/sensitive-file-guard.js +160 -0
  253. package/dist/esm/core/checks/security/workflow-security.d.ts +12 -0
  254. package/dist/esm/core/checks/security/workflow-security.js +100 -0
  255. package/dist/esm/core/checks/tool-install.d.ts +102 -0
  256. package/dist/esm/core/checks/tool-install.js +66 -0
  257. package/dist/esm/core/commands.d.ts +27 -0
  258. package/dist/esm/core/commands.js +89 -0
  259. package/dist/esm/core/context.d.ts +62 -0
  260. package/dist/esm/core/context.js +241 -0
  261. package/dist/esm/core/index.d.ts +4 -0
  262. package/dist/esm/core/index.js +4 -0
  263. package/dist/esm/core/install/cache.d.ts +58 -0
  264. package/dist/esm/core/install/cache.js +142 -0
  265. package/dist/esm/core/install/doctor.d.ts +35 -0
  266. package/dist/esm/core/install/doctor.js +164 -0
  267. package/dist/esm/core/install/ensure.d.ts +77 -0
  268. package/dist/esm/core/install/ensure.js +269 -0
  269. package/dist/esm/core/install/lock.d.ts +34 -0
  270. package/dist/esm/core/install/lock.js +92 -0
  271. package/dist/esm/core/install/merge.d.ts +47 -0
  272. package/dist/esm/core/install/merge.js +85 -0
  273. package/dist/esm/core/install/prepare.d.ts +76 -0
  274. package/dist/esm/core/install/prepare.js +142 -0
  275. package/dist/esm/core/install/profiles.d.ts +78 -0
  276. package/dist/esm/core/install/profiles.js +192 -0
  277. package/dist/esm/core/install/reuse.d.ts +41 -0
  278. package/dist/esm/core/install/reuse.js +100 -0
  279. package/dist/esm/core/registry.d.ts +6 -0
  280. package/dist/esm/core/registry.js +109 -0
  281. package/dist/esm/core/reporters.d.ts +18 -0
  282. package/dist/esm/core/reporters.js +266 -0
  283. package/dist/esm/core/run-checks.d.ts +33 -0
  284. package/dist/esm/core/run-checks.js +293 -0
  285. package/dist/esm/core/targets.d.ts +140 -0
  286. package/dist/esm/core/targets.js +213 -0
  287. package/dist/esm/core/types.d.ts +195 -0
  288. package/dist/esm/core/types.js +38 -0
  289. package/dist/esm/index.d.ts +12 -0
  290. package/dist/esm/index.js +15 -0
  291. package/dist/esm/init.d.ts +38 -0
  292. package/dist/esm/init.js +421 -0
  293. package/dist/esm/interfaces/index.d.ts +432 -0
  294. package/dist/esm/interfaces/index.js +2 -0
  295. package/dist/esm/package.json +1 -0
  296. package/dist/esm/scripts/copy-configs.d.ts +1 -0
  297. package/dist/esm/scripts/copy-configs.js +64 -0
  298. package/dist/esm/scripts/generate-install-manifests.d.ts +39 -0
  299. package/dist/esm/scripts/generate-install-manifests.js +115 -0
  300. package/dist/esm/scripts/publish-github.d.ts +1 -0
  301. package/dist/esm/scripts/publish-github.js +45 -0
  302. package/dist/esm/utils/ci.d.ts +11 -0
  303. package/dist/esm/utils/ci.js +40 -0
  304. package/dist/esm/utils/detect-language.d.ts +48 -0
  305. package/dist/esm/utils/detect-language.js +234 -0
  306. package/dist/esm/utils/direct-deps.d.ts +21 -0
  307. package/dist/esm/utils/direct-deps.js +220 -0
  308. package/dist/esm/utils/execa.d.ts +22 -0
  309. package/dist/esm/utils/execa.js +10 -0
  310. package/dist/esm/utils/git.d.ts +14 -0
  311. package/dist/esm/utils/git.js +21 -0
  312. package/dist/esm/utils/glob.d.ts +24 -0
  313. package/dist/esm/utils/glob.js +40 -0
  314. package/dist/esm/utils/http.d.ts +59 -0
  315. package/dist/esm/utils/http.js +115 -0
  316. package/dist/esm/utils/index.d.ts +15 -0
  317. package/dist/esm/utils/index.js +26 -0
  318. package/dist/esm/utils/logger.d.ts +65 -0
  319. package/dist/esm/utils/logger.js +157 -0
  320. package/dist/esm/utils/own-deps.d.ts +16 -0
  321. package/dist/esm/utils/own-deps.js +107 -0
  322. package/dist/esm/utils/package-version.d.ts +4 -0
  323. package/dist/esm/utils/package-version.js +38 -0
  324. package/dist/esm/utils/pool.d.ts +49 -0
  325. package/dist/esm/utils/pool.js +113 -0
  326. package/dist/esm/utils/resolve-bin.d.ts +67 -0
  327. package/dist/esm/utils/resolve-bin.js +156 -0
  328. package/dist/esm/utils/result-collector.d.ts +33 -0
  329. package/dist/esm/utils/result-collector.js +44 -0
  330. package/dist/esm/utils/update-notifier.d.ts +19 -0
  331. package/dist/esm/utils/update-notifier.js +108 -0
  332. package/install-manifests/core/package-lock.json +4 -4
  333. package/install-manifests/core/package.json +1 -1
  334. package/install-manifests/duplicate/package-lock.json +0 -12
  335. package/install-manifests/js/package-lock.json +17 -41
  336. package/install-manifests/js/package.json +1 -1
  337. package/install-manifests/markdown/package-lock.json +1 -492
  338. package/install-manifests/markdown/package.json +1 -1
  339. package/package.json +17 -15
  340. package/dist/core/checks/languages/lint.d.ts +0 -2
  341. package/dist/core/checks/quality/markdown-lint.js +0 -110
  342. package/dist/core/index.d.ts +0 -4
  343. package/dist/core/registry.js +0 -112
  344. package/dist/index.d.ts +0 -12
  345. package/dist/utils/index.d.ts +0 -15
  346. /package/dist/{cli.d.ts → cjs/cli.d.ts} +0 -0
  347. /package/dist/{config → cjs/config}/constants.d.ts +0 -0
  348. /package/dist/{config → cjs/config}/constants.js +0 -0
  349. /package/dist/{config → cjs/config}/pr-checkmate-workflow-docker.yml +0 -0
  350. /package/dist/{config → cjs/config}/pr-checkmate-workflow.yml +0 -0
  351. /package/dist/{core → cjs/core}/checks/languages/ruff-shared.d.ts +0 -0
  352. /package/dist/{core → cjs/core}/checks/languages/ruff-shared.js +0 -0
  353. /package/dist/{core → cjs/core}/commands.d.ts +0 -0
  354. /package/dist/{core → cjs/core}/commands.js +0 -0
  355. /package/dist/{core → cjs/core}/install/cache.d.ts +0 -0
  356. /package/dist/{core → cjs/core}/install/lock.d.ts +0 -0
  357. /package/dist/{core → cjs/core}/install/merge.d.ts +0 -0
  358. /package/dist/{core → cjs/core}/install/merge.js +0 -0
  359. /package/dist/{core → cjs/core}/types.js +0 -0
  360. /package/dist/{init.d.ts → cjs/init.d.ts} +0 -0
  361. /package/dist/{interfaces → cjs/interfaces}/index.js +0 -0
  362. /package/dist/{scripts → cjs/scripts}/copy-configs.d.ts +0 -0
  363. /package/dist/{scripts → cjs/scripts}/generate-install-manifests.d.ts +0 -0
  364. /package/dist/{scripts → cjs/scripts}/publish-github.d.ts +0 -0
  365. /package/dist/{utils → cjs/utils}/ci.d.ts +0 -0
  366. /package/dist/{utils → cjs/utils}/ci.js +0 -0
  367. /package/dist/{utils → cjs/utils}/detect-language.d.ts +0 -0
  368. /package/dist/{utils → cjs/utils}/direct-deps.d.ts +0 -0
  369. /package/dist/{utils → cjs/utils}/direct-deps.js +0 -0
  370. /package/dist/{utils → cjs/utils}/execa.d.ts +0 -0
  371. /package/dist/{utils → cjs/utils}/execa.js +0 -0
  372. /package/dist/{utils → cjs/utils}/git.d.ts +0 -0
  373. /package/dist/{utils → cjs/utils}/glob.d.ts +0 -0
  374. /package/dist/{utils → cjs/utils}/glob.js +0 -0
  375. /package/dist/{utils → cjs/utils}/http.d.ts +0 -0
  376. /package/dist/{utils → cjs/utils}/logger.d.ts +0 -0
  377. /package/dist/{utils → cjs/utils}/logger.js +0 -0
  378. /package/dist/{utils → cjs/utils}/package-version.d.ts +0 -0
  379. /package/dist/{utils → cjs/utils}/pool.d.ts +0 -0
  380. /package/dist/{utils → cjs/utils}/pool.js +0 -0
  381. /package/dist/{utils → cjs/utils}/resolve-bin.d.ts +0 -0
  382. /package/dist/{utils → cjs/utils}/result-collector.d.ts +0 -0
  383. /package/dist/{utils → cjs/utils}/result-collector.js +0 -0
  384. /package/dist/{utils → cjs/utils}/update-notifier.d.ts +0 -0
@@ -0,0 +1,100 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { logger } from '../../utils/logger.js';
4
+ import { ownPackageRoot } from '../../utils/resolve-bin.js';
5
+ /**
6
+ * The major version we declare for a tool, from our own manifest.
7
+ *
8
+ * Read from `dependencies` rather than from the installed tree: what matters is
9
+ * the version our configuration was written against, and a hoisted install can
10
+ * resolve to something else entirely.
11
+ */
12
+ function ownMajor(pkgName) {
13
+ try {
14
+ const manifest = path.join(ownPackageRoot(), 'package.json');
15
+ const deps = JSON.parse(fs.readFileSync(manifest, 'utf-8')).dependencies;
16
+ const range = deps?.[pkgName];
17
+ if (!range)
18
+ return null;
19
+ // `^10.6.0`, `>=3.0.0`, `~5.1` — the leading number is the major in every
20
+ // form we declare. Deliberately not a semver parser: this package ships zero
21
+ // runtime dependencies on purpose, and a major comparison is the only
22
+ // question being asked.
23
+ const major = /(\d+)/.exec(range)?.[1];
24
+ return major ? Number(major) : null;
25
+ }
26
+ catch {
27
+ return null;
28
+ }
29
+ }
30
+ /** The major version of a package as the client actually has it installed. */
31
+ function installedMajor(pkgName, from) {
32
+ let dir = from;
33
+ while (dir !== path.dirname(dir)) {
34
+ const manifest = path.join(dir, 'node_modules', pkgName, 'package.json');
35
+ try {
36
+ if (fs.existsSync(manifest)) {
37
+ const version = JSON.parse(fs.readFileSync(manifest, 'utf-8'))
38
+ .version;
39
+ const major = version ? /(\d+)/.exec(version)?.[1] : undefined;
40
+ return major ? Number(major) : null;
41
+ }
42
+ }
43
+ catch {
44
+ return null;
45
+ }
46
+ dir = path.dirname(dir);
47
+ }
48
+ return null;
49
+ }
50
+ /**
51
+ * Decide whether this run should prefer the client's copy of `pkgName`.
52
+ *
53
+ * `compatible` (the default) reuses when the client's major matches ours, or when
54
+ * the client's own configuration is what the tool will read. A mismatch is not an
55
+ * error — we have our own copy — so it downgrades to ours with a line saying why.
56
+ */
57
+ export function reuseDecision(pkgName, ctx, opts = {}) {
58
+ const policy = ctx.config.install?.reuseLocal ?? 'compatible';
59
+ if (policy === 'off') {
60
+ return { reason: 'install.reuseLocal is "off" — using our own copy for reproducibility' };
61
+ }
62
+ const clientMajor = installedMajor(pkgName, ctx.cwd);
63
+ if (clientMajor === null) {
64
+ return { reason: `${pkgName} is not installed in the repository — using our own copy` };
65
+ }
66
+ if (policy === 'always') {
67
+ return {
68
+ paths: [ctx.cwd],
69
+ reason: `install.reuseLocal is "always" — using ${pkgName}@${clientMajor} from the repository`,
70
+ };
71
+ }
72
+ if (opts.clientOwnsConfig) {
73
+ return {
74
+ paths: [ctx.cwd],
75
+ reason: `using ${pkgName}@${clientMajor} from the repository — it reads the repository's own config`,
76
+ };
77
+ }
78
+ const ourMajor = ownMajor(pkgName);
79
+ if (ourMajor === null || clientMajor === ourMajor) {
80
+ return {
81
+ paths: [ctx.cwd],
82
+ reason: `using ${pkgName}@${clientMajor} from the repository (matches ours)`,
83
+ };
84
+ }
85
+ return {
86
+ reason: `the repository has ${pkgName}@${clientMajor} and our config is written for @${ourMajor} — using our own copy`,
87
+ };
88
+ }
89
+ /**
90
+ * The search roots a check should prefer for `pkgName`, logging the reason once.
91
+ *
92
+ * The reason is logged rather than returned to each caller because it answers the
93
+ * question every confusing lint result starts with — "whose ESLint ran" — and no
94
+ * check should have to remember to say so.
95
+ */
96
+ export function clientToolPaths(pkgName, ctx, opts = {}) {
97
+ const decision = reuseDecision(pkgName, ctx, opts);
98
+ logger.debug(`[reuseLocal]: ${decision.reason}`);
99
+ return decision.paths;
100
+ }
@@ -0,0 +1,6 @@
1
+ import { Check } from './types.js';
2
+ /**
3
+ * Every check, in declaration order. The orchestrator groups them by `phase`
4
+ * (blocking → informational → format) and runs each phase's checks in parallel.
5
+ */
6
+ export declare const REGISTRY: Check[];
@@ -0,0 +1,109 @@
1
+ import { bannedImportsCheck } from './checks/dependencies/banned-imports.js';
2
+ import { circularDepsCheck } from './checks/dependencies/circular-deps.js';
3
+ import { dependencyCheck } from './checks/dependencies/dependency-check.js';
4
+ import { grypeScanCheck } from './checks/dependencies/grype-scan.js';
5
+ import { licenseCheck } from './checks/dependencies/license-check.js';
6
+ import { npmAuditCheck } from './checks/dependencies/npm-audit.js';
7
+ import { outdatedDepsCheck } from './checks/dependencies/outdated-deps.js';
8
+ import { vulnScanCheck } from './checks/dependencies/vuln-scan.js';
9
+ import { customRulesCheck } from './checks/git/custom-rules.js';
10
+ import { diffSmellCheck } from './checks/git/diff-smell.js';
11
+ import { largeFilesCheck } from './checks/git/large-files.js';
12
+ import { leftoverDebugCheck } from './checks/git/leftover-debug.js';
13
+ import { lockfileDriftCheck } from './checks/git/lockfile-drift.js';
14
+ import { mergeConflictCheck } from './checks/git/merge-conflict.js';
15
+ import { missingTestsCheck } from './checks/git/missing-tests.js';
16
+ import { todoFixmeCheck } from './checks/git/todo-fixme.js';
17
+ import { cppFormatCheck } from './checks/languages/cpp-format.js';
18
+ import { csharpFormatCheck, goLintCheck, kotlinLintCheck, phpFormatCheck, rubyLintCheck, rustFormatCheck, rustLintCheck, shellcheckCheck, swiftLintCheck, } from './checks/languages/external-checks.js';
19
+ import { goFormatCheck } from './checks/languages/go-format.js';
20
+ import { lintCheck } from './checks/languages/lint.js';
21
+ import { prettierCheck } from './checks/languages/prettier.js';
22
+ import { pythonFormatCheck } from './checks/languages/python-format.js';
23
+ import { pythonLintCheck } from './checks/languages/python-lint.js';
24
+ import { pythonTypecheckCheck } from './checks/languages/python-typecheck.js';
25
+ import { typecheckCheck } from './checks/languages/typecheck.js';
26
+ import { commitlintCheck } from './checks/pr/commitlint.js';
27
+ import { prBodyCheck } from './checks/pr/pr-body.js';
28
+ import { prSizeCheck } from './checks/pr/pr-size-check.js';
29
+ import { prTitleLintCheck } from './checks/pr/pr-title-lint.js';
30
+ import { caseCollisionCheck } from './checks/quality/case-collision.js';
31
+ import { configValidationCheck } from './checks/quality/config-validation.js';
32
+ import { coverageCheck } from './checks/quality/coverage.js';
33
+ import { deadCodeCheck } from './checks/quality/dead-code.js';
34
+ import { duplicateCheck } from './checks/quality/duplicate-check.js';
35
+ import { licenseHeaderCheck } from './checks/quality/license-header.js';
36
+ import { markdownLintCheck } from './checks/quality/markdown-lint.js';
37
+ import { packageSizeCheck } from './checks/quality/package-size.js';
38
+ import { spellcheckCheck } from './checks/quality/spellcheck.js';
39
+ import { symlinksCheck } from './checks/quality/symlinks.js';
40
+ import { yamlLintCheck } from './checks/quality/yaml-lint.js';
41
+ import { diffSecurityCheck } from './checks/security/diff-security.js';
42
+ import { dockerfileSecurityCheck } from './checks/security/dockerfile-security.js';
43
+ import { migrationSafetyCheck } from './checks/security/migration-safety.js';
44
+ import { securityCheck } from './checks/security/security.js';
45
+ import { sensitiveFileGuardCheck } from './checks/security/sensitive-file-guard.js';
46
+ import { workflowSecurityCheck } from './checks/security/workflow-security.js';
47
+ /**
48
+ * Every check, in declaration order. The orchestrator groups them by `phase`
49
+ * (blocking → informational → format) and runs each phase's checks in parallel.
50
+ */
51
+ export const REGISTRY = [
52
+ // blocking
53
+ mergeConflictCheck,
54
+ securityCheck,
55
+ typecheckCheck,
56
+ lintCheck,
57
+ dependencyCheck,
58
+ npmAuditCheck,
59
+ circularDepsCheck,
60
+ licenseCheck,
61
+ // informational
62
+ diffSmellCheck,
63
+ diffSecurityCheck,
64
+ workflowSecurityCheck,
65
+ dockerfileSecurityCheck,
66
+ caseCollisionCheck,
67
+ vulnScanCheck,
68
+ grypeScanCheck,
69
+ customRulesCheck,
70
+ bannedImportsCheck,
71
+ licenseHeaderCheck,
72
+ configValidationCheck,
73
+ leftoverDebugCheck,
74
+ lockfileDriftCheck,
75
+ largeFilesCheck,
76
+ todoFixmeCheck,
77
+ missingTestsCheck,
78
+ coverageCheck,
79
+ migrationSafetyCheck,
80
+ sensitiveFileGuardCheck,
81
+ prBodyCheck,
82
+ duplicateCheck,
83
+ commitlintCheck,
84
+ prSizeCheck,
85
+ prTitleLintCheck,
86
+ outdatedDepsCheck,
87
+ markdownLintCheck,
88
+ spellcheckCheck,
89
+ yamlLintCheck,
90
+ symlinksCheck,
91
+ packageSizeCheck,
92
+ pythonLintCheck,
93
+ pythonTypecheckCheck,
94
+ deadCodeCheck,
95
+ swiftLintCheck,
96
+ kotlinLintCheck,
97
+ goLintCheck,
98
+ rustLintCheck,
99
+ rubyLintCheck,
100
+ shellcheckCheck,
101
+ // format
102
+ prettierCheck,
103
+ cppFormatCheck,
104
+ pythonFormatCheck,
105
+ goFormatCheck,
106
+ rustFormatCheck,
107
+ csharpFormatCheck,
108
+ phpFormatCheck,
109
+ ];
@@ -0,0 +1,18 @@
1
+ import type { CheckReport, ReporterConfig, ReporterKind } from './types.js';
2
+ /** Whether the comment reached the PR, so the caller can act on a failure. */
3
+ export interface PostOutcome {
4
+ attempted: boolean;
5
+ ok: boolean;
6
+ error?: string;
7
+ }
8
+ export declare function buildMarkdownReport(report: CheckReport, cfg?: ReporterConfig): string;
9
+ /**
10
+ * Emit the report through the selected channel.
11
+ * none: nothing · stdout: console table · github/gitlab/bitbucket: table +
12
+ * upsert the PR/MR comment · auto: detect the platform from the environment.
13
+ *
14
+ * Returns whether the comment reached the PR, so `runChecks` can honour
15
+ * `reporter.onPostFailure` — for teams whose review process depends on the
16
+ * comment, a silently lost report is worse than a red build.
17
+ */
18
+ export declare function report(kind: ReporterKind, result: CheckReport, cfg?: ReporterConfig): Promise<PostOutcome>;
@@ -0,0 +1,266 @@
1
+ import fs from 'node:fs';
2
+ import { paginate, request } from '../utils/http.js';
3
+ import { logger } from '../utils/index.js';
4
+ import { packageVersion } from '../utils/package-version.js';
5
+ const STATUS_ICON = {
6
+ pass: '✅',
7
+ warn: '⚠️',
8
+ fail: '❌',
9
+ skip: '⏭️',
10
+ };
11
+ // Unique marker so we can find and update the comment on re-runs.
12
+ const COMMENT_MARKER = '<!-- pr-checkmate-summary -->';
13
+ const SUMMARY_BORDER = '═══════════════════════════════════════════════════════════════';
14
+ const SUMMARY_RULE = '───────────────────────────────────────────────────────────────';
15
+ /** Page size asked for everywhere; both GitHub and GitLab cap at 100. */
16
+ const PER_PAGE = 100;
17
+ const SKIPPED = { attempted: false, ok: true };
18
+ function getPrContext() {
19
+ const token = process.env.GITHUB_TOKEN;
20
+ const repository = process.env.GITHUB_REPOSITORY;
21
+ const eventPath = process.env.GITHUB_EVENT_PATH;
22
+ if (!token || !repository || !eventPath || !fs.existsSync(eventPath)) {
23
+ return null;
24
+ }
25
+ try {
26
+ const event = JSON.parse(fs.readFileSync(eventPath, 'utf-8'));
27
+ const prNumber = event?.pull_request?.number;
28
+ if (!prNumber)
29
+ return null;
30
+ const [owner, repo] = repository.split('/');
31
+ return { token, owner, repo, prNumber };
32
+ }
33
+ catch {
34
+ return null;
35
+ }
36
+ }
37
+ /** Rows the client wants in the PR comment. */
38
+ function visibleResults(report, cfg) {
39
+ const include = cfg.include ?? {};
40
+ return report.results.filter(r => {
41
+ if (r.status === 'pass' && include.passed === false)
42
+ return false;
43
+ if (r.status === 'skip' && include.skipped === false)
44
+ return false;
45
+ return true;
46
+ });
47
+ }
48
+ export function buildMarkdownReport(report, cfg = {}) {
49
+ const { passed, warned, failed, skipped } = report.summary;
50
+ const include = cfg.include ?? {};
51
+ const rows = visibleResults(report, cfg);
52
+ const table = rows
53
+ .map(r => {
54
+ const details = r.details && include.details !== false ? ` — ${r.details}` : '';
55
+ return `| ${r.name} | ${STATUS_ICON[r.status]} ${r.status}${details} |`;
56
+ })
57
+ .join('\n');
58
+ const hidden = report.results.length - rows.length;
59
+ return [
60
+ COMMENT_MARKER,
61
+ '## PR CheckMate Summary',
62
+ '',
63
+ `**${passed} passed** · **${warned} warnings** · **${failed} failed** · **${skipped} skipped**`,
64
+ '',
65
+ '| Check | Result |',
66
+ '|---|---|',
67
+ table,
68
+ // Say so rather than letting the table quietly disagree with the counts above.
69
+ ...(hidden > 0 ? ['', `_${hidden} row(s) hidden by \`reporter.include\`._`] : []),
70
+ '',
71
+ `_Generated by [PR CheckMate](https://www.npmjs.com/package/pr-checkmate) v${packageVersion()}_`,
72
+ ].join('\n');
73
+ }
74
+ /**
75
+ * The run summary, printed verbatim.
76
+ *
77
+ * `logger.print` rather than `logger.info`: this is the product's output, not a
78
+ * note about producing it. Sent through the log formatter, every line picked up
79
+ * an ISO timestamp and a level tag, which pushed the box borders out of
80
+ * alignment — the headline artefact of the whole run looked broken.
81
+ */
82
+ function printStdout(report, cfg) {
83
+ const { passed, warned, failed, skipped } = report.summary;
84
+ logger.print('');
85
+ logger.print(SUMMARY_BORDER);
86
+ // The version belongs in the headline, not in a footnote. Which copy of
87
+ // pr-checkmate produced a report is the first thing to establish when the
88
+ // report disagrees with what someone expects, and it is not otherwise
89
+ // recoverable from the log: a stale global install answers `pr-checkmate` on
90
+ // `PATH` ahead of the project's own, and reads the same config while doing it.
91
+ logger.print(` PR CheckMate Summary · v${packageVersion()}`);
92
+ logger.print(SUMMARY_BORDER);
93
+ for (const r of report.results) {
94
+ const details = r.details ? `: ${r.details}` : '';
95
+ logger.print(` ${STATUS_ICON[r.status]} ${r.name}${details}`);
96
+ }
97
+ logger.print(SUMMARY_RULE);
98
+ logger.print(` ✅ ${passed} passed ⚠️ ${warned} warnings ❌ ${failed} failed ⏭️ ${skipped} skipped`);
99
+ logger.print(SUMMARY_BORDER);
100
+ if (cfg.include?.docsLink !== false) {
101
+ // The docs cover every check and config key.
102
+ logger.print(' DOCUMENTATION: https://pr-checkmate-docs.pages.dev/');
103
+ }
104
+ }
105
+ /** Network settings shared by every platform call. */
106
+ function httpOptions(cfg, label) {
107
+ return {
108
+ timeoutMs: cfg.timeoutMs,
109
+ retries: cfg.retries,
110
+ maxPages: cfg.maxPages,
111
+ label,
112
+ };
113
+ }
114
+ /** Log and shape the result of a write. */
115
+ function finish(platform, res, verb) {
116
+ if (res.ok) {
117
+ logger.info(`[reporter]: ✅ ${verb} PR CheckMate summary on ${platform}`);
118
+ return { attempted: true, ok: true };
119
+ }
120
+ logger.warn(`[reporter]: ⚠️ Could not ${verb.toLowerCase()} ${platform} comment: ${res.error}`);
121
+ return { attempted: true, ok: false, error: res.error };
122
+ }
123
+ /** Page-number pagination: stop as soon as a page comes back short. */
124
+ function pageAfter(base, count, page) {
125
+ return count < PER_PAGE ? null : `${base}${base.includes('?') ? '&' : '?'}page=${page + 1}`;
126
+ }
127
+ async function upsertGithubComment(body, cfg) {
128
+ const ctx = getPrContext();
129
+ if (!ctx) {
130
+ logger.info('[reporter]: Skipping GitHub comment (not in PR context or GITHUB_TOKEN missing)');
131
+ return SKIPPED;
132
+ }
133
+ const { token, owner, repo, prNumber } = ctx;
134
+ const apiBase = `https://api.github.com/repos/${owner}/${repo}`;
135
+ const listBase = `${apiBase}/issues/${prNumber}/comments?per_page=${PER_PAGE}`;
136
+ const headers = {
137
+ Authorization: `Bearer ${token}`,
138
+ 'User-Agent': 'pr-checkmate',
139
+ Accept: 'application/vnd.github.v3+json',
140
+ 'Content-Type': 'application/json',
141
+ };
142
+ const opts = httpOptions(cfg, 'GitHub');
143
+ const existing = await findExisting(listBase, { headers }, b => (Array.isArray(b) ? b : []), c => typeof c.body === 'string' && c.body.includes(COMMENT_MARKER), opts);
144
+ if (existing.reuse && cfg.mode !== 'append') {
145
+ const res = await request(`${apiBase}/issues/comments/${existing.reuse.id}`, { method: 'PATCH', headers, body: JSON.stringify({ body }) }, opts);
146
+ return finish('GitHub', res, 'Updated');
147
+ }
148
+ const res = await request(`${apiBase}/issues/${prNumber}/comments`, { method: 'POST', headers, body: JSON.stringify({ body }) }, opts);
149
+ return finish('GitHub', res, 'Posted');
150
+ }
151
+ /**
152
+ * Upsert a GitLab MR note. Uses the standard CI variables plus a `GITLAB_TOKEN`
153
+ * with `api` scope. Skips gracefully when not in an MR pipeline or the token is
154
+ * missing.
155
+ */
156
+ async function upsertGitlabNote(body, cfg) {
157
+ const base = process.env.CI_API_V4_URL;
158
+ const project = process.env.CI_PROJECT_ID;
159
+ const iid = process.env.CI_MERGE_REQUEST_IID;
160
+ const token = process.env.GITLAB_TOKEN;
161
+ if (!base || !project || !iid || !token) {
162
+ logger.info('[reporter]: Skipping GitLab note (not an MR pipeline or GITLAB_TOKEN missing)');
163
+ return SKIPPED;
164
+ }
165
+ const notes = `${base}/projects/${project}/merge_requests/${iid}/notes`;
166
+ const headers = { 'PRIVATE-TOKEN': token, 'Content-Type': 'application/json' };
167
+ const opts = httpOptions(cfg, 'GitLab');
168
+ const existing = await findExisting(`${notes}?per_page=${PER_PAGE}`, { headers }, b => (Array.isArray(b) ? b : []), n => typeof n.body === 'string' && n.body.includes(COMMENT_MARKER), opts);
169
+ if (existing.reuse && cfg.mode !== 'append') {
170
+ const res = await request(`${notes}/${existing.reuse.id}`, { method: 'PUT', headers, body: JSON.stringify({ body }) }, opts);
171
+ return finish('GitLab', res, 'Updated');
172
+ }
173
+ const res = await request(notes, { method: 'POST', headers, body: JSON.stringify({ body }) }, opts);
174
+ return finish('GitLab', res, 'Posted');
175
+ }
176
+ /**
177
+ * Upsert a Bitbucket PR comment. Uses Bitbucket Pipelines variables plus a
178
+ * `BITBUCKET_TOKEN` (repo/PR write). Skips gracefully when not in a PR pipeline
179
+ * or the token is missing.
180
+ */
181
+ async function upsertBitbucketComment(body, cfg) {
182
+ const fullName = process.env.BITBUCKET_REPO_FULL_NAME;
183
+ const prId = process.env.BITBUCKET_PR_ID;
184
+ const token = process.env.BITBUCKET_TOKEN;
185
+ if (!fullName || !prId || !token) {
186
+ logger.info('[reporter]: Skipping Bitbucket comment (not a PR pipeline or BITBUCKET_TOKEN missing)');
187
+ return SKIPPED;
188
+ }
189
+ const commentsUrl = `https://api.bitbucket.org/2.0/repositories/${fullName}/pullrequests/${prId}/comments`;
190
+ const headers = { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' };
191
+ const opts = httpOptions(cfg, 'Bitbucket');
192
+ const existing = await findExisting(`${commentsUrl}?pagelen=${PER_PAGE}`, { headers }, b => b?.values ?? [], c => Boolean(c.content?.raw?.includes(COMMENT_MARKER)), opts,
193
+ // Bitbucket is cursor-paginated: the next page is a URL in the body.
194
+ b => b?.next ?? null);
195
+ if (existing.reuse && cfg.mode !== 'append') {
196
+ const res = await request(`${commentsUrl}/${existing.reuse.id}`, { method: 'PUT', headers, body: JSON.stringify({ content: { raw: body } }) }, opts);
197
+ return finish('Bitbucket', res, 'Updated');
198
+ }
199
+ const res = await request(commentsUrl, { method: 'POST', headers, body: JSON.stringify({ content: { raw: body } }) }, opts);
200
+ return finish('Bitbucket', res, 'Posted');
201
+ }
202
+ /**
203
+ * Search every page of a comment thread for our own marker.
204
+ *
205
+ * Reading only the first page is what turned the upsert into an insert: with 30
206
+ * comments per page on GitHub and 20 on GitLab, an actively reviewed PR pushed
207
+ * the marker past the end and each new push added another summary.
208
+ */
209
+ async function findExisting(listUrl, init, extract, matches, opts, cursorNext) {
210
+ const base = listUrl;
211
+ const result = await paginate(listUrl, init, extract, (body, page, count) => (cursorNext ? cursorNext(body) : pageAfter(base, count, page)), opts);
212
+ if (!result.ok) {
213
+ // A failed search is not a failed post: fall through and create a comment.
214
+ // A duplicate is a far smaller problem than no report at all.
215
+ logger.warn(`[reporter]: ⚠️ Could not read existing comments (${result.error}) — will create`);
216
+ }
217
+ if (result.truncated) {
218
+ logger.warn('[reporter]: ⚠️ Stopped searching comments at the page limit — a duplicate summary is ' +
219
+ 'possible (raise reporter.maxPages)');
220
+ }
221
+ return { reuse: result.items.find(matches) ?? null };
222
+ }
223
+ /** Detect the CI platform from the environment, or null when unknown/local. */
224
+ function detectPlatform() {
225
+ if (process.env.GITHUB_ACTIONS || process.env.GITHUB_EVENT_NAME)
226
+ return 'github';
227
+ if (process.env.GITLAB_CI)
228
+ return 'gitlab';
229
+ if (process.env.BITBUCKET_PIPELINE_UUID || process.env.BITBUCKET_PR_ID)
230
+ return 'bitbucket';
231
+ return null;
232
+ }
233
+ /** Post the markdown report to a specific platform's PR/MR. */
234
+ async function postToPlatform(platform, result, cfg) {
235
+ const body = buildMarkdownReport(result, cfg);
236
+ if (platform === 'github')
237
+ return upsertGithubComment(body, cfg);
238
+ if (platform === 'gitlab')
239
+ return upsertGitlabNote(body, cfg);
240
+ return upsertBitbucketComment(body, cfg);
241
+ }
242
+ /**
243
+ * Emit the report through the selected channel.
244
+ * none: nothing · stdout: console table · github/gitlab/bitbucket: table +
245
+ * upsert the PR/MR comment · auto: detect the platform from the environment.
246
+ *
247
+ * Returns whether the comment reached the PR, so `runChecks` can honour
248
+ * `reporter.onPostFailure` — for teams whose review process depends on the
249
+ * comment, a silently lost report is worse than a red build.
250
+ */
251
+ export async function report(kind, result, cfg = {}) {
252
+ if (kind === 'none')
253
+ return SKIPPED;
254
+ printStdout(result, cfg);
255
+ if (result.results.length === 0)
256
+ return SKIPPED;
257
+ // Nothing to say and nothing wrong: don't notify every PR subscriber.
258
+ if (cfg.skipWhenClean && result.summary.failed === 0 && result.summary.warned === 0) {
259
+ logger.info('[reporter]: Nothing to report (skipWhenClean)');
260
+ return SKIPPED;
261
+ }
262
+ const platform = kind === 'auto' ? detectPlatform() : kind === 'stdout' ? null : kind;
263
+ if (!platform)
264
+ return SKIPPED;
265
+ return postToPlatform(platform, result, cfg);
266
+ }
@@ -0,0 +1,33 @@
1
+ import type { RunScope } from './types.js';
2
+ import { CheckContext, CheckReport, CheckStatus, RunOptions } from './types.js';
3
+ /**
4
+ * Apply the universal `config.severity` override for a check. Only remaps
5
+ * between warn↔fail (pass/skip are never changed); `off` is handled earlier by
6
+ * excluding the check from the run entirely. This is what lets a repo turn any
7
+ * advisory check into a gate, or downgrade a blocking one, by name.
8
+ */
9
+ export declare function applySeverity(name: string, status: CheckStatus, ctx: CheckContext): CheckStatus;
10
+ /**
11
+ * Whether a diff-only check's skip is worth a row in the report.
12
+ *
13
+ * The two cases look identical from inside the check and are opposites to the
14
+ * person reading the result:
15
+ *
16
+ * - The range is missing because the run FELL BACK to a full scan — a shallow
17
+ * clone, an unreachable PR base. Coverage was lost without anyone choosing
18
+ * that, and saying nothing is how it stays lost (ticket 057).
19
+ * - The full scan was ASKED FOR. `--full` means "look at everything now", so
20
+ * three rows explaining that three checks review a diff repeat what the reader
21
+ * just said and push the real findings further down.
22
+ *
23
+ * `always` and `never` remain absolute; only `auto` distinguishes them.
24
+ */
25
+ export declare function shouldReportDiffSkip(scope: RunScope | undefined, reportSkipped?: 'auto' | 'always' | 'never'): boolean;
26
+ /**
27
+ * Run all applicable checks and return a structured report.
28
+ *
29
+ * Never throws for check violations and never calls `process.exit` — callers
30
+ * (CLI, PRValidator) decide what a failure means. Phases run in order; checks
31
+ * within a phase run in parallel.
32
+ */
33
+ export declare function runChecks(opts?: RunOptions): Promise<CheckReport>;