pr-checkmate 1.0.9 → 1.0.11

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
@@ -41,9 +41,6 @@ npx pr-checkmate <job>
41
41
 
42
42
  ## 📦 Example GitHub Actions Workflow
43
43
 
44
- ![pipeline](./assets/pipelineex.png)
45
-
46
-
47
44
  ```yaml
48
45
  name: PR CheckMate Quality Checks
49
46
 
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- const index_1 = require("./scripts/index");
4
+ const scripts_1 = require("./scripts");
5
5
  const init_1 = require("./init");
6
6
  const utils_1 = require("./utils");
7
7
  const cmd = process.argv[2];
@@ -11,7 +11,7 @@ void (async () => {
11
11
  await (0, init_1.init)();
12
12
  process.exit(0);
13
13
  }
14
- await (0, index_1.runJob)(cmd ?? 'all');
14
+ await (0, scripts_1.runJob)(cmd ?? 'all');
15
15
  process.exit(0);
16
16
  }
17
17
  catch (err) {
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SOURCE_EXTENSIONS = exports.IGNORE_PATTERNS = void 0;
4
+ /**
5
+ * Common patterns to ignore in all checks
6
+ */
7
+ exports.IGNORE_PATTERNS = [
8
+ '**/node_modules/**',
9
+ '**/dist/**',
10
+ '**/.git/**',
11
+ '**/build/**',
12
+ '**/coverage/**',
13
+ '**/.next/**',
14
+ '**/.nuxt/**',
15
+ '**/out/**',
16
+ '**/__pycache__/**',
17
+ '**/.pytest_cache/**',
18
+ '**/.venv/**',
19
+ '**/venv/**',
20
+ ];
21
+ /**
22
+ * File extensions to check
23
+ */
24
+ exports.SOURCE_EXTENSIONS = {
25
+ typescript: ['.ts', '.tsx'],
26
+ javascript: ['.js', '.jsx'],
27
+ markdown: ['.md', '.mdx'],
28
+ json: ['.json'],
29
+ all: ['.ts', '.tsx', '.js', '.jsx', '.json', '.md', '.mdx'],
30
+ };
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.SOURCE_PATH = exports.config = exports.CONFIG_FILE = void 0;
21
+ exports.getPackageConfigPath = getPackageConfigPath;
22
+ exports.hasLocalConfig = hasLocalConfig;
23
+ const node_fs_1 = __importDefault(require("node:fs"));
24
+ const node_path_1 = __importDefault(require("node:path"));
25
+ __exportStar(require("./config"), exports);
26
+ __exportStar(require("./constants"), exports);
27
+ exports.CONFIG_FILE = node_path_1.default.resolve(process.cwd(), 'pr-checkmate.json');
28
+ exports.config = node_fs_1.default.existsSync(exports.CONFIG_FILE)
29
+ ? JSON.parse(node_fs_1.default.readFileSync(exports.CONFIG_FILE, 'utf-8'))
30
+ : { sourcePath: 'src' };
31
+ exports.SOURCE_PATH = exports.config.sourcePath;
32
+ /**
33
+ * Get path to package config files
34
+ */
35
+ function getPackageConfigPath(fileName) {
36
+ const packageRoot = node_path_1.default.resolve(__dirname, '../..');
37
+ return node_path_1.default.join(packageRoot, fileName);
38
+ }
39
+ /**
40
+ * Check if project has local config
41
+ */
42
+ function hasLocalConfig(configNames) {
43
+ const projectRoot = process.cwd();
44
+ return configNames.some(name => node_fs_1.default.existsSync(node_path_1.default.join(projectRoot, name)));
45
+ }
@@ -0,0 +1,36 @@
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.copyConfigs = copyConfigs;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ const utils_1 = require("../utils");
10
+ const configFiles = [
11
+ { source: 'src/config/eslint.config.mjs', dest: 'eslint.config.mjs' },
12
+ { source: 'src/config/.prettierrc', dest: '.prettierrc' },
13
+ { source: 'src/config/cspell.json', dest: 'cspell.json' },
14
+ ];
15
+ /**
16
+ * Copy configuration files to package root (NOT dist!)
17
+ */
18
+ function copyConfigs() {
19
+ const projectRoot = node_path_1.default.resolve(__dirname, '..', '..'); // package root
20
+ utils_1.logger.log('📦 Copying configuration files to package root...\n');
21
+ configFiles.forEach(({ source, dest }) => {
22
+ const srcPath = node_path_1.default.join(projectRoot, source);
23
+ const destPath = node_path_1.default.join(projectRoot, dest);
24
+ if (node_fs_1.default.existsSync(srcPath)) {
25
+ node_fs_1.default.copyFileSync(srcPath, destPath);
26
+ utils_1.logger.log(`✅ Copied ${dest}`);
27
+ }
28
+ else {
29
+ utils_1.logger.warn(`⚠️ File not found: ${source}`);
30
+ }
31
+ });
32
+ utils_1.logger.info('\n✨ Config files copied to package root!\n');
33
+ }
34
+ if (require.main === module) {
35
+ copyConfigs();
36
+ }
@@ -15,16 +15,24 @@ const node_fs_1 = __importDefault(require("node:fs"));
15
15
  * @throws Will throw an error if deeper checks are added and fail.
16
16
  */
17
17
  async function runDependencyCheck() {
18
- utils_1.logger.info('Checking dependencies...');
19
- const packageJsonPath = node_path_1.default.resolve(process.cwd(), 'package.json');
18
+ utils_1.logger.info('📦 Checking dependencies...');
19
+ const projectRoot = process.cwd();
20
+ const packageJsonPath = node_path_1.default.join(projectRoot, 'package.json');
20
21
  if (!node_fs_1.default.existsSync(packageJsonPath)) {
21
- utils_1.logger.warn('No package.json — skipping dependency check');
22
+ utils_1.logger.warn('⚠️ No package.json — skipping dependency check');
22
23
  return;
23
24
  }
24
- const sourceFolder = node_path_1.default.resolve(process.cwd(), config_1.SOURCE_PATH);
25
+ const sourceFolder = node_path_1.default.join(projectRoot, config_1.SOURCE_PATH);
25
26
  if (!node_fs_1.default.existsSync(sourceFolder)) {
26
- utils_1.logger.warn(`Source folder "${config_1.SOURCE_PATH}" not found — skipping deeper checks`);
27
+ utils_1.logger.warn(`⚠️ Source folder "${config_1.SOURCE_PATH}" not found — skipping deeper checks`);
27
28
  return;
28
29
  }
30
+ const ignoredInSource = config_1.IGNORE_PATTERNS.some(pattern => {
31
+ const cleanPattern = pattern.replace(/\*\*/g, '').replace(/\//g, '');
32
+ return sourceFolder.includes(cleanPattern);
33
+ });
34
+ if (ignoredInSource) {
35
+ utils_1.logger.warn('⚠️ Source path contains ignored directories');
36
+ }
29
37
  utils_1.logger.info('✅ Dependencies OK');
30
38
  }
@@ -1,4 +1,18 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.runJob = runJob;
4
18
  const dependency_check_1 = require("./dependency-check");
@@ -6,6 +20,10 @@ const prettier_autoformat_1 = require("./prettier-autoformat");
6
20
  const spellcheck_1 = require("./spellcheck");
7
21
  const utils_1 = require("../utils");
8
22
  const lint_1 = require("./lint");
23
+ __exportStar(require("./dependency-check"), exports);
24
+ __exportStar(require("./lint"), exports);
25
+ __exportStar(require("./prettier-autoformat"), exports);
26
+ __exportStar(require("./spellcheck"), exports);
9
27
  async function runJob(jobName) {
10
28
  utils_1.logger.info(`🚀 Running job: ${jobName}`);
11
29
  try {
@@ -1,37 +1,55 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.runLint = runLint;
7
- const execa_1 = require("execa");
8
- const node_path_1 = __importDefault(require("node:path"));
4
+ const config_1 = require("../config");
9
5
  const utils_1 = require("../utils");
10
- const INTERNAL_ESLINT_CONFIG = node_path_1.default.resolve(__dirname, '../eslint.config.mjs');
6
+ const execa_1 = require("execa");
11
7
  /**
12
- * Run ESLint using the internal config.
13
- * Ignores node_modules, dist, and .git automatically.
8
+ * Run ESLint on the project.
9
+ * Uses local ESLint configuration if available; otherwise uses packaged config.
14
10
  */
15
11
  async function runLint() {
16
- utils_1.logger.info('Running ESLint...');
17
- const projectPath = node_path_1.default.resolve(process.cwd());
18
- const ignorePatterns = ['**/node_modules/**', '**/dist/**', '**/.git/**'];
19
- const args = [
20
- 'eslint',
21
- projectPath,
22
- '--ext',
23
- '.ts,.tsx',
24
- '--fix',
25
- '--config',
26
- INTERNAL_ESLINT_CONFIG,
27
- ...ignorePatterns.flatMap(p => ['--ignore-pattern', p]),
28
- ];
12
+ utils_1.logger.info('🔍 Running ESLint...');
13
+ const projectRoot = process.cwd();
14
+ const hasLocal = (0, config_1.hasLocalConfig)([
15
+ 'eslint.config.mjs',
16
+ 'eslint.config.js',
17
+ '.eslintrc.js',
18
+ '.eslintrc.json',
19
+ '.eslintrc',
20
+ ]);
21
+ let args;
22
+ if (hasLocal) {
23
+ utils_1.logger.info('📋 Using local ESLint config');
24
+ args = [
25
+ 'eslint',
26
+ projectRoot,
27
+ '--ext',
28
+ '.ts,.tsx,.js,.jsx',
29
+ '--fix',
30
+ ...config_1.IGNORE_PATTERNS.flatMap(pattern => ['--ignore-pattern', pattern]),
31
+ ];
32
+ }
33
+ else {
34
+ utils_1.logger.info('📦 Using pr-checkmate ESLint config');
35
+ const configPath = (0, config_1.getPackageConfigPath)('eslint.config.mjs');
36
+ args = [
37
+ 'eslint',
38
+ projectRoot,
39
+ '--ext',
40
+ '.ts,.tsx,.js,.jsx',
41
+ '--fix',
42
+ '--config',
43
+ configPath,
44
+ ...config_1.IGNORE_PATTERNS.flatMap(pattern => ['--ignore-pattern', pattern]),
45
+ ];
46
+ }
29
47
  try {
30
48
  await (0, execa_1.execa)('npx', args, { stdio: 'inherit' });
31
49
  utils_1.logger.info('✅ ESLint passed');
32
50
  }
33
51
  catch (err) {
34
- utils_1.logger.warn('⚠️ ESLint issues found');
52
+ utils_1.logger.warn('⚠️ ESLint found issues');
35
53
  throw err;
36
54
  }
37
55
  }
@@ -4,27 +4,80 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.runPrettier = runPrettier;
7
- // src/scripts/prettier-autoformat.ts
7
+ const config_1 = require("../config");
8
+ const utils_1 = require("../utils");
8
9
  const execa_1 = require("execa");
9
10
  const node_path_1 = __importDefault(require("node:path"));
10
- const utils_1 = require("../utils");
11
- const INTERNAL_PRETTIER_CONFIG = node_path_1.default.resolve(__dirname, '../.prettierrc');
11
+ const node_fs_1 = __importDefault(require("node:fs"));
12
+ /**
13
+ * Create temporary .prettierignore file with ignore patterns
14
+ */
15
+ function createTempIgnoreFile() {
16
+ const tempIgnoreFile = node_path_1.default.join(process.cwd(), '.prettierignore.temp');
17
+ const ignoreContent = config_1.IGNORE_PATTERNS.join('\n');
18
+ node_fs_1.default.writeFileSync(tempIgnoreFile, ignoreContent, 'utf-8');
19
+ return tempIgnoreFile;
20
+ }
12
21
  /**
13
- * Run Prettier using internal config.
14
- * Ignores node_modules, dist, and .git automatically.
22
+ * Remove temporary ignore file
15
23
  */
24
+ function cleanupTempIgnoreFile(filePath) {
25
+ try {
26
+ if (node_fs_1.default.existsSync(filePath)) {
27
+ node_fs_1.default.unlinkSync(filePath);
28
+ }
29
+ }
30
+ catch (err) {
31
+ utils_1.logger.warn(`⚠️ Failed to cleanup temp file: ${filePath}`);
32
+ }
33
+ }
16
34
  async function runPrettier() {
17
- utils_1.logger.info('Running Prettier...');
18
- const projectPath = node_path_1.default.resolve(process.cwd());
19
- const ignorePatterns = ['**/node_modules/**', '**/dist/**', '**/.git/**'];
20
- const args = [
21
- 'prettier',
22
- '--write',
23
- projectPath,
24
- '--config',
25
- INTERNAL_PRETTIER_CONFIG,
26
- ...ignorePatterns.flatMap(p => ['--ignore-path', p]),
27
- ];
35
+ utils_1.logger.info('🎨 Running Prettier...');
36
+ const projectRoot = process.cwd();
37
+ const projectIgnore = node_path_1.default.join(projectRoot, '.prettierignore');
38
+ const gitignore = node_path_1.default.join(projectRoot, '.gitignore');
39
+ const hasLocal = (0, config_1.hasLocalConfig)([
40
+ '.prettierrc',
41
+ '.prettierrc.json',
42
+ '.prettierrc.js',
43
+ 'prettier.config.js',
44
+ ]);
45
+ let tempIgnoreFile = null;
46
+ let ignorePath;
47
+ if (node_fs_1.default.existsSync(projectIgnore)) {
48
+ ignorePath = projectIgnore;
49
+ }
50
+ else if (node_fs_1.default.existsSync(gitignore)) {
51
+ ignorePath = gitignore;
52
+ }
53
+ else {
54
+ tempIgnoreFile = createTempIgnoreFile();
55
+ ignorePath = tempIgnoreFile;
56
+ }
57
+ let args;
58
+ if (hasLocal) {
59
+ utils_1.logger.info('📋 Using local Prettier config');
60
+ args = [
61
+ 'prettier',
62
+ '--write',
63
+ `${projectRoot}/**/*.{ts,tsx,js,jsx,json,md}`,
64
+ '--ignore-path',
65
+ ignorePath,
66
+ ];
67
+ }
68
+ else {
69
+ utils_1.logger.info('📦 Using pr-checkmate Prettier config');
70
+ const configPath = (0, config_1.getPackageConfigPath)('.prettierrc');
71
+ args = [
72
+ 'prettier',
73
+ '--write',
74
+ `${projectRoot}/**/*.{ts,tsx,js,jsx,json,md}`,
75
+ '--config',
76
+ configPath,
77
+ '--ignore-path',
78
+ ignorePath,
79
+ ];
80
+ }
28
81
  try {
29
82
  await (0, execa_1.execa)('npx', args, { stdio: 'inherit' });
30
83
  utils_1.logger.info('✅ Prettier completed');
@@ -33,4 +86,9 @@ async function runPrettier() {
33
86
  utils_1.logger.error('❌ Prettier failed');
34
87
  throw err;
35
88
  }
89
+ finally {
90
+ if (tempIgnoreFile) {
91
+ cleanupTempIgnoreFile(tempIgnoreFile);
92
+ }
93
+ }
36
94
  }
@@ -4,26 +4,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.runSpellcheck = runSpellcheck;
7
- // src/scripts/spellcheck.ts
8
7
  const execa_1 = require("execa");
9
8
  const node_path_1 = __importDefault(require("node:path"));
10
9
  const utils_1 = require("../utils");
11
- const INTERNAL_CSPELL_CONFIG = node_path_1.default.resolve(__dirname, '../cspell.json');
10
+ const config_1 = require("../config");
12
11
  /**
13
- * Run spellcheck using internal cspell config.
14
- * Ignores node_modules, dist, and .git automatically.
12
+ * Build glob patterns for spellcheck with ignore patterns
15
13
  */
14
+ function buildSpellcheckPatterns(projectRoot, sourcePath) {
15
+ const basePattern = node_path_1.default.join(projectRoot, sourcePath, '**/*.{ts,tsx,js,jsx,md,mdx,json}');
16
+ // create ignore glob flags: --exclude "**/node_modules/**"
17
+ const excludeArgs = config_1.IGNORE_PATTERNS.map(p => `--exclude=${p}`);
18
+ return [basePattern, ...excludeArgs];
19
+ }
16
20
  async function runSpellcheck() {
17
- utils_1.logger.info('Running spellcheck...');
18
- const projectPath = node_path_1.default.resolve(process.cwd());
19
- const ignorePatterns = ['**/node_modules/**', '**/dist/**', '**/.git/**'];
20
- const args = [
21
- 'cspell',
22
- projectPath,
23
- '--config',
24
- INTERNAL_CSPELL_CONFIG,
25
- ...ignorePatterns.flatMap(p => ['--exclude', p]),
26
- ];
21
+ utils_1.logger.info('🔤 Running spellcheck...');
22
+ const projectRoot = process.cwd();
23
+ const patterns = buildSpellcheckPatterns(projectRoot, config_1.SOURCE_PATH);
24
+ const hasLocal = (0, config_1.hasLocalConfig)(['cspell.json', '.cspell.json', 'cspell.config.json']);
25
+ let args;
26
+ if (hasLocal) {
27
+ utils_1.logger.info('📋 Using local cspell config');
28
+ args = ['cspell', ...patterns, '--no-progress'];
29
+ }
30
+ else {
31
+ utils_1.logger.info('📦 Using pr-checkmate cspell config');
32
+ const configPath = (0, config_1.getPackageConfigPath)('cspell.json');
33
+ args = ['cspell', ...patterns, '--config', configPath, '--no-progress'];
34
+ }
27
35
  try {
28
36
  await (0, execa_1.execa)('npx', args, { stdio: 'inherit' });
29
37
  utils_1.logger.info('✅ Spellcheck passed');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pr-checkmate",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Automated PR quality checks: linting, formatting, dependency analysis, and spellcheck",
5
5
  "keywords": [
6
6
  "github-actions",
@@ -19,11 +19,13 @@
19
19
  "files": [
20
20
  "dist",
21
21
  "README.md",
22
+ "scripts/copy-configs.js",
22
23
  "LICENSE"
23
24
  ],
24
25
  "scripts": {
25
26
  "check": "npm run build && npm run lint && npm run prettier && npm run spellcheck",
26
- "build": "npm run clean && tsc && chmod +x dist/cli.js",
27
+ "build": "npm run clean && tsc && npm run copy-configs && chmod +x dist/cli.js",
28
+ "copy-configs": "node dist/scripts/copy-configs.js",
27
29
  "prepublishOnly": "npm run build",
28
30
  "lint": "eslint \"src/**/*.{ts,tsx}\" --fix",
29
31
  "prettier": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
File without changes