pr-checkmate 1.21.6 → 1.21.7

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.
@@ -39,7 +39,7 @@ const DEFAULT_TYPES = [
39
39
  ];
40
40
  function buildTempConfig(types) {
41
41
  const config = {
42
- extends: [require.resolve('@commitlint/config-conventional')],
42
+ extends: [(0, utils_1.resolvePackageBin)('@commitlint/config-conventional', 'index.js')],
43
43
  rules: {
44
44
  'type-enum': [2, 'always', types],
45
45
  },
@@ -74,7 +74,7 @@ async function runCommitlint() {
74
74
  return;
75
75
  }
76
76
  utils_1.logger.info('[runCommitlint]: 📝 Running commitlint...');
77
- const commitlintBin = require.resolve('@commitlint/cli/cli.js');
77
+ const commitlintBin = (0, utils_1.resolvePackageBin)('@commitlint/cli', 'cli.js');
78
78
  const hasLocal = (0, config_1.hasLocalConfig)(LOCAL_CONFIG_FILES);
79
79
  let tempConfigFile = null;
80
80
  const { from, to } = await getCommitRange();
@@ -32,7 +32,7 @@ async function runDuplicateCheck() {
32
32
  // Fall back to src/ or project root when not in delta mode
33
33
  const srcPath = node_path_1.default.join(projectRoot, 'src');
34
34
  const targetPaths = changedFiles ?? (node_fs_1.default.existsSync(srcPath) ? [srcPath] : [projectRoot]);
35
- const jscpdBin = require.resolve('jscpd/bin/jscpd');
35
+ const jscpdBin = (0, utils_1.resolvePackageBin)('jscpd', 'bin/jscpd');
36
36
  try {
37
37
  const result = await (0, execa_1.execa)(process.execPath, [
38
38
  jscpdBin,
@@ -9,12 +9,9 @@ const utils_1 = require("../utils");
9
9
  const delta_1 = require("../utils/delta");
10
10
  const execa_1 = require("execa");
11
11
  const node_path_1 = __importDefault(require("node:path"));
12
- /**
13
- * Detect ESLint major version to choose appropriate config format
14
- */
15
- const eslintBin = require.resolve('eslint/bin/eslint.js');
16
12
  async function getESLintMajorVersion() {
17
13
  try {
14
+ const eslintBin = (0, utils_1.resolvePackageBin)('eslint', 'bin/eslint.js');
18
15
  const { stdout } = await (0, execa_1.execa)(process.execPath, [eslintBin, '--version']);
19
16
  const match = stdout.match(/v?(\d+)\./);
20
17
  return match ? parseInt(match[1], 10) : 8;
@@ -25,6 +22,7 @@ async function getESLintMajorVersion() {
25
22
  }
26
23
  async function runLint() {
27
24
  utils_1.logger.info('[runLint]: 🔍 Running ESLint...');
25
+ const eslintBin = (0, utils_1.resolvePackageBin)('eslint', 'bin/eslint.js');
28
26
  const projectRoot = process.cwd();
29
27
  const sourcePath = (0, config_1.getSourcePath)();
30
28
  const sourceFullPath = node_path_1.default.join(projectRoot, sourcePath);
@@ -90,7 +90,7 @@ async function runMarkdownLint() {
90
90
  const extraIgnores = (userConfig.ignores ?? []).flatMap(p => ['--ignore', p]);
91
91
  const gitignorePath = node_path_1.default.join(root, '.gitignore');
92
92
  const ignorePath = node_fs_1.default.existsSync(gitignorePath) ? ['--ignore-path', gitignorePath] : [];
93
- const markdownlintBin = require.resolve('markdownlint-cli/markdownlint.js');
93
+ const markdownlintBin = (0, utils_1.resolvePackageBin)('markdownlint-cli', 'markdownlint.js');
94
94
  const args = [
95
95
  '--fix',
96
96
  ...targets,
@@ -87,7 +87,7 @@ async function runPrettier() {
87
87
  ]);
88
88
  let args;
89
89
  let tempConfig = null;
90
- const prettierBin = require.resolve('prettier/bin/prettier.cjs');
90
+ const prettierBin = (0, utils_1.resolvePackageBin)('prettier', 'bin/prettier.cjs');
91
91
  if (hasLocal) {
92
92
  utils_1.logger.info(`[runPrettier]: Using local Prettier config (checking: ${sourcePath})`);
93
93
  args = ['--write', ...targets, '--ignore-path', ignorePath];
@@ -68,7 +68,7 @@ async function runSecurityScan() {
68
68
  ...(headSha && { HEAD_SHA: headSha }),
69
69
  ...(baseSha && { BASE_SHA: baseSha }),
70
70
  };
71
- const gitleaksBin = require.resolve('gitleaks-secret-scanner-fixed/bin/cli.js');
71
+ const gitleaksBin = (0, utils_1.resolvePackageBin)('gitleaks-secret-scanner-fixed', 'bin/cli.js');
72
72
  const hasClientConfig = (0, config_1.hasLocalConfig)([
73
73
  '.gitleaks.toml',
74
74
  'gitleaks.toml',
@@ -85,7 +85,7 @@ async function runSpellcheck() {
85
85
  const hasLocal = (0, config_1.hasLocalConfig)(['cspell.json', '.cspell.json', 'cspell.config.json']);
86
86
  let args;
87
87
  let tempConfigPath = null;
88
- const cspellBin = require.resolve('cspell/bin.mjs');
88
+ const cspellBin = (0, utils_1.resolvePackageBin)('cspell', 'bin.mjs');
89
89
  if (hasLocal) {
90
90
  utils_1.logger.info(`📋 Using local cspell config (checking: ${sourcePath})`);
91
91
  args = [...patterns, '--no-progress'];
@@ -21,7 +21,7 @@ async function runTypecheck() {
21
21
  utils_1.logger.info('[runTypecheck]: No tsconfig.json found, skipping');
22
22
  return;
23
23
  }
24
- const tscBin = require.resolve('typescript/bin/tsc');
24
+ const tscBin = (0, utils_1.resolvePackageBin)('typescript', 'bin/tsc');
25
25
  const result = await (0, execa_1.execa)(process.execPath, [tscBin, '--noEmit'], { reject: false });
26
26
  if (result.exitCode !== 0) {
27
27
  const output = [result.stdout, result.stderr].filter(Boolean).join('\n');
@@ -23,6 +23,7 @@ const logger_1 = require("./logger");
23
23
  __exportStar(require("./logger"), exports);
24
24
  __exportStar(require("./delta"), exports);
25
25
  __exportStar(require("./result-collector"), exports);
26
+ __exportStar(require("./resolve-bin"), exports);
26
27
  function cleanupTempFile(filePath) {
27
28
  try {
28
29
  if (node_fs_1.default.existsSync(filePath)) {
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.resolvePackageBin = resolvePackageBin;
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const node_fs_1 = __importDefault(require("node:fs"));
9
+ /**
10
+ * Resolves a binary path for a bundled package, bypassing exports map restrictions.
11
+ *
12
+ * Strategy (tries each in order):
13
+ * 1. Direct subpath — fast path for packages that explicitly export their bin
14
+ * 2. Via package.json — for packages that export ./package.json but not the bin subpath (e.g. eslint)
15
+ * 3. Walk up from main entry — for packages that export neither (e.g. cspell)
16
+ */
17
+ function resolvePackageBin(pkgName, binRelPath) {
18
+ // 1. Direct subpath
19
+ try {
20
+ return require.resolve(`${pkgName}/${binRelPath}`);
21
+ }
22
+ catch { }
23
+ // 2. Via package.json
24
+ try {
25
+ const pkgJsonPath = require.resolve(`${pkgName}/package.json`);
26
+ return node_path_1.default.join(node_path_1.default.dirname(pkgJsonPath), binRelPath);
27
+ }
28
+ catch { }
29
+ // 3. Walk up from main entry to find package root by matching package name
30
+ const main = require.resolve(pkgName);
31
+ let dir = node_path_1.default.dirname(main);
32
+ while (dir !== node_path_1.default.dirname(dir)) {
33
+ const pkgJsonPath = node_path_1.default.join(dir, 'package.json');
34
+ if (node_fs_1.default.existsSync(pkgJsonPath)) {
35
+ try {
36
+ const pkg = JSON.parse(node_fs_1.default.readFileSync(pkgJsonPath, 'utf-8'));
37
+ if (pkg.name === pkgName) {
38
+ return node_path_1.default.join(dir, binRelPath);
39
+ }
40
+ }
41
+ catch { }
42
+ }
43
+ dir = node_path_1.default.dirname(dir);
44
+ }
45
+ throw new Error(`Cannot resolve binary "${binRelPath}" for package "${pkgName}"`);
46
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pr-checkmate",
3
- "version": "1.21.6",
3
+ "version": "1.21.7",
4
4
  "description": "Automated PR quality checks: linting, formatting, dependency analysis, and spellcheck",
5
5
  "keywords": [
6
6
  "github-actions",