pr-checkmate 1.7.0 → 1.8.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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SOURCE_EXTENSIONS = exports.CONFIG_FILE_PATTERNS = exports.IGNORE_PATTERNS = void 0;
3
+ exports.DEFAULT_COMMANDS = exports.SOURCE_EXTENSIONS = exports.CONFIG_FILE_PATTERNS = exports.IGNORE_PATTERNS = void 0;
4
4
  /**
5
5
  * Common patterns to ignore in all checks
6
6
  */
@@ -71,3 +71,10 @@ exports.SOURCE_EXTENSIONS = {
71
71
  json: ['.json'],
72
72
  all: ['.ts', '.tsx', '.js', '.jsx', '.json', '.md', '.mdx'],
73
73
  };
74
+ exports.DEFAULT_COMMANDS = {
75
+ 'npx pr-checkmate all': 'Run all checks',
76
+ 'npx pr-checkmate lint': 'Lint code using ESLint',
77
+ 'npx pr-checkmate prettier': 'Format code using Prettier',
78
+ 'npx pr-checkmate deps': 'Check project dependencies',
79
+ 'npx pr-checkmate spellcheck': 'Run spellcheck via cspell',
80
+ };
package/dist/init.js CHANGED
@@ -8,9 +8,11 @@ exports.init = init;
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const path_1 = __importDefault(require("path"));
10
10
  const inquirer_1 = __importDefault(require("inquirer"));
11
+ const config_1 = require("./config");
11
12
  const utils_1 = require("./utils");
12
13
  exports.CONFIG_FILE = path_1.default.resolve(process.cwd(), 'pr-checkmate.json');
13
14
  async function init() {
15
+ const root = process.cwd();
14
16
  if (!fs_1.default.existsSync(exports.CONFIG_FILE)) {
15
17
  const answers = await inquirer_1.default.prompt([
16
18
  {
@@ -23,15 +25,18 @@ async function init() {
23
25
  type: 'input',
24
26
  name: 'manualPath',
25
27
  message: 'Enter path:',
26
- when: a => a.sourcePath === 'Enter manually',
27
- validate: input => input.trim().length > 0 || 'Cannot be empty',
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ when: (a) => a.sourcePath === 'Enter manually',
30
+ validate: (input) => input.trim().length > 0 || 'Cannot be empty',
28
31
  },
29
32
  ]);
30
33
  const sourcePath = answers.sourcePath === 'Enter manually' ? answers.manualPath : answers.sourcePath;
31
- const config = { sourcePath };
34
+ const config = {
35
+ sourcePath,
36
+ commands: config_1.DEFAULT_COMMANDS,
37
+ };
32
38
  fs_1.default.writeFileSync(exports.CONFIG_FILE, JSON.stringify(config, null, 2));
33
- utils_1.logger.info(`✅ Created pr-checkmate.json with sourcePath: ${sourcePath}`);
34
- const root = process.cwd();
39
+ utils_1.logger.info(`[init]: Created pr-checkmate.json with sourcePath: ${sourcePath}`);
35
40
  const tsconfigPath = path_1.default.join(root, 'tsconfig.json');
36
41
  if (!fs_1.default.existsSync(tsconfigPath)) {
37
42
  const newTsConfig = {
@@ -52,10 +57,23 @@ async function init() {
52
57
  exclude: ['node_modules', 'dist'],
53
58
  };
54
59
  fs_1.default.writeFileSync(tsconfigPath, JSON.stringify(newTsConfig, null, 2));
55
- utils_1.logger.info('✅ Created tsconfig.json using your sourcePath');
60
+ utils_1.logger.info('[init]: ✅ Created tsconfig.json using your sourcePath');
56
61
  }
57
62
  }
58
63
  else {
59
- utils_1.logger.info('⚡ pr-checkmate.json already exists.');
64
+ utils_1.logger.info('⚡ pr-checkmate.json already exists — updating it.');
65
+ try {
66
+ const raw = fs_1.default.readFileSync(exports.CONFIG_FILE, 'utf-8');
67
+ const json = JSON.parse(raw);
68
+ if (!json.commands) {
69
+ json.commands = config_1.DEFAULT_COMMANDS;
70
+ }
71
+ fs_1.default.writeFileSync(exports.CONFIG_FILE, JSON.stringify(json, null, 2));
72
+ utils_1.logger.info('[init]: 🔧 Updated pr-checkmate.json with jobs + commands.');
73
+ }
74
+ catch (e) {
75
+ utils_1.logger.error(`[init]: ❌ Failed to update existing pr-checkmate.json
76
+ config: ${JSON.stringify(exports.CONFIG_FILE)}\n${e}`);
77
+ }
60
78
  }
61
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pr-checkmate",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Automated PR quality checks: linting, formatting, dependency analysis, and spellcheck",
5
5
  "keywords": [
6
6
  "github-actions",