pr-checkmate 1.23.23 → 2.0.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/README.md +68 -15
- package/cspell.json +3 -8
- package/dist/cli.js +37 -62
- package/dist/config/constants.d.ts +21 -3
- package/dist/config/constants.js +33 -6
- package/dist/config/pr-checkmate-workflow.yml +33 -327
- package/dist/core/checks/dependencies/banned-imports.js +23 -24
- package/dist/core/checks/dependencies/circular-deps.js +1 -0
- package/dist/core/checks/dependencies/dependency-check.js +1 -0
- package/dist/core/checks/dependencies/grype-scan.js +1 -0
- package/dist/core/checks/dependencies/npm-audit.js +6 -1
- package/dist/core/checks/dependencies/vuln-scan.js +1 -0
- package/dist/core/checks/findings.d.ts +198 -19
- package/dist/core/checks/findings.js +474 -22
- package/dist/core/checks/git/custom-rules.js +21 -16
- package/dist/core/checks/git/diff-smell.d.ts +17 -0
- package/dist/core/checks/git/diff-smell.js +43 -24
- package/dist/core/checks/git/large-files.js +14 -2
- package/dist/core/checks/git/leftover-debug.js +23 -14
- package/dist/core/checks/git/lockfile-drift.js +2 -1
- package/dist/core/checks/git/merge-conflict.js +19 -8
- package/dist/core/checks/git/missing-tests.js +22 -6
- package/dist/core/checks/git/todo-fixme.js +10 -9
- package/dist/core/checks/languages/shellcheck.d.ts +8 -0
- package/dist/core/checks/languages/shellcheck.js +55 -0
- package/dist/core/checks/languages/typecheck.js +1 -0
- package/dist/core/checks/pr/pr-size-check.js +2 -1
- package/dist/core/checks/quality/config-validation.d.ts +14 -4
- package/dist/core/checks/quality/config-validation.js +119 -17
- package/dist/core/checks/quality/dead-code.js +1 -0
- package/dist/core/checks/quality/duplicate-check.js +1 -0
- package/dist/core/checks/quality/license-header.js +12 -2
- package/dist/core/checks/quality/spellcheck.d.ts +50 -0
- package/dist/core/checks/quality/spellcheck.js +141 -13
- package/dist/core/checks/quality/symlinks.d.ts +16 -0
- package/dist/core/checks/quality/symlinks.js +62 -0
- package/dist/core/checks/quality/yaml-lint.js +22 -9
- package/dist/core/checks/security/diff-security.js +111 -28
- package/dist/core/checks/security/dockerfile-security.js +23 -20
- package/dist/core/checks/security/migration-safety.js +19 -17
- package/dist/core/checks/security/sensitive-file-guard.js +37 -5
- package/dist/core/checks/security/workflow-security.d.ts +10 -0
- package/dist/core/checks/security/workflow-security.js +48 -26
- package/dist/core/commands.d.ts +27 -0
- package/dist/core/commands.js +91 -0
- package/dist/core/context.d.ts +12 -3
- package/dist/core/context.js +118 -16
- package/dist/core/install/cache.d.ts +39 -0
- package/dist/core/install/cache.js +99 -0
- package/dist/core/install/doctor.d.ts +35 -0
- package/dist/core/install/doctor.js +145 -0
- package/dist/core/install/ensure.d.ts +60 -0
- package/dist/core/install/ensure.js +169 -0
- package/dist/core/install/lock.d.ts +33 -0
- package/dist/core/install/lock.js +99 -0
- package/dist/core/install/profiles.d.ts +64 -0
- package/dist/core/install/profiles.js +170 -0
- package/dist/core/registry.js +4 -0
- package/dist/core/reporters.d.ts +13 -2
- package/dist/core/reporters.js +145 -104
- package/dist/core/run-checks.js +91 -14
- package/dist/core/targets.js +26 -4
- package/dist/core/types.d.ts +49 -1
- package/dist/init.d.ts +29 -14
- package/dist/init.js +204 -262
- package/dist/interfaces/index.d.ts +130 -0
- package/dist/scripts/generate-install-manifests.d.ts +39 -0
- package/dist/scripts/generate-install-manifests.js +121 -0
- package/dist/scripts/publish-github.js +18 -4
- package/dist/utils/detect-language.d.ts +37 -4
- package/dist/utils/detect-language.js +113 -19
- package/dist/utils/http.d.ts +59 -0
- package/dist/utils/http.js +119 -0
- package/dist/utils/logger.d.ts +52 -6
- package/dist/utils/logger.js +125 -33
- package/dist/utils/pool.d.ts +49 -0
- package/dist/utils/pool.js +124 -0
- package/dist/utils/update-notifier.d.ts +9 -0
- package/dist/utils/update-notifier.js +57 -3
- package/eslint.config.mjs +14 -2
- package/install-manifests/commitlint/package-lock.json +1028 -0
- package/install-manifests/commitlint/package.json +9 -0
- package/install-manifests/core/package-lock.json +1335 -0
- package/install-manifests/core/package.json +11 -0
- package/install-manifests/cpp/package-lock.json +29 -0
- package/install-manifests/cpp/package.json +8 -0
- package/install-manifests/duplicate/package-lock.json +113 -0
- package/install-manifests/duplicate/package.json +8 -0
- package/install-manifests/js/package-lock.json +5099 -0
- package/install-manifests/js/package.json +26 -0
- package/install-manifests/markdown/package-lock.json +1281 -0
- package/install-manifests/markdown/package.json +8 -0
- package/install-manifests/python/package-lock.json +21 -0
- package/install-manifests/python/package.json +8 -0
- package/install-manifests/spellcheck/package-lock.json +1047 -0
- package/install-manifests/spellcheck/package.json +8 -0
- package/package.json +13 -28
- package/pr-checkmate.schema.json +1070 -96
- package/src/config/cspell.json +3 -8
- package/src/config/pr-checkmate-workflow.yml +33 -327
- package/src/config/pr-checkmate.schema.json +1070 -96
|
@@ -3,9 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isMajorUpgrade = isMajorUpgrade;
|
|
6
7
|
exports.getUpdateNotice = getUpdateNotice;
|
|
7
8
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
// Imported from the module rather than the `../config` barrel on purpose:
|
|
11
|
+
// `config/index.ts` imports `../utils`, so going through the barrel would make
|
|
12
|
+
// utils ⇄ config circular. `constants.ts` itself pulls in nothing from utils.
|
|
13
|
+
const constants_1 = require("../config/constants");
|
|
14
|
+
// Same widths as the run summary in `reporters.ts`, so the two boxes line up
|
|
15
|
+
// when both are printed at the end of a run.
|
|
16
|
+
const NOTICE_BORDER = '═'.repeat(63);
|
|
17
|
+
const NOTICE_RULE = '─'.repeat(63);
|
|
9
18
|
/** Compare dotted versions; true when `latest` is strictly greater than `current`. */
|
|
10
19
|
function isNewer(latest, current) {
|
|
11
20
|
const a = latest.split('.').map(n => parseInt(n, 10) || 0);
|
|
@@ -16,6 +25,33 @@ function isNewer(latest, current) {
|
|
|
16
25
|
}
|
|
17
26
|
return false;
|
|
18
27
|
}
|
|
28
|
+
/** True when the upgrade crosses a major version, i.e. behaviour may change. */
|
|
29
|
+
function isMajorUpgrade(latest, current) {
|
|
30
|
+
return (parseInt(latest.split('.')[0], 10) || 0) > (parseInt(current.split('.')[0], 10) || 0);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Extra lines for a major upgrade. A patch bump is a routine "install it"; a
|
|
34
|
+
* major one can change what fails a build, and finding that out from a red PR is
|
|
35
|
+
* the wrong way to learn it. Says what to read and how to stage the rollout,
|
|
36
|
+
* because the answer to "everything went red" should arrive before it happens.
|
|
37
|
+
*/
|
|
38
|
+
function majorNotice(pkgName) {
|
|
39
|
+
return [
|
|
40
|
+
NOTICE_RULE,
|
|
41
|
+
' ⚠️ MAJOR VERSION — behaviour changes, read before upgrading',
|
|
42
|
+
'',
|
|
43
|
+
' Findings a check rates "error" now BLOCK the run. Previously they were',
|
|
44
|
+
' reported and the run still passed, so a repo with existing findings will',
|
|
45
|
+
' start failing its PRs.',
|
|
46
|
+
'',
|
|
47
|
+
' To stage it, make everything advisory first and promote checks back one',
|
|
48
|
+
' at a time — in pr-checkmate.json:',
|
|
49
|
+
' "severityDefaults": { "failOn": "warn" }',
|
|
50
|
+
' "severity": { "Security Scan": "error" }',
|
|
51
|
+
'',
|
|
52
|
+
` Full notes: https://www.npmjs.com/package/${pkgName}?activeTab=versions`,
|
|
53
|
+
];
|
|
54
|
+
}
|
|
19
55
|
/**
|
|
20
56
|
* Best-effort check for a newer published version. Returns the notice lines when
|
|
21
57
|
* an update exists, or `null` (up-to-date, offline, timed out, or opted out).
|
|
@@ -24,6 +60,13 @@ function isNewer(latest, current) {
|
|
|
24
60
|
* the caller can print them at the very end — after the summary — where they're
|
|
25
61
|
* noticeable. Deliberately called ONLY from the CLI (not `runChecks`) so
|
|
26
62
|
* programmatic consumers (e.g. a wrapping SDK) never trigger a network call.
|
|
63
|
+
*
|
|
64
|
+
* The notice is framed like the run summary so it is noticed, but it is now a
|
|
65
|
+
* one-liner: upgrading is just installing. It used to demand `npx pr-checkmate
|
|
66
|
+
* init` afterwards, because `init` copied the release's new defaults into the
|
|
67
|
+
* client's config — a step nobody could safely skip, for a file that should
|
|
68
|
+
* never have held those defaults in the first place. They are merged in when the
|
|
69
|
+
* config loads, so the second step no longer exists.
|
|
27
70
|
*/
|
|
28
71
|
async function getUpdateNotice(timeoutMs = 2500) {
|
|
29
72
|
if (process.env.PR_CHECKMATE_NO_UPDATE_CHECK)
|
|
@@ -45,10 +88,21 @@ async function getUpdateNotice(timeoutMs = 2500) {
|
|
|
45
88
|
clearTimeout(timer);
|
|
46
89
|
}
|
|
47
90
|
if (latest && isNewer(latest, pkg.version)) {
|
|
91
|
+
const major = isMajorUpgrade(latest, pkg.version);
|
|
48
92
|
return [
|
|
49
|
-
|
|
50
|
-
`
|
|
51
|
-
|
|
93
|
+
NOTICE_BORDER,
|
|
94
|
+
` ⬆️ UPDATE AVAILABLE — ${pkg.name} ${pkg.version} → ${latest}`,
|
|
95
|
+
...(major ? majorNotice(pkg.name) : []),
|
|
96
|
+
NOTICE_RULE,
|
|
97
|
+
` Install: npm install ${pkg.name}@latest`,
|
|
98
|
+
'',
|
|
99
|
+
' That is the whole upgrade. New checks and new defaults apply on their',
|
|
100
|
+
' own — your pr-checkmate.json holds only what you changed, and nothing',
|
|
101
|
+
' in it needs topping up.',
|
|
102
|
+
NOTICE_RULE,
|
|
103
|
+
` 📚 Docs: ${constants_1.DOCS_URL}`,
|
|
104
|
+
` 📦 Release: https://www.npmjs.com/package/${pkg.name}`,
|
|
105
|
+
NOTICE_BORDER,
|
|
52
106
|
];
|
|
53
107
|
}
|
|
54
108
|
return null;
|
package/eslint.config.mjs
CHANGED
|
@@ -101,6 +101,18 @@ function loadUserConfig() {
|
|
|
101
101
|
const userConfig = loadUserConfig();
|
|
102
102
|
const SRC = userConfig.sourcePath || 'src';
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Directories linted in addition to `sourcePath`.
|
|
106
|
+
*
|
|
107
|
+
* Test suites commonly live outside the source tree, and a pattern built from
|
|
108
|
+
* `sourcePath` alone silently skips them — the files most likely to accumulate
|
|
109
|
+
* dead helpers and stray `console.log` go unchecked, and nothing says so. A
|
|
110
|
+
* project without these directories simply matches nothing here.
|
|
111
|
+
*/
|
|
112
|
+
const EXTRA_LINT_DIRS = ['tests', 'test', '__tests__'];
|
|
113
|
+
|
|
114
|
+
const LINT_GLOBS = [SRC, ...EXTRA_LINT_DIRS].map(dir => `${dir}/**/*.{ts,tsx,js,jsx}`);
|
|
115
|
+
|
|
104
116
|
// Merge default rules with user-defined rules
|
|
105
117
|
const mergedRules = {
|
|
106
118
|
...defaultRules,
|
|
@@ -144,7 +156,7 @@ if (customIgnoresCount > 0) {
|
|
|
144
156
|
console.error(`🚫 Applied ${customIgnoresCount} custom ignore patterns`);
|
|
145
157
|
}
|
|
146
158
|
|
|
147
|
-
console.error(`ESLint checking: ${
|
|
159
|
+
console.error(`ESLint checking: ${LINT_GLOBS.join(', ')}`);
|
|
148
160
|
|
|
149
161
|
export default [
|
|
150
162
|
// Global ignores must be in a separate config object
|
|
@@ -152,7 +164,7 @@ export default [
|
|
|
152
164
|
ignores: mergedIgnores,
|
|
153
165
|
},
|
|
154
166
|
{
|
|
155
|
-
files:
|
|
167
|
+
files: LINT_GLOBS,
|
|
156
168
|
|
|
157
169
|
languageOptions: {
|
|
158
170
|
parser: tsParser,
|