pr-checkmate 1.0.8 → 1.0.10
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 +0 -3
- package/dist/.prettierrc +8 -0
- package/dist/cli.js +2 -2
- package/dist/config/constants.js +30 -0
- package/dist/config/index.js +45 -0
- package/dist/cspell.json +35 -0
- package/dist/eslint.config.mjs +73 -0
- package/dist/scripts/copy-configs.js +50 -0
- package/dist/scripts/dependency-check.js +13 -5
- package/dist/scripts/index.js +18 -0
- package/dist/scripts/lint.js +38 -23
- package/dist/scripts/prettier-autoformat.js +75 -17
- package/dist/scripts/spellcheck.js +27 -11
- package/package.json +4 -2
- /package/dist/{config.js → config/config.js} +0 -0
package/README.md
CHANGED
package/dist/.prettierrc
ADDED
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
|
|
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,
|
|
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
|
+
}
|
package/dist/cspell.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2",
|
|
3
|
+
"language": "en",
|
|
4
|
+
"words": [
|
|
5
|
+
"checkmate",
|
|
6
|
+
"eslint",
|
|
7
|
+
"prettier",
|
|
8
|
+
"cspell",
|
|
9
|
+
"typescript",
|
|
10
|
+
"execa",
|
|
11
|
+
"playwright",
|
|
12
|
+
"pytest"
|
|
13
|
+
],
|
|
14
|
+
"ignorePaths": [
|
|
15
|
+
"**/node_modules/**",
|
|
16
|
+
"**/dist/**",
|
|
17
|
+
"**/.git/**",
|
|
18
|
+
"**/build/**",
|
|
19
|
+
"**/coverage/**",
|
|
20
|
+
"**/.next/**",
|
|
21
|
+
"**/.nuxt/**",
|
|
22
|
+
"**/out/**",
|
|
23
|
+
"**/__pycache__/**",
|
|
24
|
+
"**/.pytest_cache/**",
|
|
25
|
+
"**/.venv/**",
|
|
26
|
+
"**/venv/**",
|
|
27
|
+
"**/package-lock.json",
|
|
28
|
+
"**/yarn.lock",
|
|
29
|
+
"**/pnpm-lock.yaml",
|
|
30
|
+
"**/*.min.js",
|
|
31
|
+
"**/*.min.css"
|
|
32
|
+
],
|
|
33
|
+
"enableFiletypes": ["typescript", "javascript", "markdown", "json"],
|
|
34
|
+
"ignoreRegExpList": ["/https?:\\/\\/[^\\s]+/g", "/\\b[0-9a-f]{7,40}\\b/gi"]
|
|
35
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import tsPlugin from '@typescript-eslint/eslint-plugin';
|
|
2
|
+
import tsParser from '@typescript-eslint/parser';
|
|
3
|
+
import prettierPlugin from 'eslint-plugin-prettier';
|
|
4
|
+
|
|
5
|
+
export default [
|
|
6
|
+
{
|
|
7
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
|
|
8
|
+
ignores: [
|
|
9
|
+
'**/node_modules/**',
|
|
10
|
+
'**/dist/**',
|
|
11
|
+
'**/.git/**',
|
|
12
|
+
'**/build/**',
|
|
13
|
+
'**/coverage/**',
|
|
14
|
+
'**/.next/**',
|
|
15
|
+
'**/.nuxt/**',
|
|
16
|
+
'**/out/**',
|
|
17
|
+
],
|
|
18
|
+
languageOptions: {
|
|
19
|
+
parser: tsParser,
|
|
20
|
+
parserOptions: {
|
|
21
|
+
ecmaVersion: 2020,
|
|
22
|
+
sourceType: 'module',
|
|
23
|
+
project: './tsconfig.json',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
plugins: {
|
|
28
|
+
'@typescript-eslint': tsPlugin,
|
|
29
|
+
prettier: prettierPlugin,
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
rules: {
|
|
33
|
+
'no-console': 'warn',
|
|
34
|
+
'no-debugger': 'error',
|
|
35
|
+
'prefer-const': 'error',
|
|
36
|
+
eqeqeq: ['error', 'always'],
|
|
37
|
+
'@typescript-eslint/no-unused-vars': [
|
|
38
|
+
'error',
|
|
39
|
+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
|
|
40
|
+
],
|
|
41
|
+
'@typescript-eslint/explicit-function-return-type': ['warn'],
|
|
42
|
+
'@typescript-eslint/no-explicit-any': ['warn'],
|
|
43
|
+
'@typescript-eslint/no-floating-promises': ['error'],
|
|
44
|
+
'space-before-function-paren': 'off',
|
|
45
|
+
'operator-linebreak': 'off',
|
|
46
|
+
'max-len': ['warn', { code: 100 }],
|
|
47
|
+
|
|
48
|
+
// Formatting / Style Rules
|
|
49
|
+
semi: ['error', 'always'],
|
|
50
|
+
quotes: ['error', 'single', { avoidEscape: true }],
|
|
51
|
+
'object-curly-spacing': ['error', 'always'],
|
|
52
|
+
'space-infix-ops': 'error',
|
|
53
|
+
'keyword-spacing': ['error', { before: true, after: true }],
|
|
54
|
+
'padding-line-between-statements': [
|
|
55
|
+
'error',
|
|
56
|
+
{ blankLine: 'always', prev: 'block', next: '*' },
|
|
57
|
+
{ blankLine: 'always', prev: '*', next: 'return' },
|
|
58
|
+
],
|
|
59
|
+
|
|
60
|
+
// Prettier integration
|
|
61
|
+
'prettier/prettier': [
|
|
62
|
+
'error',
|
|
63
|
+
{
|
|
64
|
+
semi: true,
|
|
65
|
+
singleQuote: true,
|
|
66
|
+
bracketSpacing: true,
|
|
67
|
+
arrowParens: 'avoid',
|
|
68
|
+
printWidth: 100,
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
];
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
{
|
|
12
|
+
source: 'src/config/eslint.config.mjs',
|
|
13
|
+
dest: 'eslint.config.mjs',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
source: 'src/config/.prettierrc',
|
|
17
|
+
dest: '.prettierrc',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
source: 'src/config/cspell.json',
|
|
21
|
+
dest: 'cspell.json',
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Copy configuration files from src/config to dist/
|
|
26
|
+
*/
|
|
27
|
+
function copyConfigs() {
|
|
28
|
+
const projectRoot = node_path_1.default.resolve(__dirname, '../..');
|
|
29
|
+
const distDir = node_path_1.default.join(projectRoot, 'dist');
|
|
30
|
+
if (!node_fs_1.default.existsSync(distDir)) {
|
|
31
|
+
node_fs_1.default.mkdirSync(distDir, { recursive: true });
|
|
32
|
+
}
|
|
33
|
+
utils_1.logger.log('📦 Copying configuration files...\n');
|
|
34
|
+
configFiles.forEach(({ source, dest }) => {
|
|
35
|
+
const srcPath = node_path_1.default.join(projectRoot, source);
|
|
36
|
+
const destPath = node_path_1.default.join(distDir, dest);
|
|
37
|
+
if (node_fs_1.default.existsSync(srcPath)) {
|
|
38
|
+
node_fs_1.default.copyFileSync(srcPath, destPath);
|
|
39
|
+
utils_1.logger.log(`✅ Copied ${dest}`);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
utils_1.logger.warn(`⚠️ File not found: ${source}`);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
utils_1.logger.info('\n✨ Config files copied successfully!\n');
|
|
46
|
+
}
|
|
47
|
+
// Run if called directly
|
|
48
|
+
if (require.main === module) {
|
|
49
|
+
copyConfigs();
|
|
50
|
+
}
|
|
@@ -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
|
|
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.
|
|
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(
|
|
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
|
}
|
package/dist/scripts/index.js
CHANGED
|
@@ -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 {
|
package/dist/scripts/lint.js
CHANGED
|
@@ -1,40 +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_fs_1 = __importDefault(require("node:fs"));
|
|
9
4
|
const config_1 = require("../config");
|
|
10
5
|
const utils_1 = require("../utils");
|
|
6
|
+
const execa_1 = require("execa");
|
|
11
7
|
/**
|
|
12
8
|
* Run ESLint on the project.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @throws Will throw an error if ESLint detects issues that cannot be fixed automatically.
|
|
9
|
+
* Uses local ESLint configuration if available; otherwise uses packaged config.
|
|
16
10
|
*/
|
|
17
11
|
async function runLint() {
|
|
18
|
-
utils_1.logger.info('Running ESLint...');
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
'
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
'
|
|
30
|
-
|
|
31
|
-
|
|
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
|
+
}
|
|
32
47
|
try {
|
|
33
48
|
await (0, execa_1.execa)('npx', args, { stdio: 'inherit' });
|
|
34
49
|
utils_1.logger.info('✅ ESLint passed');
|
|
35
50
|
}
|
|
36
51
|
catch (err) {
|
|
37
|
-
utils_1.logger.warn('⚠️ ESLint issues
|
|
52
|
+
utils_1.logger.warn('⚠️ ESLint found issues');
|
|
38
53
|
throw err;
|
|
39
54
|
}
|
|
40
55
|
}
|
|
@@ -4,33 +4,91 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.runPrettier = runPrettier;
|
|
7
|
-
const execa_1 = require("execa");
|
|
8
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
7
|
const config_1 = require("../config");
|
|
10
8
|
const utils_1 = require("../utils");
|
|
9
|
+
const execa_1 = require("execa");
|
|
10
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
-
* Ignores node_modules, dist, and .git folders automatically.
|
|
14
|
-
*
|
|
15
|
-
* @throws Will throw an error if Prettier fails.
|
|
13
|
+
* Create temporary .prettierignore file with ignore patterns
|
|
16
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
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Remove temporary ignore file
|
|
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
|
+
}
|
|
17
34
|
async function runPrettier() {
|
|
18
|
-
utils_1.logger.info('Running Prettier...');
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
await (0, execa_1.execa)('npx',
|
|
82
|
+
await (0, execa_1.execa)('npx', args, { stdio: 'inherit' });
|
|
30
83
|
utils_1.logger.info('✅ Prettier completed');
|
|
31
84
|
}
|
|
32
85
|
catch (err) {
|
|
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
|
}
|
|
@@ -1,23 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.runSpellcheck = runSpellcheck;
|
|
4
7
|
const execa_1 = require("execa");
|
|
5
|
-
const
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
6
9
|
const utils_1 = require("../utils");
|
|
10
|
+
const config_1 = require("../config");
|
|
7
11
|
/**
|
|
8
|
-
*
|
|
9
|
-
* Ignores node_modules, dist, and .git folders automatically.
|
|
10
|
-
*
|
|
11
|
-
* @throws Will throw an error if spelling issues are detected.
|
|
12
|
+
* Build glob patterns for spellcheck with ignore patterns
|
|
12
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
|
+
}
|
|
13
20
|
async function runSpellcheck() {
|
|
14
|
-
utils_1.logger.info('Running spellcheck...');
|
|
15
|
-
const
|
|
16
|
-
const
|
|
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
|
+
}
|
|
17
35
|
try {
|
|
18
|
-
await (0, execa_1.execa)('npx',
|
|
19
|
-
stdio: 'inherit',
|
|
20
|
-
});
|
|
36
|
+
await (0, execa_1.execa)('npx', args, { stdio: 'inherit' });
|
|
21
37
|
utils_1.logger.info('✅ Spellcheck passed');
|
|
22
38
|
}
|
|
23
39
|
catch (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pr-checkmate",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
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
|