2025-04-18 12:50:52 +08:00
|
|
|
// commitlint.config.js
|
2025-04-21 14:16:56 +08:00
|
|
|
const fs = require('node:fs');
|
|
|
|
const path = require('node:path');
|
|
|
|
|
|
|
|
// read subdirectories of the directory
|
|
|
|
function getSubdirectories(dir) {
|
|
|
|
if (!fs.existsSync(dir)) return [];
|
|
|
|
|
|
|
|
return fs
|
|
|
|
.readdirSync(dir, { withFileTypes: true })
|
|
|
|
.filter((dirent) => dirent.isDirectory())
|
|
|
|
.map((dirent) => dirent.name);
|
|
|
|
}
|
|
|
|
|
|
|
|
// get subdirectories of the directory
|
|
|
|
const appsScopes = getSubdirectories(path.join(__dirname, 'apps'));
|
|
|
|
const packagesScopes = getSubdirectories(path.join(__dirname, 'packages'));
|
|
|
|
|
|
|
|
// merge all scopes and remove duplicates
|
|
|
|
const allScopes = [
|
|
|
|
// basic scopes
|
|
|
|
'workflow',
|
|
|
|
'llm',
|
|
|
|
'playwright',
|
|
|
|
'puppeteer',
|
|
|
|
'mcp',
|
2025-05-21 16:49:26 +08:00
|
|
|
'blog',
|
2025-04-21 20:51:17 +08:00
|
|
|
'bridge',
|
2025-04-21 14:16:56 +08:00
|
|
|
// automatically added scopes
|
|
|
|
...appsScopes,
|
|
|
|
...packagesScopes,
|
|
|
|
];
|
|
|
|
|
|
|
|
// remove duplicates
|
|
|
|
const uniqueScopes = [...new Set(allScopes)];
|
|
|
|
|
2025-04-18 12:50:52 +08:00
|
|
|
module.exports = {
|
|
|
|
extends: ['@commitlint/config-conventional'],
|
|
|
|
rules: {
|
|
|
|
'scope-enum': [
|
|
|
|
2, // Level: Error
|
|
|
|
'always', // Apply rule always
|
2025-04-21 14:16:56 +08:00
|
|
|
uniqueScopes,
|
2025-04-18 12:50:52 +08:00
|
|
|
],
|
|
|
|
// Add rule to disallow empty scopes
|
|
|
|
'scope-empty': [2, 'never'],
|
|
|
|
},
|
|
|
|
};
|