pr-checkmate 1.0.3 → 1.0.5

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 CHANGED
@@ -1,17 +1,21 @@
1
1
  #!/usr/bin/env node
2
- import { runJob } from './scripts/index.js';
3
- import { init } from './init.js';
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const index_1 = require("./scripts/index");
5
+ const init_1 = require("./init");
6
+ const utils_1 = require("./utils");
4
7
  const cmd = process.argv[2];
5
- (async () => {
8
+ void (async () => {
6
9
  try {
7
10
  if (cmd === 'init') {
8
- await init();
11
+ await (0, init_1.init)();
9
12
  process.exit(0);
10
13
  }
11
- await runJob(cmd || 'all');
14
+ await (0, index_1.runJob)(cmd ?? 'all');
15
+ process.exit(0);
12
16
  }
13
17
  catch (err) {
14
- console.error('❌ CLI failed:', err);
18
+ utils_1.logger.error(`❌ CLI failed: ${err}`);
15
19
  process.exit(1);
16
20
  }
17
21
  })();
package/dist/config.js CHANGED
@@ -1,7 +1,13 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- export const CONFIG_FILE = path.resolve(process.cwd(), 'pr-checkmate.json');
4
- export const config = fs.existsSync(CONFIG_FILE)
5
- ? JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf-8'))
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.SOURCE_PATH = exports.config = exports.CONFIG_FILE = void 0;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ exports.CONFIG_FILE = node_path_1.default.resolve(process.cwd(), 'pr-checkmate.json');
10
+ exports.config = node_fs_1.default.existsSync(exports.CONFIG_FILE)
11
+ ? JSON.parse(node_fs_1.default.readFileSync(exports.CONFIG_FILE, 'utf-8'))
6
12
  : { sourcePath: 'src' };
7
- export const SOURCE_PATH = config.sourcePath;
13
+ exports.SOURCE_PATH = exports.config.sourcePath;
package/dist/index.js CHANGED
@@ -1,22 +1,65 @@
1
+ "use strict";
1
2
  /**
2
3
  * PR CheckMate - Automated PR quality checks
3
4
  *
4
5
  * @module pr-checkmate
5
6
  */
6
- export { runLint } from './scripts/lint';
7
- export { runDependencyCheck } from './scripts/dependency-check';
8
- export { runPrettier } from './scripts/prettier-autoformat';
9
- export { runSpellcheck } from './scripts/spellcheck';
10
- export { logger } from './utils';
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.logger = exports.runSpellcheck = exports.runPrettier = exports.runDependencyCheck = exports.runLint = void 0;
42
+ exports.runAllChecks = runAllChecks;
43
+ exports.runChecks = runChecks;
44
+ var lint_1 = require("./scripts/lint");
45
+ Object.defineProperty(exports, "runLint", { enumerable: true, get: function () { return lint_1.runLint; } });
46
+ var dependency_check_1 = require("./scripts/dependency-check");
47
+ Object.defineProperty(exports, "runDependencyCheck", { enumerable: true, get: function () { return dependency_check_1.runDependencyCheck; } });
48
+ var prettier_autoformat_1 = require("./scripts/prettier-autoformat");
49
+ Object.defineProperty(exports, "runPrettier", { enumerable: true, get: function () { return prettier_autoformat_1.runPrettier; } });
50
+ var spellcheck_1 = require("./scripts/spellcheck");
51
+ Object.defineProperty(exports, "runSpellcheck", { enumerable: true, get: function () { return spellcheck_1.runSpellcheck; } });
52
+ var utils_1 = require("./utils");
53
+ Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return utils_1.logger; } });
11
54
  /**
12
55
  * Run all checks sequentially
13
56
  * @returns Promise that resolves when all checks complete
14
57
  */
15
- export async function runAllChecks() {
16
- const { runLint } = await import('./scripts/lint');
17
- const { runDependencyCheck } = await import('./scripts/dependency-check');
18
- const { runPrettier } = await import('./scripts/prettier-autoformat');
19
- const { runSpellcheck } = await import('./scripts/spellcheck');
58
+ async function runAllChecks() {
59
+ const { runLint } = await Promise.resolve().then(() => __importStar(require('./scripts/lint')));
60
+ const { runDependencyCheck } = await Promise.resolve().then(() => __importStar(require('./scripts/dependency-check')));
61
+ const { runPrettier } = await Promise.resolve().then(() => __importStar(require('./scripts/prettier-autoformat')));
62
+ const { runSpellcheck } = await Promise.resolve().then(() => __importStar(require('./scripts/spellcheck')));
20
63
  await runLint();
21
64
  await runDependencyCheck();
22
65
  await runSpellcheck();
@@ -25,11 +68,11 @@ export async function runAllChecks() {
25
68
  /**
26
69
  * Run checks based on configuration
27
70
  */
28
- export async function runChecks(config = {}) {
29
- const { runLint } = await import('./scripts/lint');
30
- const { runDependencyCheck } = await import('./scripts/dependency-check');
31
- const { runPrettier } = await import('./scripts/prettier-autoformat');
32
- const { runSpellcheck } = await import('./scripts/spellcheck');
71
+ async function runChecks(config = {}) {
72
+ const { runLint } = await Promise.resolve().then(() => __importStar(require('./scripts/lint')));
73
+ const { runDependencyCheck } = await Promise.resolve().then(() => __importStar(require('./scripts/dependency-check')));
74
+ const { runPrettier } = await Promise.resolve().then(() => __importStar(require('./scripts/prettier-autoformat')));
75
+ const { runSpellcheck } = await Promise.resolve().then(() => __importStar(require('./scripts/spellcheck')));
33
76
  if (!config.skipLint)
34
77
  await runLint();
35
78
  if (!config.skipDeps)
package/dist/init.js CHANGED
@@ -1,14 +1,24 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import inquirer from 'inquirer';
4
- import { logger } from './utils';
5
- export const CONFIG_FILE = path.resolve(process.cwd(), 'pr-checkmate.json');
6
- export async function init() {
7
- if (fs.existsSync(CONFIG_FILE)) {
8
- logger.info('⚡ pr-checkmate.json already exists.');
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.CONFIG_FILE = void 0;
7
+ exports.init = init;
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const inquirer_1 = __importDefault(require("inquirer"));
11
+ const utils_1 = require("./utils");
12
+ exports.CONFIG_FILE = path_1.default.resolve(process.cwd(), 'pr-checkmate.json');
13
+ /**
14
+ * Initialize pr-checkmate configuration file.
15
+ */
16
+ async function init() {
17
+ if (fs_1.default.existsSync(exports.CONFIG_FILE)) {
18
+ utils_1.logger.info('⚡ pr-checkmate.json already exists.');
9
19
  return;
10
20
  }
11
- const answers = await inquirer.prompt([
21
+ const answers = await inquirer_1.default.prompt([
12
22
  {
13
23
  type: 'list',
14
24
  name: 'sourcePath',
@@ -19,13 +29,13 @@ export async function init() {
19
29
  type: 'input',
20
30
  name: 'manualPath',
21
31
  message: 'Enter path:',
22
- when: a => a.sourcePath === 'Enter manually',
23
- validate: input => input.trim().length > 0 || 'Cannot be empty',
32
+ when: (a) => a.sourcePath === 'Enter manually',
33
+ validate: (input) => input.trim().length > 0 || 'Cannot be empty',
24
34
  },
25
35
  ]);
26
36
  const config = {
27
37
  sourcePath: answers.sourcePath === 'Enter manually' ? answers.manualPath : answers.sourcePath,
28
38
  };
29
- fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
30
- logger.info('✅ Created checkmatec.json');
39
+ fs_1.default.writeFileSync(exports.CONFIG_FILE, JSON.stringify(config, null, 2));
40
+ utils_1.logger.info('✅ Created pr-checkmate.json');
31
41
  }
@@ -1,24 +1,30 @@
1
- import { logger } from '../utils';
2
- import fs from 'node:fs';
3
- import path from 'node:path';
4
- import { SOURCE_PATH } from '../config';
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.runDependencyCheck = runDependencyCheck;
7
+ const config_1 = require("../config");
8
+ const utils_1 = require("../utils");
9
+ const node_path_1 = __importDefault(require("node:path"));
10
+ const node_fs_1 = __importDefault(require("node:fs"));
5
11
  /**
6
12
  * Check for the presence of package.json and source folder.
7
13
  * Currently, only validates existence; can be extended for dependency checks.
8
14
  *
9
15
  * @throws Will throw an error if deeper checks are added and fail.
10
16
  */
11
- export async function runDependencyCheck() {
12
- logger.info('Checking dependencies...');
13
- const packageJsonPath = path.resolve(process.cwd(), 'package.json');
14
- if (!fs.existsSync(packageJsonPath)) {
15
- logger.warn('No package.json — skipping dependency check');
17
+ async function runDependencyCheck() {
18
+ utils_1.logger.info('Checking dependencies...');
19
+ const packageJsonPath = node_path_1.default.resolve(process.cwd(), 'package.json');
20
+ if (!node_fs_1.default.existsSync(packageJsonPath)) {
21
+ utils_1.logger.warn('No package.json — skipping dependency check');
16
22
  return;
17
23
  }
18
- const sourceFolder = path.resolve(process.cwd(), SOURCE_PATH);
19
- if (!fs.existsSync(sourceFolder)) {
20
- logger.warn(`Source folder "${SOURCE_PATH}" not found — skipping deeper checks`);
24
+ const sourceFolder = node_path_1.default.resolve(process.cwd(), config_1.SOURCE_PATH);
25
+ if (!node_fs_1.default.existsSync(sourceFolder)) {
26
+ utils_1.logger.warn(`Source folder "${config_1.SOURCE_PATH}" not found — skipping deeper checks`);
21
27
  return;
22
28
  }
23
- logger.info('Dependencies OK');
29
+ utils_1.logger.info('Dependencies OK');
24
30
  }
@@ -1,8 +1,11 @@
1
- import { runLint } from './lint';
2
- import { runDependencyCheck } from './dependency-check';
3
- import { runPrettier } from './prettier-autoformat';
4
- import { runSpellcheck } from './spellcheck';
5
- import { logger } from '../utils';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runJob = runJob;
4
+ const dependency_check_1 = require("./dependency-check");
5
+ const prettier_autoformat_1 = require("./prettier-autoformat");
6
+ const spellcheck_1 = require("./spellcheck");
7
+ const utils_1 = require("../utils");
8
+ const lint_1 = require("./lint");
6
9
  /**
7
10
  * CLI entry point for PR CheckMate.
8
11
  *
@@ -16,32 +19,27 @@ import { logger } from '../utils';
16
19
  * prettier - Run Prettier auto-format
17
20
  * spellcheck - Run cspell spellcheck
18
21
  */
19
- const job = process.argv[2];
20
- export async function runJob(jobName) {
22
+ async function runJob(jobName) {
21
23
  switch (jobName) {
22
24
  case 'all':
23
- await runLint();
24
- await runDependencyCheck();
25
- await runPrettier();
26
- await runSpellcheck();
25
+ await (0, lint_1.runLint)();
26
+ await (0, dependency_check_1.runDependencyCheck)();
27
+ await (0, prettier_autoformat_1.runPrettier)();
28
+ await (0, spellcheck_1.runSpellcheck)();
27
29
  break;
28
30
  case 'lint':
29
- await runLint();
31
+ await (0, lint_1.runLint)();
30
32
  break;
31
33
  case 'deps':
32
- await runDependencyCheck();
34
+ await (0, dependency_check_1.runDependencyCheck)();
33
35
  break;
34
36
  case 'prettier':
35
- await runPrettier();
37
+ await (0, prettier_autoformat_1.runPrettier)();
36
38
  break;
37
39
  case 'spellcheck':
38
- await runSpellcheck();
40
+ await (0, spellcheck_1.runSpellcheck)();
39
41
  break;
40
42
  default:
41
- logger.log('[runJob]: Available jobs: lint, deps, prettier, spellcheck');
43
+ utils_1.logger.log('[runJob]: Available jobs: lint, deps, prettier, spellcheck');
42
44
  }
43
45
  }
44
- runJob(job).catch(err => {
45
- const message = err instanceof Error ? err.message : String(err);
46
- throw new Error(`[runJob]: ❌ CLI execution failed: ${message}`);
47
- });
@@ -1,27 +1,33 @@
1
- import { execa } from 'execa';
2
- import { logger } from '../utils';
3
- import { SOURCE_PATH } from '../config';
4
- import fs from 'node:fs';
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.runLint = runLint;
7
+ const execa_1 = require("execa");
8
+ const node_fs_1 = __importDefault(require("node:fs"));
9
+ const config_1 = require("../config");
10
+ const utils_1 = require("../utils");
5
11
  /**
6
12
  * Run ESLint on the project.
7
13
  * Uses local ESLint configuration if available; otherwise defaults to SOURCE_PATH.
8
14
  *
9
15
  * @throws Will throw an error if ESLint detects issues that cannot be fixed automatically.
10
16
  */
11
- export async function runLint() {
12
- logger.info('Running ESLint...');
13
- const hasLocalConfig = fs.existsSync('eslint.config.mjs') ||
14
- fs.existsSync('.eslintrc.js') ||
15
- fs.existsSync('.eslintrc.json');
17
+ async function runLint() {
18
+ utils_1.logger.info('Running ESLint...');
19
+ const hasLocalConfig = node_fs_1.default.existsSync('eslint.config.mjs') ||
20
+ node_fs_1.default.existsSync('.eslintrc.js') ||
21
+ node_fs_1.default.existsSync('.eslintrc.json');
16
22
  const args = hasLocalConfig
17
23
  ? ['eslint', '.', '--ext', '.ts,.tsx', '--fix']
18
- : ['eslint', SOURCE_PATH, '--ext', '.ts,.tsx', '--fix'];
24
+ : ['eslint', config_1.SOURCE_PATH, '--ext', '.ts,.tsx', '--fix'];
19
25
  try {
20
- await execa('npx', args, { stdio: 'inherit' });
21
- logger.info('ESLint passed');
26
+ await (0, execa_1.execa)('npx', args, { stdio: 'inherit' });
27
+ utils_1.logger.info('ESLint passed');
22
28
  }
23
29
  catch (err) {
24
- logger.warn('ESLint issues found');
30
+ utils_1.logger.warn('ESLint issues found');
25
31
  throw err;
26
32
  }
27
33
  }
@@ -1,27 +1,33 @@
1
- import { execa } from 'execa';
2
- import { logger } from '../utils';
3
- import fs from 'node:fs';
4
- import { SOURCE_PATH } from '../config';
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.runPrettier = runPrettier;
7
+ const execa_1 = require("execa");
8
+ const node_fs_1 = __importDefault(require("node:fs"));
9
+ const config_1 = require("../config");
10
+ const utils_1 = require("../utils");
5
11
  /**
6
12
  * Run Prettier to auto-format project files.
7
13
  * If a Prettier config file exists, it runs on the whole project; otherwise on SOURCE_PATH.
8
14
  *
9
15
  * @throws Will throw an error if Prettier fails.
10
16
  */
11
- export async function runPrettier() {
12
- logger.info('Running Prettier...');
13
- const hasConfig = fs.existsSync('.prettierrc') ||
14
- fs.existsSync('.prettierrc.json') ||
15
- fs.existsSync('prettier.config.js');
16
- const pattern = hasConfig ? '.' : SOURCE_PATH;
17
+ async function runPrettier() {
18
+ utils_1.logger.info('Running Prettier...');
19
+ const hasConfig = node_fs_1.default.existsSync('.prettierrc') ||
20
+ node_fs_1.default.existsSync('.prettierrc.json') ||
21
+ node_fs_1.default.existsSync('prettier.config.js');
22
+ const pattern = hasConfig ? '.' : config_1.SOURCE_PATH;
17
23
  try {
18
- await execa('npx', ['prettier', '--write', `${pattern}/**/*`], {
24
+ await (0, execa_1.execa)('npx', ['prettier', '--write', `${pattern}/**/*`], {
19
25
  stdio: 'inherit',
20
26
  });
21
- logger.info('Prettier completed');
27
+ utils_1.logger.info('Prettier completed');
22
28
  }
23
29
  catch (err) {
24
- logger.error('Prettier failed');
30
+ utils_1.logger.error('Prettier failed');
25
31
  throw err;
26
32
  }
27
33
  }
@@ -1,21 +1,24 @@
1
- import { execa } from 'execa';
2
- import { logger } from '../utils';
3
- import { SOURCE_PATH } from '../config';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runSpellcheck = runSpellcheck;
4
+ const execa_1 = require("execa");
5
+ const utils_1 = require("../utils");
6
+ const config_1 = require("../config");
4
7
  /**
5
8
  * Run spellcheck using cspell on the project source files.
6
9
  * Only runs on SOURCE_PATH.
7
10
  *
8
11
  * @throws Will throw an error if cspell detects spelling issues.
9
12
  */
10
- export async function runSpellcheck() {
11
- logger.info('Running spellcheck...');
12
- const pattern = `${SOURCE_PATH}/**/*`;
13
+ async function runSpellcheck() {
14
+ utils_1.logger.info('Running spellcheck...');
15
+ const pattern = `${config_1.SOURCE_PATH}/**/*`;
13
16
  try {
14
- await execa('npx', ['cspell', pattern], { stdio: 'inherit' });
15
- logger.info('Spellcheck passed');
17
+ await (0, execa_1.execa)('npx', ['cspell', pattern], { stdio: 'inherit' });
18
+ utils_1.logger.info('Spellcheck passed');
16
19
  }
17
20
  catch (err) {
18
- logger.warn('Spellcheck found issues');
21
+ utils_1.logger.warn('Spellcheck found issues');
19
22
  throw err;
20
23
  }
21
24
  }
@@ -1 +1,17 @@
1
- export * from './logger';
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
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./logger"), exports);
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logger = void 0;
1
4
  class Logger {
2
5
  constructor() {
3
6
  this.logs = [];
@@ -59,4 +62,4 @@ class Logger {
59
62
  this.logs = [];
60
63
  }
61
64
  }
62
- export const logger = new Logger();
65
+ exports.logger = new Logger();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pr-checkmate",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Automated PR quality checks: linting, formatting, dependency analysis, and spellcheck",
5
5
  "keywords": [
6
6
  "github-actions",
@@ -12,7 +12,7 @@
12
12
  "automation"
13
13
  ],
14
14
  "main": "./dist/cli.js",
15
- "types": "dist/index.d.ts",
15
+ "type": "commonjs",
16
16
  "bin": {
17
17
  "pr-checkmate": "./dist/cli.js"
18
18
  },
@@ -23,9 +23,9 @@
23
23
  ],
24
24
  "scripts": {
25
25
  "check": "npm run build && npm run lint && npm run prettier && npm run spellcheck",
26
- "build": "npm run clean && tsc",
26
+ "build": "npm run clean && tsc && chmod +x dist/cli.js",
27
27
  "prepublishOnly": "npm run build",
28
- "lint": "eslint \"src/**/*.{ts,tsx}\"",
28
+ "lint": "eslint \"src/**/*.{ts,tsx}\" --fix",
29
29
  "prettier": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
30
30
  "spellcheck": "cspell '**/*.{ts,tsx,js,jsx,md,json}' --no-progress",
31
31
  "test": "echo 'Tests coming soon'",