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.
- package/dist/{cli.js → cjs/cli.js} +30 -30
- package/dist/{config → cjs/config}/index.d.ts +2 -2
- package/dist/{config → cjs/config}/index.js +8 -7
- package/dist/{config → cjs/config}/loader.d.ts +1 -1
- package/dist/{config → cjs/config}/loader.js +8 -8
- package/dist/{core → cjs/core}/checks/dependencies/banned-imports.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/dependencies/banned-imports.js +10 -10
- package/dist/{core → cjs/core}/checks/dependencies/circular-deps.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/dependencies/circular-deps.js +27 -27
- package/dist/{core → cjs/core}/checks/dependencies/dependency-check.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/dependencies/dependency-check.js +17 -17
- package/dist/{core → cjs/core}/checks/dependencies/grype-scan.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/dependencies/grype-scan.js +18 -18
- package/dist/{core → cjs/core}/checks/dependencies/license-check.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/dependencies/license-check.js +12 -12
- package/dist/{core → cjs/core}/checks/dependencies/npm-audit.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/dependencies/npm-audit.js +14 -14
- package/dist/{core → cjs/core}/checks/dependencies/outdated-deps.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/dependencies/outdated-deps.js +14 -14
- package/dist/{core → cjs/core}/checks/dependencies/vuln-scan.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/dependencies/vuln-scan.js +14 -14
- package/dist/{core → cjs/core}/checks/findings.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/findings.js +16 -16
- package/dist/{core → cjs/core}/checks/git/custom-rules.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/git/custom-rules.js +19 -19
- package/dist/{core → cjs/core}/checks/git/diff-smell.d.ts +2 -2
- package/dist/{core → cjs/core}/checks/git/diff-smell.js +13 -13
- package/dist/{core → cjs/core}/checks/git/large-files.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/git/large-files.js +15 -15
- package/dist/{core → cjs/core}/checks/git/leftover-debug.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/git/leftover-debug.js +13 -13
- package/dist/{core → cjs/core}/checks/git/lockfile-drift.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/git/lockfile-drift.js +12 -12
- package/dist/{core → cjs/core}/checks/git/merge-conflict.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/git/merge-conflict.js +15 -15
- package/dist/{core → cjs/core}/checks/git/missing-tests.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/git/missing-tests.js +15 -15
- package/dist/{core → cjs/core}/checks/git/todo-fixme.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/git/todo-fixme.js +11 -11
- package/dist/{core → cjs/core}/checks/languages/cpp-format.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/languages/cpp-format.js +18 -18
- package/dist/{core → cjs/core}/checks/languages/external-checks.d.ts +9 -9
- package/dist/{core → cjs/core}/checks/languages/external-checks.js +10 -10
- package/dist/{core → cjs/core}/checks/languages/external-runner.d.ts +2 -2
- package/dist/{core → cjs/core}/checks/languages/external-runner.js +21 -21
- package/dist/{core → cjs/core}/checks/languages/go-format.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/languages/go-format.js +21 -21
- package/dist/cjs/core/checks/languages/lint.d.ts +2 -0
- package/dist/{core → cjs/core}/checks/languages/lint.js +21 -21
- package/dist/{core → cjs/core}/checks/languages/prettier.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/languages/prettier.js +18 -18
- package/dist/{core → cjs/core}/checks/languages/python-format.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/languages/python-format.js +14 -14
- package/dist/{core → cjs/core}/checks/languages/python-lint.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/languages/python-lint.js +13 -13
- package/dist/{core → cjs/core}/checks/languages/python-typecheck.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/languages/python-typecheck.js +29 -29
- package/dist/{core → cjs/core}/checks/languages/typecheck.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/languages/typecheck.js +13 -13
- package/dist/{core → cjs/core}/checks/pr/commitlint.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/pr/commitlint.js +12 -12
- package/dist/{core → cjs/core}/checks/pr/pr-body.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/pr/pr-body.js +8 -8
- package/dist/{core → cjs/core}/checks/pr/pr-size-check.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/pr/pr-size-check.js +10 -10
- package/dist/{core → cjs/core}/checks/pr/pr-title-lint.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/pr/pr-title-lint.js +8 -8
- package/dist/{core → cjs/core}/checks/quality/case-collision.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/quality/case-collision.js +7 -7
- package/dist/{core → cjs/core}/checks/quality/config-validation.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/quality/config-validation.js +9 -9
- package/dist/{core → cjs/core}/checks/quality/coverage.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/quality/coverage.js +4 -4
- package/dist/{core → cjs/core}/checks/quality/dead-code.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/quality/dead-code.js +23 -23
- package/dist/{core → cjs/core}/checks/quality/duplicate-check.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/quality/duplicate-check.js +22 -22
- package/dist/{core → cjs/core}/checks/quality/license-header.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/quality/license-header.js +16 -16
- package/dist/{core → cjs/core}/checks/quality/markdown-lint.d.ts +1 -1
- package/dist/cjs/core/checks/quality/markdown-lint.js +147 -0
- package/dist/{core → cjs/core}/checks/quality/package-size.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/quality/package-size.js +12 -12
- package/dist/{core → cjs/core}/checks/quality/spellcheck.d.ts +2 -2
- package/dist/{core → cjs/core}/checks/quality/spellcheck.js +18 -18
- package/dist/{core → cjs/core}/checks/quality/symlinks.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/quality/symlinks.js +8 -8
- package/dist/{core → cjs/core}/checks/quality/yaml-lint.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/quality/yaml-lint.js +12 -12
- package/dist/{core → cjs/core}/checks/security/diff-security.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/security/diff-security.js +15 -15
- package/dist/{core → cjs/core}/checks/security/dockerfile-security.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/security/dockerfile-security.js +16 -16
- package/dist/{core → cjs/core}/checks/security/migration-safety.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/security/migration-safety.js +17 -17
- package/dist/{core → cjs/core}/checks/security/security.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/security/security.js +21 -21
- package/dist/{core → cjs/core}/checks/security/sensitive-file-guard.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/security/sensitive-file-guard.js +14 -14
- package/dist/{core → cjs/core}/checks/security/workflow-security.d.ts +2 -2
- package/dist/{core → cjs/core}/checks/security/workflow-security.js +14 -14
- package/dist/{core → cjs/core}/checks/tool-install.d.ts +1 -1
- package/dist/{core → cjs/core}/checks/tool-install.js +2 -2
- package/dist/{core → cjs/core}/context.d.ts +1 -1
- package/dist/{core → cjs/core}/context.js +16 -16
- package/dist/cjs/core/index.d.ts +4 -0
- package/dist/{core → cjs/core}/index.js +7 -7
- package/dist/{core → cjs/core}/install/cache.js +2 -2
- package/dist/{core → cjs/core}/install/doctor.d.ts +4 -4
- package/dist/{core → cjs/core}/install/doctor.js +34 -34
- package/dist/{core → cjs/core}/install/ensure.d.ts +2 -2
- package/dist/{core → cjs/core}/install/ensure.js +15 -14
- package/dist/{core → cjs/core}/install/lock.js +4 -4
- package/dist/{core → cjs/core}/install/prepare.d.ts +4 -4
- package/dist/{core → cjs/core}/install/prepare.js +13 -13
- package/dist/{core → cjs/core}/install/profiles.d.ts +2 -2
- package/dist/{core → cjs/core}/install/profiles.js +1 -1
- package/dist/{core → cjs/core}/install/reuse.d.ts +1 -1
- package/dist/{core → cjs/core}/install/reuse.js +4 -4
- package/dist/{core → cjs/core}/registry.d.ts +1 -1
- package/dist/cjs/core/registry.js +112 -0
- package/dist/{core → cjs/core}/reporters.d.ts +1 -1
- package/dist/{core → cjs/core}/reporters.js +28 -28
- package/dist/{core → cjs/core}/run-checks.d.ts +2 -2
- package/dist/{core → cjs/core}/run-checks.js +31 -31
- package/dist/{core → cjs/core}/targets.d.ts +1 -1
- package/dist/{core → cjs/core}/targets.js +20 -20
- package/dist/{core → cjs/core}/types.d.ts +3 -3
- package/dist/cjs/index.d.ts +12 -0
- package/dist/{index.js → cjs/index.js} +18 -18
- package/dist/{init.js → cjs/init.js} +68 -56
- package/dist/{interfaces → cjs/interfaces}/index.d.ts +3 -3
- package/dist/cjs/package.json +1 -0
- package/dist/{scripts → cjs/scripts}/copy-configs.js +22 -7
- package/dist/{scripts → cjs/scripts}/generate-install-manifests.js +2 -2
- package/dist/{scripts → cjs/scripts}/publish-github.js +4 -4
- package/dist/{utils → cjs/utils}/detect-language.js +12 -12
- package/dist/{utils → cjs/utils}/git.js +2 -2
- package/dist/{utils → cjs/utils}/http.js +2 -2
- package/dist/cjs/utils/index.d.ts +15 -0
- package/dist/{utils → cjs/utils}/index.js +13 -13
- package/dist/{utils → cjs/utils}/own-deps.d.ts +2 -0
- package/dist/{utils → cjs/utils}/own-deps.js +1 -0
- package/dist/{utils → cjs/utils}/package-version.js +2 -1
- package/dist/{utils → cjs/utils}/resolve-bin.js +2 -1
- package/dist/{utils → cjs/utils}/update-notifier.js +4 -4
- package/dist/esm/cli.d.ts +2 -0
- package/dist/esm/cli.js +137 -0
- package/dist/esm/config/constants.d.ts +153 -0
- package/dist/esm/config/constants.js +360 -0
- package/dist/esm/config/index.d.ts +40 -0
- package/dist/esm/config/index.js +60 -0
- package/dist/esm/config/loader.d.ts +6 -0
- package/dist/esm/config/loader.js +191 -0
- package/dist/esm/config/pr-checkmate-workflow-docker.yml +79 -0
- package/dist/esm/config/pr-checkmate-workflow.yml +92 -0
- package/dist/esm/core/checks/dependencies/banned-imports.d.ts +2 -0
- package/dist/esm/core/checks/dependencies/banned-imports.js +70 -0
- package/dist/esm/core/checks/dependencies/circular-deps.d.ts +2 -0
- package/dist/esm/core/checks/dependencies/circular-deps.js +155 -0
- package/dist/esm/core/checks/dependencies/dependency-check.d.ts +43 -0
- package/dist/esm/core/checks/dependencies/dependency-check.js +174 -0
- package/dist/esm/core/checks/dependencies/grype-scan.d.ts +22 -0
- package/dist/esm/core/checks/dependencies/grype-scan.js +112 -0
- package/dist/esm/core/checks/dependencies/license-check.d.ts +2 -0
- package/dist/esm/core/checks/dependencies/license-check.js +61 -0
- package/dist/esm/core/checks/dependencies/npm-audit.d.ts +6 -0
- package/dist/esm/core/checks/dependencies/npm-audit.js +80 -0
- package/dist/esm/core/checks/dependencies/outdated-deps.d.ts +2 -0
- package/dist/esm/core/checks/dependencies/outdated-deps.js +66 -0
- package/dist/esm/core/checks/dependencies/vuln-scan.d.ts +2 -0
- package/dist/esm/core/checks/dependencies/vuln-scan.js +54 -0
- package/dist/esm/core/checks/findings.d.ts +299 -0
- package/dist/esm/core/checks/findings.js +701 -0
- package/dist/esm/core/checks/git/custom-rules.d.ts +2 -0
- package/dist/esm/core/checks/git/custom-rules.js +106 -0
- package/dist/esm/core/checks/git/diff-smell.d.ts +19 -0
- package/dist/esm/core/checks/git/diff-smell.js +69 -0
- package/dist/esm/core/checks/git/large-files.d.ts +2 -0
- package/dist/esm/core/checks/git/large-files.js +112 -0
- package/dist/esm/core/checks/git/leftover-debug.d.ts +2 -0
- package/dist/esm/core/checks/git/leftover-debug.js +89 -0
- package/dist/esm/core/checks/git/lockfile-drift.d.ts +2 -0
- package/dist/esm/core/checks/git/lockfile-drift.js +114 -0
- package/dist/esm/core/checks/git/merge-conflict.d.ts +2 -0
- package/dist/esm/core/checks/git/merge-conflict.js +117 -0
- package/dist/esm/core/checks/git/missing-tests.d.ts +2 -0
- package/dist/esm/core/checks/git/missing-tests.js +105 -0
- package/dist/esm/core/checks/git/todo-fixme.d.ts +7 -0
- package/dist/esm/core/checks/git/todo-fixme.js +80 -0
- package/dist/esm/core/checks/languages/cpp-format.d.ts +7 -0
- package/dist/esm/core/checks/languages/cpp-format.js +91 -0
- package/dist/esm/core/checks/languages/external-checks.d.ts +77 -0
- package/dist/esm/core/checks/languages/external-checks.js +197 -0
- package/dist/esm/core/checks/languages/external-runner.d.ts +119 -0
- package/dist/esm/core/checks/languages/external-runner.js +138 -0
- package/dist/esm/core/checks/languages/go-format.d.ts +8 -0
- package/dist/esm/core/checks/languages/go-format.js +163 -0
- package/dist/esm/core/checks/languages/lint.d.ts +2 -0
- package/dist/esm/core/checks/languages/lint.js +92 -0
- package/dist/esm/core/checks/languages/prettier.d.ts +2 -0
- package/dist/esm/core/checks/languages/prettier.js +85 -0
- package/dist/esm/core/checks/languages/python-format.d.ts +7 -0
- package/dist/esm/core/checks/languages/python-format.js +61 -0
- package/dist/esm/core/checks/languages/python-lint.d.ts +9 -0
- package/dist/esm/core/checks/languages/python-lint.js +55 -0
- package/dist/esm/core/checks/languages/python-typecheck.d.ts +14 -0
- package/dist/esm/core/checks/languages/python-typecheck.js +184 -0
- package/dist/esm/core/checks/languages/ruff-shared.d.ts +10 -0
- package/dist/esm/core/checks/languages/ruff-shared.js +35 -0
- package/dist/esm/core/checks/languages/typecheck.d.ts +2 -0
- package/dist/esm/core/checks/languages/typecheck.js +61 -0
- package/dist/esm/core/checks/pr/commitlint.d.ts +2 -0
- package/dist/esm/core/checks/pr/commitlint.js +102 -0
- package/dist/esm/core/checks/pr/pr-body.d.ts +2 -0
- package/dist/esm/core/checks/pr/pr-body.js +43 -0
- package/dist/esm/core/checks/pr/pr-size-check.d.ts +2 -0
- package/dist/esm/core/checks/pr/pr-size-check.js +42 -0
- package/dist/esm/core/checks/pr/pr-title-lint.d.ts +2 -0
- package/dist/esm/core/checks/pr/pr-title-lint.js +31 -0
- package/dist/esm/core/checks/quality/case-collision.d.ts +8 -0
- package/dist/esm/core/checks/quality/case-collision.js +39 -0
- package/dist/esm/core/checks/quality/config-validation.d.ts +11 -0
- package/dist/esm/core/checks/quality/config-validation.js +188 -0
- package/dist/esm/core/checks/quality/coverage.d.ts +2 -0
- package/dist/esm/core/checks/quality/coverage.js +62 -0
- package/dist/esm/core/checks/quality/dead-code.d.ts +2 -0
- package/dist/esm/core/checks/quality/dead-code.js +124 -0
- package/dist/esm/core/checks/quality/duplicate-check.d.ts +2 -0
- package/dist/esm/core/checks/quality/duplicate-check.js +141 -0
- package/dist/esm/core/checks/quality/license-header.d.ts +7 -0
- package/dist/esm/core/checks/quality/license-header.js +81 -0
- package/dist/esm/core/checks/quality/markdown-lint.d.ts +2 -0
- package/dist/esm/core/checks/quality/markdown-lint.js +141 -0
- package/dist/esm/core/checks/quality/package-size.d.ts +36 -0
- package/dist/esm/core/checks/quality/package-size.js +196 -0
- package/dist/esm/core/checks/quality/spellcheck.d.ts +77 -0
- package/dist/esm/core/checks/quality/spellcheck.js +296 -0
- package/dist/esm/core/checks/quality/symlinks.d.ts +16 -0
- package/dist/esm/core/checks/quality/symlinks.js +57 -0
- package/dist/esm/core/checks/quality/yaml-lint.d.ts +20 -0
- package/dist/esm/core/checks/quality/yaml-lint.js +116 -0
- package/dist/esm/core/checks/security/diff-security.d.ts +2 -0
- package/dist/esm/core/checks/security/diff-security.js +354 -0
- package/dist/esm/core/checks/security/dockerfile-security.d.ts +2 -0
- package/dist/esm/core/checks/security/dockerfile-security.js +98 -0
- package/dist/esm/core/checks/security/migration-safety.d.ts +2 -0
- package/dist/esm/core/checks/security/migration-safety.js +137 -0
- package/dist/esm/core/checks/security/security.d.ts +63 -0
- package/dist/esm/core/checks/security/security.js +201 -0
- package/dist/esm/core/checks/security/sensitive-file-guard.d.ts +2 -0
- package/dist/esm/core/checks/security/sensitive-file-guard.js +160 -0
- package/dist/esm/core/checks/security/workflow-security.d.ts +12 -0
- package/dist/esm/core/checks/security/workflow-security.js +100 -0
- package/dist/esm/core/checks/tool-install.d.ts +102 -0
- package/dist/esm/core/checks/tool-install.js +66 -0
- package/dist/esm/core/commands.d.ts +27 -0
- package/dist/esm/core/commands.js +89 -0
- package/dist/esm/core/context.d.ts +62 -0
- package/dist/esm/core/context.js +241 -0
- package/dist/esm/core/index.d.ts +4 -0
- package/dist/esm/core/index.js +4 -0
- package/dist/esm/core/install/cache.d.ts +58 -0
- package/dist/esm/core/install/cache.js +142 -0
- package/dist/esm/core/install/doctor.d.ts +35 -0
- package/dist/esm/core/install/doctor.js +164 -0
- package/dist/esm/core/install/ensure.d.ts +77 -0
- package/dist/esm/core/install/ensure.js +269 -0
- package/dist/esm/core/install/lock.d.ts +34 -0
- package/dist/esm/core/install/lock.js +92 -0
- package/dist/esm/core/install/merge.d.ts +47 -0
- package/dist/esm/core/install/merge.js +85 -0
- package/dist/esm/core/install/prepare.d.ts +76 -0
- package/dist/esm/core/install/prepare.js +142 -0
- package/dist/esm/core/install/profiles.d.ts +78 -0
- package/dist/esm/core/install/profiles.js +192 -0
- package/dist/esm/core/install/reuse.d.ts +41 -0
- package/dist/esm/core/install/reuse.js +100 -0
- package/dist/esm/core/registry.d.ts +6 -0
- package/dist/esm/core/registry.js +109 -0
- package/dist/esm/core/reporters.d.ts +18 -0
- package/dist/esm/core/reporters.js +266 -0
- package/dist/esm/core/run-checks.d.ts +33 -0
- package/dist/esm/core/run-checks.js +293 -0
- package/dist/esm/core/targets.d.ts +140 -0
- package/dist/esm/core/targets.js +213 -0
- package/dist/esm/core/types.d.ts +195 -0
- package/dist/esm/core/types.js +38 -0
- package/dist/esm/index.d.ts +12 -0
- package/dist/esm/index.js +15 -0
- package/dist/esm/init.d.ts +38 -0
- package/dist/esm/init.js +421 -0
- package/dist/esm/interfaces/index.d.ts +432 -0
- package/dist/esm/interfaces/index.js +2 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/scripts/copy-configs.d.ts +1 -0
- package/dist/esm/scripts/copy-configs.js +64 -0
- package/dist/esm/scripts/generate-install-manifests.d.ts +39 -0
- package/dist/esm/scripts/generate-install-manifests.js +115 -0
- package/dist/esm/scripts/publish-github.d.ts +1 -0
- package/dist/esm/scripts/publish-github.js +45 -0
- package/dist/esm/utils/ci.d.ts +11 -0
- package/dist/esm/utils/ci.js +40 -0
- package/dist/esm/utils/detect-language.d.ts +48 -0
- package/dist/esm/utils/detect-language.js +234 -0
- package/dist/esm/utils/direct-deps.d.ts +21 -0
- package/dist/esm/utils/direct-deps.js +220 -0
- package/dist/esm/utils/execa.d.ts +22 -0
- package/dist/esm/utils/execa.js +10 -0
- package/dist/esm/utils/git.d.ts +14 -0
- package/dist/esm/utils/git.js +21 -0
- package/dist/esm/utils/glob.d.ts +24 -0
- package/dist/esm/utils/glob.js +40 -0
- package/dist/esm/utils/http.d.ts +59 -0
- package/dist/esm/utils/http.js +115 -0
- package/dist/esm/utils/index.d.ts +15 -0
- package/dist/esm/utils/index.js +26 -0
- package/dist/esm/utils/logger.d.ts +65 -0
- package/dist/esm/utils/logger.js +157 -0
- package/dist/esm/utils/own-deps.d.ts +16 -0
- package/dist/esm/utils/own-deps.js +107 -0
- package/dist/esm/utils/package-version.d.ts +4 -0
- package/dist/esm/utils/package-version.js +38 -0
- package/dist/esm/utils/pool.d.ts +49 -0
- package/dist/esm/utils/pool.js +113 -0
- package/dist/esm/utils/resolve-bin.d.ts +67 -0
- package/dist/esm/utils/resolve-bin.js +156 -0
- package/dist/esm/utils/result-collector.d.ts +33 -0
- package/dist/esm/utils/result-collector.js +44 -0
- package/dist/esm/utils/update-notifier.d.ts +19 -0
- package/dist/esm/utils/update-notifier.js +108 -0
- package/install-manifests/core/package-lock.json +4 -4
- package/install-manifests/core/package.json +1 -1
- package/install-manifests/duplicate/package-lock.json +0 -12
- package/install-manifests/js/package-lock.json +17 -41
- package/install-manifests/js/package.json +1 -1
- package/install-manifests/markdown/package-lock.json +1 -492
- package/install-manifests/markdown/package.json +1 -1
- package/package.json +17 -15
- package/dist/core/checks/languages/lint.d.ts +0 -2
- package/dist/core/checks/quality/markdown-lint.js +0 -110
- package/dist/core/index.d.ts +0 -4
- package/dist/core/registry.js +0 -112
- package/dist/index.d.ts +0 -12
- package/dist/utils/index.d.ts +0 -15
- /package/dist/{cli.d.ts → cjs/cli.d.ts} +0 -0
- /package/dist/{config → cjs/config}/constants.d.ts +0 -0
- /package/dist/{config → cjs/config}/constants.js +0 -0
- /package/dist/{config → cjs/config}/pr-checkmate-workflow-docker.yml +0 -0
- /package/dist/{config → cjs/config}/pr-checkmate-workflow.yml +0 -0
- /package/dist/{core → cjs/core}/checks/languages/ruff-shared.d.ts +0 -0
- /package/dist/{core → cjs/core}/checks/languages/ruff-shared.js +0 -0
- /package/dist/{core → cjs/core}/commands.d.ts +0 -0
- /package/dist/{core → cjs/core}/commands.js +0 -0
- /package/dist/{core → cjs/core}/install/cache.d.ts +0 -0
- /package/dist/{core → cjs/core}/install/lock.d.ts +0 -0
- /package/dist/{core → cjs/core}/install/merge.d.ts +0 -0
- /package/dist/{core → cjs/core}/install/merge.js +0 -0
- /package/dist/{core → cjs/core}/types.js +0 -0
- /package/dist/{init.d.ts → cjs/init.d.ts} +0 -0
- /package/dist/{interfaces → cjs/interfaces}/index.js +0 -0
- /package/dist/{scripts → cjs/scripts}/copy-configs.d.ts +0 -0
- /package/dist/{scripts → cjs/scripts}/generate-install-manifests.d.ts +0 -0
- /package/dist/{scripts → cjs/scripts}/publish-github.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/ci.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/ci.js +0 -0
- /package/dist/{utils → cjs/utils}/detect-language.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/direct-deps.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/direct-deps.js +0 -0
- /package/dist/{utils → cjs/utils}/execa.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/execa.js +0 -0
- /package/dist/{utils → cjs/utils}/git.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/glob.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/glob.js +0 -0
- /package/dist/{utils → cjs/utils}/http.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/logger.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/logger.js +0 -0
- /package/dist/{utils → cjs/utils}/package-version.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/pool.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/pool.js +0 -0
- /package/dist/{utils → cjs/utils}/resolve-bin.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/result-collector.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/result-collector.js +0 -0
- /package/dist/{utils → cjs/utils}/update-notifier.d.ts +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export * from './constants.js';
|
|
2
|
+
export { loadProjectConfig } from '../config/loader.js';
|
|
3
|
+
/**
|
|
4
|
+
* The configured source path(s), normalised to a list.
|
|
5
|
+
*
|
|
6
|
+
* Accepts a string or an array; empty and invalid values fall back to `['.']`,
|
|
7
|
+
* the whole repository. Clients narrow scanning to a subdirectory by setting
|
|
8
|
+
* `sourcePath`.
|
|
9
|
+
*
|
|
10
|
+
* `cwd` is a parameter rather than `process.cwd()` baked in, and that is the
|
|
11
|
+
* whole of ticket 074. This used to read a `CONFIG_FILE` constant resolved at
|
|
12
|
+
* *module load*, so the answer was fixed to whatever directory the process
|
|
13
|
+
* started in — `chdir` could not change it and neither could a caller. For the
|
|
14
|
+
* CLI that is harmless, since its working directory never moves; for
|
|
15
|
+
* `runChecks({ cwd })` it meant the SDK consumer's own `sourcePath` was applied
|
|
16
|
+
* to somebody else's repository, silently scoping every scoped check to a
|
|
17
|
+
* directory that may not exist there.
|
|
18
|
+
*
|
|
19
|
+
* It also read the file itself, duplicating `loadProjectConfig` with its own
|
|
20
|
+
* defaults. One reader is now the only reader.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getSourcePaths(cwd?: string): string[];
|
|
23
|
+
/**
|
|
24
|
+
* The first configured source path, for callers that only support one directory.
|
|
25
|
+
* Prefer {@link getSourcePaths} for scan targets.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getSourcePath(cwd?: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Get the effective list of directory names excluded from every check
|
|
30
|
+
* (client `ignoreDirs` in pr-checkmate.json, or the curated default).
|
|
31
|
+
*/
|
|
32
|
+
export declare function getIgnoredDirs(cwd?: string): string[];
|
|
33
|
+
/**
|
|
34
|
+
* Get path to package config files
|
|
35
|
+
*/
|
|
36
|
+
export declare function getPackageConfigPath(fileName: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Check if project has local config
|
|
39
|
+
*/
|
|
40
|
+
export declare function hasLocalConfig(configNames: string[], cwd?: string): boolean;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
2
|
+
import { dirname as __dirnameFn } from 'node:path';
|
|
3
|
+
const __dirname = __dirnameFn(__fileURLToPath(import.meta.url));
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { loadProjectConfig } from '../config/loader.js';
|
|
7
|
+
import { findOwnPackageRoot } from '../utils/own-deps.js';
|
|
8
|
+
export * from './constants.js';
|
|
9
|
+
export { loadProjectConfig } from '../config/loader.js';
|
|
10
|
+
/**
|
|
11
|
+
* The configured source path(s), normalised to a list.
|
|
12
|
+
*
|
|
13
|
+
* Accepts a string or an array; empty and invalid values fall back to `['.']`,
|
|
14
|
+
* the whole repository. Clients narrow scanning to a subdirectory by setting
|
|
15
|
+
* `sourcePath`.
|
|
16
|
+
*
|
|
17
|
+
* `cwd` is a parameter rather than `process.cwd()` baked in, and that is the
|
|
18
|
+
* whole of ticket 074. This used to read a `CONFIG_FILE` constant resolved at
|
|
19
|
+
* *module load*, so the answer was fixed to whatever directory the process
|
|
20
|
+
* started in — `chdir` could not change it and neither could a caller. For the
|
|
21
|
+
* CLI that is harmless, since its working directory never moves; for
|
|
22
|
+
* `runChecks({ cwd })` it meant the SDK consumer's own `sourcePath` was applied
|
|
23
|
+
* to somebody else's repository, silently scoping every scoped check to a
|
|
24
|
+
* directory that may not exist there.
|
|
25
|
+
*
|
|
26
|
+
* It also read the file itself, duplicating `loadProjectConfig` with its own
|
|
27
|
+
* defaults. One reader is now the only reader.
|
|
28
|
+
*/
|
|
29
|
+
export function getSourcePaths(cwd = process.cwd()) {
|
|
30
|
+
const { sourcePath } = loadProjectConfig(cwd);
|
|
31
|
+
const paths = (Array.isArray(sourcePath) ? sourcePath : [sourcePath]).filter((p) => typeof p === 'string' && p.trim().length > 0);
|
|
32
|
+
return paths.length > 0 ? paths : ['.'];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The first configured source path, for callers that only support one directory.
|
|
36
|
+
* Prefer {@link getSourcePaths} for scan targets.
|
|
37
|
+
*/
|
|
38
|
+
export function getSourcePath(cwd) {
|
|
39
|
+
return getSourcePaths(cwd)[0];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get the effective list of directory names excluded from every check
|
|
43
|
+
* (client `ignoreDirs` in pr-checkmate.json, or the curated default).
|
|
44
|
+
*/
|
|
45
|
+
export function getIgnoredDirs(cwd) {
|
|
46
|
+
return loadProjectConfig(cwd).ignoreDirs ?? [];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get path to package config files
|
|
50
|
+
*/
|
|
51
|
+
export function getPackageConfigPath(fileName) {
|
|
52
|
+
const packageRoot = findOwnPackageRoot() ?? path.resolve(__dirname, '../../..');
|
|
53
|
+
return path.join(packageRoot, fileName);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Check if project has local config
|
|
57
|
+
*/
|
|
58
|
+
export function hasLocalConfig(configNames, cwd = process.cwd()) {
|
|
59
|
+
return configNames.some(name => fs.existsSync(path.join(cwd, name)));
|
|
60
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { logger } from '../utils/index.js';
|
|
4
|
+
import { DEAD_CODE_IGNORE_DEFAULTS, DEFAULT_ALLOW_PACKAGES, DUPLICATE_CODE_FORMATS, DUPLICATE_IGNORE_DEFAULTS, IGNORED_DIRS, } from './constants.js';
|
|
5
|
+
/**
|
|
6
|
+
* Load project configuration from pr-checkmate.json
|
|
7
|
+
* Falls back to defaults if not found
|
|
8
|
+
*/
|
|
9
|
+
export function loadProjectConfig(cwd = process.cwd()) {
|
|
10
|
+
const configPath = path.join(cwd, 'pr-checkmate.json');
|
|
11
|
+
if (fs.existsSync(configPath)) {
|
|
12
|
+
try {
|
|
13
|
+
const content = fs.readFileSync(configPath, 'utf-8');
|
|
14
|
+
const config = JSON.parse(content);
|
|
15
|
+
return mergeWithDefaults(config);
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
logger.warn(`[loadProjectConfig]: ⚠️ Failed to parse pr-checkmate.json: ${err}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return getDefaultConfig();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Deep merge user config with defaults
|
|
25
|
+
*/
|
|
26
|
+
function mergeWithDefaults(userConfig) {
|
|
27
|
+
const defaults = getDefaultConfig();
|
|
28
|
+
return {
|
|
29
|
+
// Preserve every key the user set — including opt-in checks (vulnScan,
|
|
30
|
+
// grypeScan) and controls with no default entry below (severity, customRules,
|
|
31
|
+
// prSize, caseCollision, go/rust/ruby/php, …). The explicitly-merged keys
|
|
32
|
+
// that follow override this spread with their default-merged values.
|
|
33
|
+
...userConfig,
|
|
34
|
+
sourcePath: userConfig.sourcePath || defaults.sourcePath,
|
|
35
|
+
// Replace (not merge): the client sees the full default list in their
|
|
36
|
+
// generated config and edits it directly, so their list is authoritative.
|
|
37
|
+
ignoreDirs: userConfig.ignoreDirs ?? defaults.ignoreDirs,
|
|
38
|
+
lint: {
|
|
39
|
+
rules: { ...defaults.lint?.rules, ...userConfig.lint?.rules },
|
|
40
|
+
ignorePatterns: [
|
|
41
|
+
...(defaults.lint?.ignorePatterns || []),
|
|
42
|
+
...(userConfig.lint?.ignorePatterns || []),
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
prettier: {
|
|
46
|
+
config: { ...defaults.prettier?.config, ...userConfig.prettier?.config },
|
|
47
|
+
},
|
|
48
|
+
spellcheck: {
|
|
49
|
+
words: [...(userConfig.spellcheck?.words || [])],
|
|
50
|
+
ignoreWords: [...(userConfig.spellcheck?.ignoreWords || [])],
|
|
51
|
+
ignorePaths: [
|
|
52
|
+
...(defaults.spellcheck?.ignorePaths || []),
|
|
53
|
+
...(userConfig.spellcheck?.ignorePaths || []),
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
security: {
|
|
57
|
+
...defaults.security,
|
|
58
|
+
...userConfig.security,
|
|
59
|
+
gitleaks: { ...defaults.security?.gitleaks, ...userConfig.security?.gitleaks },
|
|
60
|
+
'npm-audit': { ...defaults.security?.['npm-audit'], ...userConfig.security?.['npm-audit'] },
|
|
61
|
+
},
|
|
62
|
+
typecheck: { ...defaults.typecheck, ...userConfig.typecheck },
|
|
63
|
+
cpp: {
|
|
64
|
+
...defaults.cpp,
|
|
65
|
+
...userConfig.cpp,
|
|
66
|
+
clangFormat: { ...defaults.cpp?.clangFormat, ...userConfig.cpp?.clangFormat },
|
|
67
|
+
},
|
|
68
|
+
python: {
|
|
69
|
+
...defaults.python,
|
|
70
|
+
...userConfig.python,
|
|
71
|
+
ruff: { ...defaults.python?.ruff, ...userConfig.python?.ruff },
|
|
72
|
+
},
|
|
73
|
+
swift: { ...defaults.swift, ...userConfig.swift },
|
|
74
|
+
kotlin: { ...defaults.kotlin, ...userConfig.kotlin },
|
|
75
|
+
diffSmell: { ...defaults.diffSmell, ...userConfig.diffSmell },
|
|
76
|
+
prBody: { ...defaults.prBody, ...userConfig.prBody },
|
|
77
|
+
duplicate: { ...defaults.duplicate, ...userConfig.duplicate },
|
|
78
|
+
dependency: { ...defaults.dependency, ...userConfig.dependency },
|
|
79
|
+
outdatedDeps: { ...defaults.outdatedDeps, ...userConfig.outdatedDeps },
|
|
80
|
+
commitlint: { ...defaults.commitlint, ...userConfig.commitlint },
|
|
81
|
+
deadCode: { ...defaults.deadCode, ...userConfig.deadCode },
|
|
82
|
+
licenseCheck: {
|
|
83
|
+
allowPackages: [
|
|
84
|
+
...(defaults.licenseCheck?.allowPackages || []),
|
|
85
|
+
...(userConfig.licenseCheck?.allowPackages || []),
|
|
86
|
+
],
|
|
87
|
+
allowLicenses: [
|
|
88
|
+
...(defaults.licenseCheck?.allowLicenses || []),
|
|
89
|
+
...(userConfig.licenseCheck?.allowLicenses || []),
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get default configuration
|
|
96
|
+
*/
|
|
97
|
+
function getDefaultConfig() {
|
|
98
|
+
return {
|
|
99
|
+
sourcePath: '.',
|
|
100
|
+
ignoreDirs: [...IGNORED_DIRS],
|
|
101
|
+
lint: {
|
|
102
|
+
rules: {
|
|
103
|
+
'no-console': 'warn',
|
|
104
|
+
'no-debugger': 'error',
|
|
105
|
+
'prefer-const': 'error',
|
|
106
|
+
eqeqeq: ['error', 'always'],
|
|
107
|
+
'@typescript-eslint/no-unused-vars': [
|
|
108
|
+
'error',
|
|
109
|
+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
|
|
110
|
+
],
|
|
111
|
+
'@typescript-eslint/explicit-function-return-type': ['warn'],
|
|
112
|
+
'@typescript-eslint/no-explicit-any': ['warn'],
|
|
113
|
+
'@typescript-eslint/no-floating-promises': ['error'],
|
|
114
|
+
'max-len': ['warn', { code: 100 }],
|
|
115
|
+
semi: ['error', 'always'],
|
|
116
|
+
quotes: ['error', 'single', { avoidEscape: true }],
|
|
117
|
+
'object-curly-spacing': ['error', 'always'],
|
|
118
|
+
'keyword-spacing': ['error', { before: true, after: true }],
|
|
119
|
+
},
|
|
120
|
+
ignorePatterns: [
|
|
121
|
+
'**/node_modules/**',
|
|
122
|
+
'**/dist/**',
|
|
123
|
+
'**/.git/**',
|
|
124
|
+
'**/build/**',
|
|
125
|
+
'**/coverage/**',
|
|
126
|
+
'**/.next/**',
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
prettier: {
|
|
130
|
+
config: {
|
|
131
|
+
semi: true,
|
|
132
|
+
singleQuote: true,
|
|
133
|
+
trailingComma: 'all',
|
|
134
|
+
bracketSpacing: true,
|
|
135
|
+
arrowParens: 'avoid',
|
|
136
|
+
printWidth: 100,
|
|
137
|
+
tabWidth: 2,
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
spellcheck: {
|
|
141
|
+
words: [],
|
|
142
|
+
ignoreWords: [],
|
|
143
|
+
ignorePaths: ['**/node_modules/**', '**/dist/**', '**/.git/**', '**/build/**'],
|
|
144
|
+
},
|
|
145
|
+
security: {
|
|
146
|
+
gitleaks: { enabled: true },
|
|
147
|
+
'npm-audit': { enabled: true, auditLevel: 'moderate' },
|
|
148
|
+
},
|
|
149
|
+
typecheck: { enabled: true },
|
|
150
|
+
cpp: { enabled: true, clangFormat: { style: 'LLVM' } },
|
|
151
|
+
python: { enabled: true, ruff: { lint: true, format: true } },
|
|
152
|
+
swift: { enabled: true },
|
|
153
|
+
kotlin: { enabled: true },
|
|
154
|
+
diffSmell: { enabled: true },
|
|
155
|
+
prBody: { enabled: true, minLength: 20, requireTicket: true },
|
|
156
|
+
duplicate: {
|
|
157
|
+
enabled: true,
|
|
158
|
+
minLines: 5,
|
|
159
|
+
minTokens: 50,
|
|
160
|
+
ignore: DUPLICATE_IGNORE_DEFAULTS,
|
|
161
|
+
formats: DUPLICATE_CODE_FORMATS,
|
|
162
|
+
},
|
|
163
|
+
dependency: { enabled: true, ignore: [] },
|
|
164
|
+
outdatedDeps: { enabled: true, ignore: [] },
|
|
165
|
+
deadCode: { enabled: true, ignoreFiles: DEAD_CODE_IGNORE_DEFAULTS },
|
|
166
|
+
commitlint: {
|
|
167
|
+
enabled: true,
|
|
168
|
+
types: [
|
|
169
|
+
'feat',
|
|
170
|
+
'fix',
|
|
171
|
+
'docs',
|
|
172
|
+
'chore',
|
|
173
|
+
'ci',
|
|
174
|
+
'refactor',
|
|
175
|
+
'perf',
|
|
176
|
+
'style',
|
|
177
|
+
'revert',
|
|
178
|
+
'test',
|
|
179
|
+
'build',
|
|
180
|
+
],
|
|
181
|
+
// Skip release PRs and squash-merge titles that don't follow conventional
|
|
182
|
+
// commits (e.g. "Release 15 (#114)"). commitlint already ignores literal
|
|
183
|
+
// "Merge"/"Revert" messages, but not GitHub squash-merge PR titles.
|
|
184
|
+
ignores: ['^Release\\b', '^chore\\(release\\):'],
|
|
185
|
+
},
|
|
186
|
+
licenseCheck: {
|
|
187
|
+
allowPackages: [...DEFAULT_ALLOW_PACKAGES],
|
|
188
|
+
allowLicenses: [],
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
name: PR CheckMate
|
|
2
|
+
|
|
3
|
+
# The container variant, scaffolded because this repository does not carry
|
|
4
|
+
# pr-checkmate as a dependency.
|
|
5
|
+
#
|
|
6
|
+
# The alternative would be `npx pr-checkmate`, and with no node_modules to reuse
|
|
7
|
+
# that resolves to whatever is newest on the registry and downloads it again on
|
|
8
|
+
# every job: 547 MB and about five minutes, measured. Worse, a major release
|
|
9
|
+
# would land on you without a line changing here — and a major release of a gate
|
|
10
|
+
# can start failing builds that passed yesterday.
|
|
11
|
+
#
|
|
12
|
+
# The image is pulled once and cached by the runner, and the tag below pins the
|
|
13
|
+
# major so nothing moves under you.
|
|
14
|
+
|
|
15
|
+
on:
|
|
16
|
+
pull_request:
|
|
17
|
+
branches: [main, master, develop]
|
|
18
|
+
types: [opened, synchronize, reopened]
|
|
19
|
+
|
|
20
|
+
# Least privilege. `pull-requests: write` is what lets the run upsert its summary
|
|
21
|
+
# comment on the PR; drop it and the checks still run, they just report to the log.
|
|
22
|
+
permissions:
|
|
23
|
+
contents: read
|
|
24
|
+
pull-requests: write
|
|
25
|
+
|
|
26
|
+
# Push three times in a minute and the first two runs become answers to questions
|
|
27
|
+
# nobody is asking any more — they still hold a runner, and they still race to
|
|
28
|
+
# upsert the summary comment, so a stale verdict can land on top of a fresh one.
|
|
29
|
+
# Keyed per PR, so runs on different pull requests never cancel each other.
|
|
30
|
+
concurrency:
|
|
31
|
+
group: pr-checkmate-${{ github.workflow }}-${{ github.ref }}
|
|
32
|
+
cancel-in-progress: true
|
|
33
|
+
|
|
34
|
+
jobs:
|
|
35
|
+
pr-checkmate:
|
|
36
|
+
name: PR CheckMate
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
# A hung step otherwise runs to GitHub's six-hour default before anyone hears
|
|
39
|
+
# about it. Every check has its own internal timeout; this is the backstop.
|
|
40
|
+
timeout-minutes: 20
|
|
41
|
+
|
|
42
|
+
steps:
|
|
43
|
+
- name: Checkout code
|
|
44
|
+
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
45
|
+
with:
|
|
46
|
+
# Required, not optional. Without the full history the PR base commit is
|
|
47
|
+
# not in the clone, no diff range can be built, and every diff-based
|
|
48
|
+
# check skips itself. The run then says `Scan Scope: … set
|
|
49
|
+
# fetch-depth: 0`, which is this line.
|
|
50
|
+
fetch-depth: 0
|
|
51
|
+
|
|
52
|
+
# One job runs the whole registry. Which checks run is decided in
|
|
53
|
+
# pr-checkmate.json (`severity`), not by splitting this into jobs.
|
|
54
|
+
#
|
|
55
|
+
# `--user` is not a detail: without it every file a formatter rewrites comes
|
|
56
|
+
# back owned by root, and the next step in your pipeline fails on
|
|
57
|
+
# permissions long after this one reported success.
|
|
58
|
+
#
|
|
59
|
+
# The environment variables are passed through by name rather than by value:
|
|
60
|
+
# the run reads them to find the PR, and interpolating them into the command
|
|
61
|
+
# line would put their contents into a shell.
|
|
62
|
+
- name: Run PR CheckMate
|
|
63
|
+
env:
|
|
64
|
+
# Not injected automatically: without this the run cannot authenticate,
|
|
65
|
+
# and the summary comment silently never reaches the PR.
|
|
66
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
67
|
+
run: |
|
|
68
|
+
docker run --rm \
|
|
69
|
+
-v "$PWD:/repo" \
|
|
70
|
+
--user "$(id -u):$(id -g)" \
|
|
71
|
+
-e GITHUB_TOKEN \
|
|
72
|
+
-e GITHUB_REPOSITORY \
|
|
73
|
+
-e GITHUB_EVENT_NAME \
|
|
74
|
+
-e GITHUB_EVENT_PATH \
|
|
75
|
+
-e GITHUB_REF \
|
|
76
|
+
-e GITHUB_SHA \
|
|
77
|
+
-e CI \
|
|
78
|
+
-v "$GITHUB_EVENT_PATH:$GITHUB_EVENT_PATH:ro" \
|
|
79
|
+
ghcr.io/mybono/pr-checkmate:__IMAGE_TAG__ all
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
name: PR CheckMate
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [main, master, develop]
|
|
6
|
+
types: [opened, synchronize, reopened]
|
|
7
|
+
|
|
8
|
+
# Least privilege. `pull-requests: write` is what lets the run upsert its summary
|
|
9
|
+
# comment on the PR; drop it and the checks still run, they just report to the log.
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
pull-requests: write
|
|
13
|
+
|
|
14
|
+
# Push three times in a minute and the first two runs become answers to questions
|
|
15
|
+
# nobody is asking any more — they still hold a runner, and they still race to
|
|
16
|
+
# upsert the summary comment, so a stale verdict can land on top of a fresh one.
|
|
17
|
+
# Keyed per PR, so runs on different pull requests never cancel each other.
|
|
18
|
+
concurrency:
|
|
19
|
+
group: pr-checkmate-${{ github.workflow }}-${{ github.ref }}
|
|
20
|
+
cancel-in-progress: true
|
|
21
|
+
|
|
22
|
+
jobs:
|
|
23
|
+
pr-checkmate:
|
|
24
|
+
name: PR CheckMate
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
# A hung step otherwise runs to GitHub's six-hour default before anyone hears
|
|
27
|
+
# about it. Every check here has its own internal timeout; this is the backstop
|
|
28
|
+
# for the ones that cannot fail themselves — a wedged network fetch, a tool
|
|
29
|
+
# waiting on stdin. Raise it for a large monorepo.
|
|
30
|
+
timeout-minutes: 20
|
|
31
|
+
steps:
|
|
32
|
+
- name: Checkout code
|
|
33
|
+
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
34
|
+
with:
|
|
35
|
+
# Required, not optional. Without the full history the PR base commit is
|
|
36
|
+
# not in the clone, no diff range can be built, and every diff-based
|
|
37
|
+
# check — Diff Security, Workflow Security, Dockerfile Security,
|
|
38
|
+
# Sensitive Files and a dozen others — skips itself. The run then says
|
|
39
|
+
# `Scan Scope: … set fetch-depth: 0`, which is this line.
|
|
40
|
+
fetch-depth: 0
|
|
41
|
+
|
|
42
|
+
- name: Setup Node.js
|
|
43
|
+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
44
|
+
with:
|
|
45
|
+
node-version: 24
|
|
46
|
+
cache: 'npm'
|
|
47
|
+
|
|
48
|
+
- name: Install dependencies
|
|
49
|
+
run: npm ci
|
|
50
|
+
|
|
51
|
+
# PR CheckMate fetches only the tooling this repository turns out to need
|
|
52
|
+
# (`npx pr-checkmate doctor` prints what and why). Without this step that
|
|
53
|
+
# tooling is fetched again on every run: the download shrinks, the wait
|
|
54
|
+
# does not. The key carries the pr-checkmate version, so an upgrade fetches
|
|
55
|
+
# afresh instead of reusing tooling meant for the previous one.
|
|
56
|
+
- name: Cache PR CheckMate tooling
|
|
57
|
+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
|
58
|
+
with:
|
|
59
|
+
path: ~/.cache/pr-checkmate
|
|
60
|
+
key: pr-checkmate-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
|
|
61
|
+
restore-keys: |
|
|
62
|
+
pr-checkmate-${{ runner.os }}-
|
|
63
|
+
|
|
64
|
+
# Grype keeps its own vulnerability database, and it is the single largest
|
|
65
|
+
# download in the whole run: 134 MB compressed, 1.9 GB unpacked, refreshed
|
|
66
|
+
# daily upstream. Without this step every job pays for it again. The key is
|
|
67
|
+
# dated rather than content-hashed, because the thing that changes is the
|
|
68
|
+
# upstream database, not anything in this repository — a stale entry is
|
|
69
|
+
# restored by the prefix and grype updates it in place.
|
|
70
|
+
- name: Cache Grype vulnerability database
|
|
71
|
+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
|
72
|
+
with:
|
|
73
|
+
path: ~/.cache/grype
|
|
74
|
+
key: grype-db-${{ runner.os }}-${{ github.run_id }}
|
|
75
|
+
restore-keys: |
|
|
76
|
+
grype-db-${{ runner.os }}-
|
|
77
|
+
|
|
78
|
+
# One job runs the whole registry. Splitting it per check would repeat the
|
|
79
|
+
# checkout and install for every one of them, and the selection of what runs
|
|
80
|
+
# belongs in pr-checkmate.json (`severity`), not in copied YAML.
|
|
81
|
+
#
|
|
82
|
+
# This template is the one `init` scaffolds when pr-checkmate IS a
|
|
83
|
+
# dependency: `npm ci` above installs it, so npx runs that copy at the
|
|
84
|
+
# version your lockfile pins. A repository that does not install it gets
|
|
85
|
+
# the container variant instead, because bare `npx` would resolve to the
|
|
86
|
+
# newest release and download it on every job.
|
|
87
|
+
- name: Run PR CheckMate
|
|
88
|
+
env:
|
|
89
|
+
# Not injected automatically: without this the run cannot authenticate,
|
|
90
|
+
# and the summary comment silently never reaches the PR.
|
|
91
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
92
|
+
run: npx pr-checkmate all
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { logger } from '../../../utils/index.js';
|
|
2
|
+
import { pass, skip } from '../../types.js';
|
|
3
|
+
import { clientFindingOptions, reportSeverityBuckets, reviewLines, } from '../findings.js';
|
|
4
|
+
const PREFIX = 'Banned Imports';
|
|
5
|
+
const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
6
|
+
/**
|
|
7
|
+
* Compile `bannedImports` into matchers that catch a banned package via an ES
|
|
8
|
+
* import, a CommonJS require, or its addition to a manifest dependency list.
|
|
9
|
+
*/
|
|
10
|
+
function compileBans(ctx) {
|
|
11
|
+
const list = ctx.config.bannedImports ?? [];
|
|
12
|
+
return list
|
|
13
|
+
.filter(b => b?.name)
|
|
14
|
+
.map(b => {
|
|
15
|
+
const n = escapeRe(b.name);
|
|
16
|
+
const re = new RegExp(`from\\s+['"]${n}(?:/[^'"]*)?['"]|require\\(\\s*['"]${n}(?:/[^'"]*)?['"]|import\\s+['"]${n}['"]|["']${n}["']\\s*:`);
|
|
17
|
+
return {
|
|
18
|
+
message: b.message ?? `banned dependency: ${b.name}`,
|
|
19
|
+
re,
|
|
20
|
+
severity: b.severity === 'error' ? 'error' : 'warn',
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export const bannedImportsCheck = {
|
|
25
|
+
name: 'Banned Imports',
|
|
26
|
+
phase: 'informational',
|
|
27
|
+
// No `requiresDiff`: a banned import is banned wherever it is, not only where
|
|
28
|
+
// it was just introduced (ticket 067).
|
|
29
|
+
applies(ctx) {
|
|
30
|
+
return (ctx.config.bannedImports?.length ?? 0) > 0;
|
|
31
|
+
},
|
|
32
|
+
async run(ctx) {
|
|
33
|
+
const bans = compileBans(ctx);
|
|
34
|
+
if (bans.length === 0)
|
|
35
|
+
return pass('no banned imports configured');
|
|
36
|
+
try {
|
|
37
|
+
const errors = {};
|
|
38
|
+
const warnings = {};
|
|
39
|
+
const reviewed = await reviewLines(ctx, ['*'], stdout => {
|
|
40
|
+
var _a;
|
|
41
|
+
for (const raw of stdout.split('\n')) {
|
|
42
|
+
if (!raw.startsWith('+') || raw.startsWith('+++'))
|
|
43
|
+
continue;
|
|
44
|
+
const content = raw.slice(1);
|
|
45
|
+
for (const ban of bans) {
|
|
46
|
+
if (ban.re.test(content)) {
|
|
47
|
+
const bucket = ban.severity === 'error' ? errors : warnings;
|
|
48
|
+
(bucket[_a = ban.message] ?? (bucket[_a] = [])).push(content.trim().substring(0, 100));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
// An unreadable file list is not "no banned imports" (ticket 072).
|
|
54
|
+
if (!reviewed)
|
|
55
|
+
return skip('git unavailable');
|
|
56
|
+
// A ban configured as "error" blocks the run, regardless of phase — that
|
|
57
|
+
// is the default `failOn`, and the client can still relax it per repo.
|
|
58
|
+
return reportSeverityBuckets(errors, warnings, {
|
|
59
|
+
prefix: PREFIX,
|
|
60
|
+
errorSummary: n => `${n} banned (error)`,
|
|
61
|
+
warningSummary: n => `${n} banned (warn)`,
|
|
62
|
+
...clientFindingOptions(ctx),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
logger.warn(`[Banned Imports]: ⚠️ Could not analyze diff\n${err}`);
|
|
67
|
+
return skip('diff unavailable');
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
};
|