pr-checkmate 1.21.8 → 1.21.9

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 CHANGED
@@ -1,9 +1,9 @@
1
+ # ♟️ PR CheckMate
2
+
1
3
  ![Build](https://img.shields.io/github/actions/workflow/status/Mybono/sdk_automation/publish.yml?branch=main&label=CI&color=blue)
2
4
  ![ESLint](https://img.shields.io/npm/v/eslint?color=yellow&label=ESLint)
3
5
  ![Prettier](https://img.shields.io/npm/v/prettier?color=orange&label=Prettier)
4
6
 
5
- # ♟️ PR CheckMate
6
- >
7
7
  > **PR CheckMate** is an npm package for automating Pull Request checks.
8
8
  > It helps teams maintain code quality by automatically validating linting, formatting, dependencies, security, and spelling before merging to `main`.
9
9
 
@@ -77,7 +77,7 @@ async function runCommitlint() {
77
77
  result_collector_1.resultCollector.register('Commitlint', 'skip');
78
78
  return;
79
79
  }
80
- utils_1.logger.info('[runCommitlint]: 📝 Running commitlint...');
80
+ utils_1.logger.info('[runCommitlint]: Running commitlint...');
81
81
  const commitlintBin = (0, utils_1.resolvePackageBin)('@commitlint/cli', 'cli.js');
82
82
  const hasLocal = (0, config_1.hasLocalConfig)(LOCAL_CONFIG_FILES);
83
83
  let tempConfigFile = null;
@@ -84,7 +84,7 @@ async function trackSoftCheck(name, fn) {
84
84
  }
85
85
  }
86
86
  async function runJob(jobName) {
87
- utils_1.logger.info(`[runJob]: 🚀 Running job: ${jobName}`);
87
+ utils_1.logger.info(`[runJob]: Running job: ${jobName}`);
88
88
  try {
89
89
  switch (jobName) {
90
90
  case 'all':
@@ -21,7 +21,7 @@ async function getESLintMajorVersion() {
21
21
  }
22
22
  }
23
23
  async function runLint() {
24
- utils_1.logger.info('[runLint]: 🔍 Running ESLint...');
24
+ utils_1.logger.info('[runLint]: Running ESLint...');
25
25
  const eslintBin = (0, utils_1.resolvePackageBin)('eslint', 'bin/eslint.js');
26
26
  const projectRoot = process.cwd();
27
27
  const sourcePath = (0, config_1.getSourcePath)();
@@ -33,7 +33,7 @@ function buildMergedConfig(bundledConfigPath, userRules) {
33
33
  return tmpFile;
34
34
  }
35
35
  async function runMarkdownLint() {
36
- utils_1.logger.info('[runMarkdownLint]: 📝 Running Markdown lint...');
36
+ utils_1.logger.info('[runMarkdownLint]: Running Markdown lint...');
37
37
  const root = process.cwd();
38
38
  const changedFiles = await (0, delta_1.getChangedFiles)(['.md', '.mdx']);
39
39
  let targets;
@@ -53,7 +53,7 @@ async function getBaseSha() {
53
53
  * Run security scan for secrets
54
54
  */
55
55
  async function runSecurityScan() {
56
- utils_1.logger.info('🔐 Running security scan with gitleaks-secret-scanner...');
56
+ utils_1.logger.info('Running security scan with gitleaks-secret-scanner...');
57
57
  try {
58
58
  const headSha = await getHeadSha();
59
59
  if (!headSha) {
@@ -101,7 +101,7 @@ async function runSpellcheck() {
101
101
  let tempConfigPath = null;
102
102
  const cspellBin = (0, utils_1.resolvePackageBin)('cspell', 'bin.mjs');
103
103
  if (hasLocal) {
104
- utils_1.logger.info(`📋 Using local cspell config (checking: ${sourcePath})`);
104
+ utils_1.logger.info(`Using local cspell config (checking: ${sourcePath})`);
105
105
  args = [...patterns, '--no-progress'];
106
106
  }
107
107
  else {
@@ -9,6 +9,22 @@ const utils_1 = require("../utils");
9
9
  const loader_1 = require("../config/loader");
10
10
  const node_fs_1 = __importDefault(require("node:fs"));
11
11
  const node_path_1 = __importDefault(require("node:path"));
12
+ /**
13
+ * Resolves the `tsc` binary, preferring the consumer project's own TypeScript so its
14
+ * tsconfig is compiled by the version it was written for. Falls back to the TypeScript
15
+ * bundled with pr-checkmate when the project has no local install.
16
+ */
17
+ function resolveTsc() {
18
+ try {
19
+ const localTsc = (0, utils_1.resolvePackageBin)('typescript', 'bin/tsc', { paths: [process.cwd()] });
20
+ utils_1.logger.info("[runTypecheck]: Using project's local TypeScript");
21
+ return localTsc;
22
+ }
23
+ catch {
24
+ utils_1.logger.info('[runTypecheck]: No local TypeScript found, using bundled compiler');
25
+ return (0, utils_1.resolvePackageBin)('typescript', 'bin/tsc');
26
+ }
27
+ }
12
28
  async function runTypecheck() {
13
29
  const cfg = (0, loader_1.loadProjectConfig)();
14
30
  if (cfg.typecheck?.enabled === false) {
@@ -21,7 +37,7 @@ async function runTypecheck() {
21
37
  utils_1.logger.info('[runTypecheck]: No tsconfig.json found, skipping');
22
38
  return;
23
39
  }
24
- const tscBin = (0, utils_1.resolvePackageBin)('typescript', 'bin/tsc');
40
+ const tscBin = resolveTsc();
25
41
  const result = await (0, execa_1.execa)(process.execPath, [tscBin, '--noEmit'], { reject: false });
26
42
  if (result.exitCode !== 0) {
27
43
  const output = [result.stdout, result.stderr].filter(Boolean).join('\n');
@@ -13,21 +13,25 @@ const node_fs_1 = __importDefault(require("node:fs"));
13
13
  * 1. Direct subpath — fast path for packages that explicitly export their bin
14
14
  * 2. Via package.json — for packages that export ./package.json but not the bin subpath (e.g. eslint)
15
15
  * 3. Walk up from main entry — for packages that export neither (e.g. cspell)
16
+ *
17
+ * @param options.paths - Directories to resolve from (passed to `require.resolve`).
18
+ * Use `[process.cwd()]` to prefer the consumer project's copy of the package.
16
19
  */
17
- function resolvePackageBin(pkgName, binRelPath) {
20
+ function resolvePackageBin(pkgName, binRelPath, options) {
21
+ const resolveOpts = options?.paths ? { paths: options.paths } : undefined;
18
22
  // 1. Direct subpath
19
23
  try {
20
- return require.resolve(`${pkgName}/${binRelPath}`);
24
+ return require.resolve(`${pkgName}/${binRelPath}`, resolveOpts);
21
25
  }
22
26
  catch { }
23
27
  // 2. Via package.json
24
28
  try {
25
- const pkgJsonPath = require.resolve(`${pkgName}/package.json`);
29
+ const pkgJsonPath = require.resolve(`${pkgName}/package.json`, resolveOpts);
26
30
  return node_path_1.default.join(node_path_1.default.dirname(pkgJsonPath), binRelPath);
27
31
  }
28
32
  catch { }
29
33
  // 3. Walk up from main entry to find package root by matching package name
30
- const main = require.resolve(pkgName);
34
+ const main = require.resolve(pkgName, resolveOpts);
31
35
  let dir = node_path_1.default.dirname(main);
32
36
  while (dir !== node_path_1.default.dirname(dir)) {
33
37
  const pkgJsonPath = node_path_1.default.join(dir, 'package.json');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pr-checkmate",
3
- "version": "1.21.8",
3
+ "version": "1.21.9",
4
4
  "description": "Automated PR quality checks: linting, formatting, dependency analysis, and spellcheck",
5
5
  "keywords": [
6
6
  "github-actions",