commitizen.js 755 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. const { execSync } = require('child_process');
  3. const fg = require('fast-glob');
  4. const components = fg.sync('*', { cwd: 'components', onlyDirectories: true });
  5. // precomputed scope
  6. const scopeComplete = execSync('git status --porcelain || true')
  7. .toString()
  8. .trim()
  9. .split('\n')
  10. .find(r => ~r.indexOf('M '))
  11. ?.replace(/(\/)/g, '%%')
  12. ?.match(/components%%((\w|-)*)/)?.[1];
  13. /** @type {import('cz-git').CommitizenGitOptions} */
  14. module.exports = {
  15. scopes: ['site', 'util', 'script', 'tool', ...components],
  16. scopeFilters: ['__tests__', '_util'],
  17. customScopesAlign: !scopeComplete ? 'top' : 'bottom',
  18. defaultScope: scopeComplete,
  19. maxHeaderLength: 100,
  20. allowEmptyIssuePrefixs: false,
  21. allowCustomIssuePrefixs: false,
  22. };