pr-checkmate 3.0.4 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/cjs/core/checks/languages/go-format.js +202 -0
- 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/{core → cjs/core}/checks/quality/markdown-lint.js +17 -17
- 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/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/cjs/utils/execa.js +46 -0
- 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/{core → esm/core}/checks/languages/go-format.js +29 -35
- 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 +104 -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/{utils → esm/utils}/execa.js +1 -4
- 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/package.json +15 -13
- package/dist/core/checks/languages/lint.d.ts +0 -2
- 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}/install/profiles.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}/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,45 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { logger } from '../utils/index.js';
|
|
5
|
+
function publishToGithub() {
|
|
6
|
+
const root = process.cwd();
|
|
7
|
+
const pkgPath = path.join(root, 'package.json');
|
|
8
|
+
const tempPath = path.join(root, 'package.json.github');
|
|
9
|
+
const backupPath = path.join(root, 'package.json.bak');
|
|
10
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
11
|
+
pkg.name = '@mybono/pr-checkmate';
|
|
12
|
+
pkg.publishConfig = {
|
|
13
|
+
registry: 'https://npm.pkg.github.com',
|
|
14
|
+
access: 'public',
|
|
15
|
+
};
|
|
16
|
+
delete pkg.scripts?.prepublishOnly;
|
|
17
|
+
fs.writeFileSync(tempPath, JSON.stringify(pkg, null, 2));
|
|
18
|
+
try {
|
|
19
|
+
// `fs.renameSync` rather than shelling out to `mv`: the paths are built here
|
|
20
|
+
// and are not attacker-controlled, but a template literal inside execSync is
|
|
21
|
+
// a shell invocation regardless, and one that runs holding npm credentials.
|
|
22
|
+
// Found by our own Diff Security once `--full` began reviewing whole files
|
|
23
|
+
// (ticket 067) — the delta mode could never see it, since the file is old.
|
|
24
|
+
fs.renameSync(pkgPath, backupPath);
|
|
25
|
+
fs.renameSync(tempPath, pkgPath);
|
|
26
|
+
execSync('npm publish --registry=https://npm.pkg.github.com', { stdio: 'inherit' });
|
|
27
|
+
logger.log('[publishToGithub]: ✅ Published to GitHub Packages');
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
logger.error(`[publishToGithub]: ${err}`);
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
// The backup only exists if the first rename succeeded; restoring is
|
|
34
|
+
// best-effort so a failure here cannot mask the original error.
|
|
35
|
+
if (fs.existsSync(backupPath)) {
|
|
36
|
+
try {
|
|
37
|
+
fs.renameSync(backupPath, pkgPath);
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
logger.error(`[publishToGithub]: could not restore package.json: ${err}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
publishToGithub();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True when running inside a CI/CD build.
|
|
3
|
+
*
|
|
4
|
+
* Decides the default review scope: a build looks at the diff (that is the point
|
|
5
|
+
* of a PR gate), a human at a terminal looks at the whole project — the local
|
|
6
|
+
* `HEAD^` default used to check only the last commit, so a repo could report a
|
|
7
|
+
* clean run with a `debugger` sitting in it.
|
|
8
|
+
*
|
|
9
|
+
* @param env Environment to inspect. Defaults to the current process.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isCiEnvironment(env?: NodeJS.ProcessEnv): boolean;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment variables that mean "this is an automated build". `CI` alone covers
|
|
3
|
+
* GitHub Actions, GitLab, Bitbucket, CircleCI, Buildkite, Travis and most others;
|
|
4
|
+
* the rest are providers that either predate the convention or set only their own
|
|
5
|
+
* marker (Jenkins, TeamCity, Azure Pipelines, AWS CodeBuild).
|
|
6
|
+
*
|
|
7
|
+
* This answers a different question from `detectPlatform()` in reporters.ts, which
|
|
8
|
+
* picks WHERE to post a PR comment and therefore only knows the three platforms we
|
|
9
|
+
* can comment on. A Jenkins build is CI but has nowhere to post.
|
|
10
|
+
*/
|
|
11
|
+
const CI_ENV_VARS = [
|
|
12
|
+
'CI',
|
|
13
|
+
'GITHUB_ACTIONS',
|
|
14
|
+
'GITLAB_CI',
|
|
15
|
+
'BITBUCKET_BUILD_NUMBER',
|
|
16
|
+
'JENKINS_URL',
|
|
17
|
+
'TEAMCITY_VERSION',
|
|
18
|
+
'TF_BUILD',
|
|
19
|
+
'CIRCLECI',
|
|
20
|
+
'BUILDKITE',
|
|
21
|
+
'CODEBUILD_BUILD_ID',
|
|
22
|
+
];
|
|
23
|
+
/** Values that are present but mean "no" — some tooling exports `CI=false`. */
|
|
24
|
+
const FALSY = new Set(['', '0', 'false', 'no', 'off']);
|
|
25
|
+
/**
|
|
26
|
+
* True when running inside a CI/CD build.
|
|
27
|
+
*
|
|
28
|
+
* Decides the default review scope: a build looks at the diff (that is the point
|
|
29
|
+
* of a PR gate), a human at a terminal looks at the whole project — the local
|
|
30
|
+
* `HEAD^` default used to check only the last commit, so a repo could report a
|
|
31
|
+
* clean run with a `debugger` sitting in it.
|
|
32
|
+
*
|
|
33
|
+
* @param env Environment to inspect. Defaults to the current process.
|
|
34
|
+
*/
|
|
35
|
+
export function isCiEnvironment(env = process.env) {
|
|
36
|
+
return CI_ENV_VARS.some(name => {
|
|
37
|
+
const value = env[name];
|
|
38
|
+
return value !== undefined && !FALSY.has(value.trim().toLowerCase());
|
|
39
|
+
});
|
|
40
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** Client `detect` block: how strictly a language is inferred from the tree. */
|
|
2
|
+
export interface DetectOptions {
|
|
3
|
+
/** Source files needed to count a language as present. A marker file bypasses it. */
|
|
4
|
+
minFiles?: number;
|
|
5
|
+
/** Extra paths excluded from the count, on top of the built-in list. */
|
|
6
|
+
excludePaths?: string[];
|
|
7
|
+
/** Languages never reported, whatever the tree looks like. */
|
|
8
|
+
disable?: Language[];
|
|
9
|
+
}
|
|
10
|
+
export type Language = 'typescript' | 'javascript' | 'python' | 'cpp' | 'swift' | 'kotlin' | 'go' | 'rust' | 'csharp' | 'ruby' | 'php';
|
|
11
|
+
/** One detected language, with the evidence that detected it. */
|
|
12
|
+
export interface LanguageUsage {
|
|
13
|
+
lang: Language;
|
|
14
|
+
/** Tracked source files, excluding generated, vendored and manifest files. */
|
|
15
|
+
files: number;
|
|
16
|
+
/** A marker file declares the language regardless of the file count. */
|
|
17
|
+
marker: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Detects the languages a repository uses, and *why* each one was detected.
|
|
21
|
+
*
|
|
22
|
+
* Two different decisions read this, and they should not read it the same way:
|
|
23
|
+
*
|
|
24
|
+
* - **Which checks to run.** A marker is enough. A repo scaffolded from a
|
|
25
|
+
* template has `pyproject.toml` and no `.py` yet, and running Python checks on
|
|
26
|
+
* it costs nothing but a skip.
|
|
27
|
+
* - **Which toolchains to download** (ticket 064). A marker is *not* enough — a
|
|
28
|
+
* `Cargo.toml` beside zero `.rs` files would pull a Rust profile on every CI
|
|
29
|
+
* run for a language nobody has written yet. That decision wants `files > 0`.
|
|
30
|
+
*
|
|
31
|
+
* Returning the evidence rather than a bare list is what lets each caller pick.
|
|
32
|
+
*
|
|
33
|
+
* @param root Repository root.
|
|
34
|
+
* @param ignoreDirs Directory names whose contents do not count as the repo's own
|
|
35
|
+
* code. Defaults to the curated list; `buildContext` passes the client's
|
|
36
|
+
* `ignoreDirs` so a repo that vendors dependencies is described by its own
|
|
37
|
+
* sources. Marker files are unaffected — they are only ever read from `root`.
|
|
38
|
+
* @param detect Client overrides for the heuristics.
|
|
39
|
+
* @returns languages ordered by tracked file count (most-used first). `.h` headers
|
|
40
|
+
* are intentionally excluded from the C++ count since they are ambiguous with C.
|
|
41
|
+
*/
|
|
42
|
+
export declare function detectLanguageUsage(root?: string, ignoreDirs?: string[], detect?: DetectOptions): Promise<LanguageUsage[]>;
|
|
43
|
+
/**
|
|
44
|
+
* The languages a repository uses, most-used first — the answer to "which checks
|
|
45
|
+
* should run". See {@link detectLanguageUsage} when the file counts matter, as
|
|
46
|
+
* they do for deciding what to download.
|
|
47
|
+
*/
|
|
48
|
+
export declare function detectLanguages(root?: string, ignoreDirs?: string[], detect?: DetectOptions): Promise<Language[]>;
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { IGNORED_DIRS } from '../config/constants.js';
|
|
4
|
+
import { execa } from './execa.js';
|
|
5
|
+
import { globToRegExp, isUnderIgnoredDir, matchesAnyGlob } from './glob.js';
|
|
6
|
+
import { logger } from './logger.js';
|
|
7
|
+
/**
|
|
8
|
+
* Marker files that unambiguously indicate a language's presence, independent of
|
|
9
|
+
* how many source files are tracked. Presence of any marker forces detection even
|
|
10
|
+
* when the file count is low (e.g. a fresh repo scaffolded from a template).
|
|
11
|
+
*/
|
|
12
|
+
const MARKER_FILES = {
|
|
13
|
+
typescript: ['tsconfig.json'],
|
|
14
|
+
// Deliberately empty. `package.json` used to sit here, and it is the one marker
|
|
15
|
+
// this package creates itself: installing pr-checkmate through npm puts a
|
|
16
|
+
// `package.json` in a repository that may not hold a single line of JavaScript.
|
|
17
|
+
// A Python service then detected as JavaScript and got the whole JS half of the
|
|
18
|
+
// report — ESLint, Prettier, NPM Audit, License Check — every row of it about
|
|
19
|
+
// the file that installed us. `install/profiles.ts` already refused to buy
|
|
20
|
+
// 152 MB of toolchain off this marker (ticket 064); the checks now refuse to
|
|
21
|
+
// run off it for the same reason. Real JavaScript is detected by its `.js`,
|
|
22
|
+
// `.jsx`, `.mjs` and `.cjs` files, and a repository that has none loses
|
|
23
|
+
// nothing: every JS check it lost would have reported "no files" anyway.
|
|
24
|
+
javascript: [],
|
|
25
|
+
python: ['pyproject.toml', 'setup.py', 'setup.cfg', 'requirements.txt', 'Pipfile'],
|
|
26
|
+
cpp: ['CMakeLists.txt', 'compile_commands.json', 'conanfile.txt', 'conanfile.py'],
|
|
27
|
+
swift: ['Package.swift', 'Package.resolved'],
|
|
28
|
+
kotlin: [
|
|
29
|
+
'build.gradle',
|
|
30
|
+
'build.gradle.kts',
|
|
31
|
+
'settings.gradle',
|
|
32
|
+
'settings.gradle.kts',
|
|
33
|
+
'AndroidManifest.xml',
|
|
34
|
+
],
|
|
35
|
+
go: ['go.mod'],
|
|
36
|
+
rust: ['Cargo.toml'],
|
|
37
|
+
// Glob markers (`*.csproj`/`*.sln`) — matched against root dir entries, since
|
|
38
|
+
// C# projects have no single fixed marker filename.
|
|
39
|
+
csharp: ['*.csproj', '*.sln'],
|
|
40
|
+
ruby: ['Gemfile', '.rubocop.yml'],
|
|
41
|
+
php: ['composer.json'],
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Paths whose files never count towards a language, on top of `ignoreDirs`.
|
|
45
|
+
*
|
|
46
|
+
* Every entry here comes from a real client repository, not from imagination:
|
|
47
|
+
*
|
|
48
|
+
* - `**\/*UnitTest*\/**` — Gradle/Android writes HTML+JS test reports into
|
|
49
|
+
* `tests/testProdReleaseUnitTest_25.4.11/js/`. One generated `report.js` was
|
|
50
|
+
* enough to make a 302-file Kotlin project detect as JavaScript.
|
|
51
|
+
* - `get-pip.py` — vendored bootstrap script, not the project's Python.
|
|
52
|
+
* - `vendor` / `third_party` — dependencies someone committed; the repo did not
|
|
53
|
+
* write them and should not be judged by them.
|
|
54
|
+
*/
|
|
55
|
+
const DEFAULT_DETECT_EXCLUDES = [
|
|
56
|
+
'**/*UnitTest*/**',
|
|
57
|
+
'**/get-pip.py',
|
|
58
|
+
'**/vendor/**',
|
|
59
|
+
'**/third_party/**',
|
|
60
|
+
];
|
|
61
|
+
/**
|
|
62
|
+
* Extensions that mean a different language depending on where the file sits.
|
|
63
|
+
*
|
|
64
|
+
* `.rs` is Rust almost everywhere — but in an Android project `src/main/rs/`
|
|
65
|
+
* holds RenderScript, and `BrainEyeAndroid/src/main/rs/yuv2rgb.rs` made a mobile
|
|
66
|
+
* SDK detect as a Rust project. Real Rust (`build.rs`, `src/main.rs` in a Tauri
|
|
67
|
+
* app) is unaffected, which is why this is a path rule rather than a count threshold.
|
|
68
|
+
*/
|
|
69
|
+
const EXTENSION_COLLISIONS = [
|
|
70
|
+
{ ext: '.rs', notUnder: /(^|\/)src\/main\/rs\//, lang: 'rust' },
|
|
71
|
+
];
|
|
72
|
+
/**
|
|
73
|
+
* Source extensions per language, used to count tracked files via `git ls-files`.
|
|
74
|
+
*/
|
|
75
|
+
const EXTENSIONS = {
|
|
76
|
+
typescript: ['.ts', '.tsx'],
|
|
77
|
+
javascript: ['.js', '.jsx', '.mjs', '.cjs'],
|
|
78
|
+
python: ['.py', '.pyi'],
|
|
79
|
+
cpp: ['.cpp', '.cc', '.cxx', '.c++', '.hpp', '.hh', '.hxx'],
|
|
80
|
+
swift: ['.swift'],
|
|
81
|
+
kotlin: ['.kt', '.kts', '.java'],
|
|
82
|
+
go: ['.go'],
|
|
83
|
+
rust: ['.rs'],
|
|
84
|
+
csharp: ['.cs'],
|
|
85
|
+
ruby: ['.rb', '.rake'],
|
|
86
|
+
php: ['.php'],
|
|
87
|
+
};
|
|
88
|
+
function hasMarker(root, lang) {
|
|
89
|
+
return MARKER_FILES[lang].some(name => {
|
|
90
|
+
if (!name.includes('*'))
|
|
91
|
+
return fs.existsSync(path.join(root, name));
|
|
92
|
+
// Glob marker (e.g. `*.csproj`): match against root-directory entries.
|
|
93
|
+
try {
|
|
94
|
+
const re = globToRegExp(name);
|
|
95
|
+
return fs.readdirSync(root).some(entry => re.test(entry));
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Every marker filename that is also a source file, so it is never counted as
|
|
104
|
+
* one. `Package.swift` is a Swift *manifest*: counting it made a C++ repository
|
|
105
|
+
* report one Swift source it does not have. Same shape for `setup.py` and
|
|
106
|
+
* `conanfile.py`.
|
|
107
|
+
*
|
|
108
|
+
* The marker still detects the language on its own — that path is untouched.
|
|
109
|
+
* What changes is only that a manifest no longer inflates the file count, which
|
|
110
|
+
* is what the install decision in ticket 064 will read.
|
|
111
|
+
*/
|
|
112
|
+
function markerFilenames() {
|
|
113
|
+
const names = new Set();
|
|
114
|
+
for (const list of Object.values(MARKER_FILES)) {
|
|
115
|
+
for (const name of list) {
|
|
116
|
+
if (!name.includes('*') && path.extname(name))
|
|
117
|
+
names.add(name);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return names;
|
|
121
|
+
}
|
|
122
|
+
/** Which language a file counts towards, or null when it counts towards none. */
|
|
123
|
+
function languageOf(file, ext) {
|
|
124
|
+
for (const collision of EXTENSION_COLLISIONS) {
|
|
125
|
+
if (ext === collision.ext) {
|
|
126
|
+
return collision.notUnder.test(file) ? null : collision.lang;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
for (const lang of Object.keys(EXTENSIONS)) {
|
|
130
|
+
if (EXTENSIONS[lang].includes(ext))
|
|
131
|
+
return lang;
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
async function countTrackedFiles(root, ignoreDirs, excludePaths) {
|
|
136
|
+
const counts = {
|
|
137
|
+
typescript: 0,
|
|
138
|
+
javascript: 0,
|
|
139
|
+
python: 0,
|
|
140
|
+
cpp: 0,
|
|
141
|
+
swift: 0,
|
|
142
|
+
kotlin: 0,
|
|
143
|
+
go: 0,
|
|
144
|
+
rust: 0,
|
|
145
|
+
csharp: 0,
|
|
146
|
+
ruby: 0,
|
|
147
|
+
php: 0,
|
|
148
|
+
};
|
|
149
|
+
try {
|
|
150
|
+
const { stdout } = await execa('git', ['ls-files'], { cwd: root });
|
|
151
|
+
const files = stdout.split('\n').map(f => f.trim());
|
|
152
|
+
const ignored = new Set(ignoreDirs);
|
|
153
|
+
const markers = markerFilenames();
|
|
154
|
+
for (const file of files) {
|
|
155
|
+
if (!file)
|
|
156
|
+
continue;
|
|
157
|
+
// A repository that commits its dependencies (`node_modules`, `vendor`,
|
|
158
|
+
// `third_party`) would otherwise be detected as a Python/Go/PHP project off
|
|
159
|
+
// the back of files nobody in it wrote, switching on whole toolchains for
|
|
160
|
+
// languages absent from the source. Detection has to describe the repo's own
|
|
161
|
+
// code, since it decides which checks run at all — the same exclusion every
|
|
162
|
+
// check's file list already applies via `excludeIgnoredDirs`.
|
|
163
|
+
if (isUnderIgnoredDir(file, ignored))
|
|
164
|
+
continue;
|
|
165
|
+
// Generated reports and vendored bootstrap scripts are not the repo's code.
|
|
166
|
+
if (matchesAnyGlob(file, excludePaths))
|
|
167
|
+
continue;
|
|
168
|
+
// A manifest that happens to be source-shaped (`Package.swift`) declares a
|
|
169
|
+
// language; it is not a line of it.
|
|
170
|
+
if (markers.has(path.basename(file)))
|
|
171
|
+
continue;
|
|
172
|
+
const lang = languageOf(file, path.extname(file).toLowerCase());
|
|
173
|
+
if (lang)
|
|
174
|
+
counts[lang] += 1;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
logger.debug('[detectLanguages]: git ls-files unavailable, using marker files only');
|
|
179
|
+
}
|
|
180
|
+
return counts;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Detects the languages a repository uses, and *why* each one was detected.
|
|
184
|
+
*
|
|
185
|
+
* Two different decisions read this, and they should not read it the same way:
|
|
186
|
+
*
|
|
187
|
+
* - **Which checks to run.** A marker is enough. A repo scaffolded from a
|
|
188
|
+
* template has `pyproject.toml` and no `.py` yet, and running Python checks on
|
|
189
|
+
* it costs nothing but a skip.
|
|
190
|
+
* - **Which toolchains to download** (ticket 064). A marker is *not* enough — a
|
|
191
|
+
* `Cargo.toml` beside zero `.rs` files would pull a Rust profile on every CI
|
|
192
|
+
* run for a language nobody has written yet. That decision wants `files > 0`.
|
|
193
|
+
*
|
|
194
|
+
* Returning the evidence rather than a bare list is what lets each caller pick.
|
|
195
|
+
*
|
|
196
|
+
* @param root Repository root.
|
|
197
|
+
* @param ignoreDirs Directory names whose contents do not count as the repo's own
|
|
198
|
+
* code. Defaults to the curated list; `buildContext` passes the client's
|
|
199
|
+
* `ignoreDirs` so a repo that vendors dependencies is described by its own
|
|
200
|
+
* sources. Marker files are unaffected — they are only ever read from `root`.
|
|
201
|
+
* @param detect Client overrides for the heuristics.
|
|
202
|
+
* @returns languages ordered by tracked file count (most-used first). `.h` headers
|
|
203
|
+
* are intentionally excluded from the C++ count since they are ambiguous with C.
|
|
204
|
+
*/
|
|
205
|
+
export async function detectLanguageUsage(root = process.cwd(), ignoreDirs = IGNORED_DIRS, detect = {}) {
|
|
206
|
+
const excludePaths = [...DEFAULT_DETECT_EXCLUDES, ...(detect.excludePaths ?? [])];
|
|
207
|
+
const counts = await countTrackedFiles(root, ignoreDirs, excludePaths);
|
|
208
|
+
// 1 by default: with the causes of the false positives fixed above, a single
|
|
209
|
+
// real source file is a real language. The knob exists for repositories that
|
|
210
|
+
// carry stray one-off scripts they would rather not have checked.
|
|
211
|
+
const minFiles = Math.max(1, detect.minFiles ?? 1);
|
|
212
|
+
const disabled = new Set(detect.disable ?? []);
|
|
213
|
+
const detected = [];
|
|
214
|
+
for (const lang of Object.keys(EXTENSIONS)) {
|
|
215
|
+
if (disabled.has(lang))
|
|
216
|
+
continue;
|
|
217
|
+
const marker = hasMarker(root, lang);
|
|
218
|
+
if (marker || counts[lang] >= minFiles)
|
|
219
|
+
detected.push({ lang, files: counts[lang], marker });
|
|
220
|
+
}
|
|
221
|
+
detected.sort((a, b) => b.files - a.files);
|
|
222
|
+
const countStr = Object.keys(counts).map(l => `${l}=${counts[l]}`).join(', ');
|
|
223
|
+
const names = detected.map(u => u.lang).join(', ');
|
|
224
|
+
logger.info(`[detectLanguages]: Detected ${names || 'none'} (counts: ${countStr})`);
|
|
225
|
+
return detected;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* The languages a repository uses, most-used first — the answer to "which checks
|
|
229
|
+
* should run". See {@link detectLanguageUsage} when the file counts matter, as
|
|
230
|
+
* they do for deciding what to download.
|
|
231
|
+
*/
|
|
232
|
+
export async function detectLanguages(root = process.cwd(), ignoreDirs = IGNORED_DIRS, detect = {}) {
|
|
233
|
+
return (await detectLanguageUsage(root, ignoreDirs, detect)).map(u => u.lang);
|
|
234
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package ecosystems for which we can determine a project's DIRECT (declared)
|
|
3
|
+
* dependencies from a manifest — the set a maintainer actually controls and can
|
|
4
|
+
* bump. Transitive packages (resolved only in a lockfile) are deliberately not
|
|
5
|
+
* here: the consumer cannot fix them directly, so a vuln scan must not flag them.
|
|
6
|
+
*/
|
|
7
|
+
export type Ecosystem = 'npm' | 'python' | 'go' | 'rust' | 'ruby' | 'php';
|
|
8
|
+
/** Canonical key for name comparison within an ecosystem. */
|
|
9
|
+
export declare function normalizeName(ecosystem: Ecosystem, name: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Build the set of DIRECT (declared) dependency names for `cwd`, keyed by
|
|
12
|
+
* ecosystem, by parsing manifests — not lockfiles. Used to filter vulnerability
|
|
13
|
+
* scanner output down to what the consumer actually controls: transitive
|
|
14
|
+
* dependencies (present only in lockfiles) and the scanning tool's own bundled
|
|
15
|
+
* dependencies are absent from these manifests and thus never reported.
|
|
16
|
+
*
|
|
17
|
+
* Dependency-free and best-effort: unparseable/absent manifests contribute
|
|
18
|
+
* nothing rather than throwing. An ecosystem with no manifest yields no entry
|
|
19
|
+
* (callers should treat "no entry" as "cannot classify" — see grype-scan).
|
|
20
|
+
*/
|
|
21
|
+
export declare function collectDirectDeps(cwd: string): Map<Ecosystem, Set<string>>;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
const require = __createRequire(import.meta.url);
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
/** Directories never worth descending into when locating manifests. */
|
|
6
|
+
const SKIP_DIRS = new Set([
|
|
7
|
+
'node_modules',
|
|
8
|
+
'.git',
|
|
9
|
+
'dist',
|
|
10
|
+
'build',
|
|
11
|
+
'vendor',
|
|
12
|
+
'.venv',
|
|
13
|
+
'venv',
|
|
14
|
+
'target',
|
|
15
|
+
]);
|
|
16
|
+
/** PEP 503 normalisation, applied to both manifest and scanner names for Python. */
|
|
17
|
+
function normalizePython(name) {
|
|
18
|
+
return name
|
|
19
|
+
.trim()
|
|
20
|
+
.toLowerCase()
|
|
21
|
+
.replace(/[-_.]+/g, '-');
|
|
22
|
+
}
|
|
23
|
+
/** Canonical key for name comparison within an ecosystem. */
|
|
24
|
+
export function normalizeName(ecosystem, name) {
|
|
25
|
+
return ecosystem === 'python' ? normalizePython(name) : name.trim().toLowerCase();
|
|
26
|
+
}
|
|
27
|
+
function readJson(file) {
|
|
28
|
+
try {
|
|
29
|
+
return JSON.parse(fs.readFileSync(file, 'utf-8'));
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function readText(file) {
|
|
36
|
+
try {
|
|
37
|
+
return fs.readFileSync(file, 'utf-8');
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** Collect direct dep names from a package.json's four dependency maps. */
|
|
44
|
+
function addNpm(file, out) {
|
|
45
|
+
const pkg = readJson(file);
|
|
46
|
+
if (!pkg)
|
|
47
|
+
return;
|
|
48
|
+
for (const key of [
|
|
49
|
+
'dependencies',
|
|
50
|
+
'devDependencies',
|
|
51
|
+
'peerDependencies',
|
|
52
|
+
'optionalDependencies',
|
|
53
|
+
]) {
|
|
54
|
+
const map = pkg[key];
|
|
55
|
+
if (map && typeof map === 'object') {
|
|
56
|
+
for (const name of Object.keys(map))
|
|
57
|
+
out.add(normalizeName('npm', name));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/** Extract the bare package name from a Python requirement specifier line. */
|
|
62
|
+
function pythonReqName(line) {
|
|
63
|
+
const stripped = line.split('#')[0].trim();
|
|
64
|
+
if (!stripped || stripped.startsWith('-'))
|
|
65
|
+
return null; // skip options like -r / -e
|
|
66
|
+
const match = /^([A-Za-z0-9._-]+)/.exec(stripped);
|
|
67
|
+
return match ? normalizePython(match[1]) : null;
|
|
68
|
+
}
|
|
69
|
+
function addPython(cwd, out, manifests) {
|
|
70
|
+
for (const file of manifests) {
|
|
71
|
+
const base = path.basename(file);
|
|
72
|
+
if (base.startsWith('requirements') && base.endsWith('.txt')) {
|
|
73
|
+
const text = readText(file);
|
|
74
|
+
if (text)
|
|
75
|
+
text.split('\n').forEach(l => {
|
|
76
|
+
const n = pythonReqName(l);
|
|
77
|
+
if (n)
|
|
78
|
+
out.add(n);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
else if (base === 'pyproject.toml' || base === 'Pipfile') {
|
|
82
|
+
const text = readText(file);
|
|
83
|
+
if (!text)
|
|
84
|
+
continue;
|
|
85
|
+
// Best-effort, parser-free: PEP 621 `dependencies = ["pkg>=1", ...]`,
|
|
86
|
+
// Poetry/Pipfile `pkg = "^1.2"` table entries. Section-agnostic on purpose.
|
|
87
|
+
for (const m of text.matchAll(/["']([A-Za-z0-9._-]+)\s*(?:[<>=!~;)\[]|["'])/g)) {
|
|
88
|
+
const n = normalizePython(m[1]);
|
|
89
|
+
if (n && n !== 'python')
|
|
90
|
+
out.add(n);
|
|
91
|
+
}
|
|
92
|
+
for (const m of text.matchAll(/^\s*([A-Za-z0-9._-]+)\s*=/gm)) {
|
|
93
|
+
const n = normalizePython(m[1]);
|
|
94
|
+
if (n && n !== 'python')
|
|
95
|
+
out.add(n);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function addGo(file, out) {
|
|
101
|
+
const text = readText(file);
|
|
102
|
+
if (!text)
|
|
103
|
+
return;
|
|
104
|
+
// `require ( ... )` block and single-line `require x v...`; skip `// indirect`.
|
|
105
|
+
for (const raw of text.split('\n')) {
|
|
106
|
+
const line = raw.trim();
|
|
107
|
+
if (line.includes('// indirect'))
|
|
108
|
+
continue;
|
|
109
|
+
const m = /^(?:require\s+)?([a-zA-Z0-9._~/-]+\.[a-zA-Z0-9._~/-]+)\s+v/.exec(line);
|
|
110
|
+
if (m)
|
|
111
|
+
out.add(m[1].toLowerCase());
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function addRust(file, out) {
|
|
115
|
+
const text = readText(file);
|
|
116
|
+
if (!text)
|
|
117
|
+
return;
|
|
118
|
+
// Keys under [dependencies] / [dev-dependencies] / [build-dependencies].
|
|
119
|
+
let inDeps = false;
|
|
120
|
+
for (const raw of text.split('\n')) {
|
|
121
|
+
const line = raw.trim();
|
|
122
|
+
if (line.startsWith('[')) {
|
|
123
|
+
inDeps = /^\[(?:.*\.)?(?:dev-|build-)?dependencies\]$/.test(line);
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (!inDeps)
|
|
127
|
+
continue;
|
|
128
|
+
const m = /^([A-Za-z0-9._-]+)\s*=/.exec(line);
|
|
129
|
+
if (m)
|
|
130
|
+
out.add(m[1].toLowerCase());
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function addRuby(file, out) {
|
|
134
|
+
const text = readText(file);
|
|
135
|
+
if (!text)
|
|
136
|
+
return;
|
|
137
|
+
for (const m of text.matchAll(/^\s*gem\s+["']([A-Za-z0-9._-]+)["']/gm)) {
|
|
138
|
+
out.add(m[1].toLowerCase());
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function addPhp(file, out) {
|
|
142
|
+
const pkg = readJson(file);
|
|
143
|
+
if (!pkg)
|
|
144
|
+
return;
|
|
145
|
+
for (const key of ['require', 'require-dev']) {
|
|
146
|
+
const map = pkg[key];
|
|
147
|
+
if (map && typeof map === 'object') {
|
|
148
|
+
for (const name of Object.keys(map)) {
|
|
149
|
+
if (name === 'php' || name.startsWith('ext-'))
|
|
150
|
+
continue;
|
|
151
|
+
out.add(name.toLowerCase());
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/** Recursively list files matching any of `names`, skipping vendored dirs. */
|
|
157
|
+
function findManifests(cwd, names, matchPrefix) {
|
|
158
|
+
const found = [];
|
|
159
|
+
const walk = (dir) => {
|
|
160
|
+
let entries;
|
|
161
|
+
try {
|
|
162
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
for (const entry of entries) {
|
|
168
|
+
if (entry.isDirectory()) {
|
|
169
|
+
if (!SKIP_DIRS.has(entry.name) && !entry.name.startsWith('.')) {
|
|
170
|
+
walk(path.join(dir, entry.name));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else if (names.has(entry.name) || (matchPrefix && matchPrefix.test(entry.name))) {
|
|
174
|
+
found.push(path.join(dir, entry.name));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
walk(cwd);
|
|
179
|
+
return found;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Build the set of DIRECT (declared) dependency names for `cwd`, keyed by
|
|
183
|
+
* ecosystem, by parsing manifests — not lockfiles. Used to filter vulnerability
|
|
184
|
+
* scanner output down to what the consumer actually controls: transitive
|
|
185
|
+
* dependencies (present only in lockfiles) and the scanning tool's own bundled
|
|
186
|
+
* dependencies are absent from these manifests and thus never reported.
|
|
187
|
+
*
|
|
188
|
+
* Dependency-free and best-effort: unparseable/absent manifests contribute
|
|
189
|
+
* nothing rather than throwing. An ecosystem with no manifest yields no entry
|
|
190
|
+
* (callers should treat "no entry" as "cannot classify" — see grype-scan).
|
|
191
|
+
*/
|
|
192
|
+
export function collectDirectDeps(cwd) {
|
|
193
|
+
const result = new Map();
|
|
194
|
+
const npm = new Set();
|
|
195
|
+
findManifests(cwd, new Set(['package.json'])).forEach(f => addNpm(f, npm));
|
|
196
|
+
if (npm.size)
|
|
197
|
+
result.set('npm', npm);
|
|
198
|
+
const python = new Set();
|
|
199
|
+
const pyManifests = findManifests(cwd, new Set(['pyproject.toml', 'Pipfile']), /^requirements.*\.txt$/);
|
|
200
|
+
addPython(cwd, python, pyManifests);
|
|
201
|
+
if (python.size)
|
|
202
|
+
result.set('python', python);
|
|
203
|
+
const go = new Set();
|
|
204
|
+
findManifests(cwd, new Set(['go.mod'])).forEach(f => addGo(f, go));
|
|
205
|
+
if (go.size)
|
|
206
|
+
result.set('go', go);
|
|
207
|
+
const rust = new Set();
|
|
208
|
+
findManifests(cwd, new Set(['Cargo.toml'])).forEach(f => addRust(f, rust));
|
|
209
|
+
if (rust.size)
|
|
210
|
+
result.set('rust', rust);
|
|
211
|
+
const ruby = new Set();
|
|
212
|
+
findManifests(cwd, new Set(['Gemfile'])).forEach(f => addRuby(f, ruby));
|
|
213
|
+
if (ruby.size)
|
|
214
|
+
result.set('ruby', ruby);
|
|
215
|
+
const php = new Set();
|
|
216
|
+
findManifests(cwd, new Set(['composer.json'])).forEach(f => addPhp(f, php));
|
|
217
|
+
if (php.size)
|
|
218
|
+
result.set('php', php);
|
|
219
|
+
return result;
|
|
220
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy loader for {@link https://github.com/sindresorhus/execa | execa}.
|
|
3
|
+
*
|
|
4
|
+
* execa v9 is ESM-only. Because this package compiles to CommonJS, importing
|
|
5
|
+
* execa at module scope forces every consumer to resolve execa's full
|
|
6
|
+
* dependency graph the moment they import pr-checkmate — even consumers that
|
|
7
|
+
* only need the types or a config helper and never run a check. That graph
|
|
8
|
+
* pulls in transitive packages (e.g. `unicorn-magic`) whose `exports` maps some
|
|
9
|
+
* loaders such as `tsx` fail to resolve, which crashes the import for those
|
|
10
|
+
* consumers before any check runs.
|
|
11
|
+
*
|
|
12
|
+
* Loading execa on first use keeps the library entry point cheap and avoids
|
|
13
|
+
* dragging the subprocess toolchain into consumers that never spawn a process.
|
|
14
|
+
*/
|
|
15
|
+
import type { Options, Result } from 'execa';
|
|
16
|
+
/**
|
|
17
|
+
* Run a command via execa, loading the module lazily on first call.
|
|
18
|
+
*
|
|
19
|
+
* Drop-in replacement for `execa(file, args, options)` at every call site in
|
|
20
|
+
* this package — all of which await the result and read it synchronously.
|
|
21
|
+
*/
|
|
22
|
+
export declare function execa<OptionsType extends Options = {}>(file: string, args?: readonly string[], options?: OptionsType): Promise<Result<OptionsType>>;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.execa = execa;
|
|
4
1
|
/**
|
|
5
2
|
* Run a command via execa, loading the module lazily on first call.
|
|
6
3
|
*
|
|
7
4
|
* Drop-in replacement for `execa(file, args, options)` at every call site in
|
|
8
5
|
* this package — all of which await the result and read it synchronously.
|
|
9
6
|
*/
|
|
10
|
-
async function execa(file, args, options) {
|
|
7
|
+
export async function execa(file, args, options) {
|
|
11
8
|
const { execa: run } = await import('execa');
|
|
12
9
|
return (await run(file, args, options));
|
|
13
10
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve a git ref to a concrete commit SHA, or `undefined` when this clone
|
|
3
|
+
* cannot resolve it.
|
|
4
|
+
*
|
|
5
|
+
* `--verify --quiet` emits nothing (rather than echoing the literal ref) and exits
|
|
6
|
+
* non-zero for a missing ref, so the caller gets a clear "not here" instead of a
|
|
7
|
+
* string that looks like a ref but resolves to nothing. Refs go missing more often
|
|
8
|
+
* than it seems: `HEAD^` on a repository's first commit, and any ancestor in a
|
|
9
|
+
* shallow CI clone — `actions/checkout` fetches depth 1 by default.
|
|
10
|
+
*
|
|
11
|
+
* Every caller must degrade rather than fail when this returns `undefined`: a
|
|
12
|
+
* missing base means "review everything", never "review nothing".
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveGitRef(cwd: string, ref: string): Promise<string | undefined>;
|