Skip to content

Commit 05e4b24

Browse files
committed
fix(commitlint): adding another delimiter for scopes
When doing the research we missed that commitlint has some multi-scope predefined delimiters and what we are currently using is in conflict with commitlint expectations. There is a PR in commitlint repo to fix these scenarios by letting people provide a custom delimiters for scopes but the owner is not actively working on that. @bbogdanov will try to join and push that PR to get in for their next release and unblock us to get back to what we wanted in the first place. conventional-changelog/commitlint#2407 Signed-off-by: Bogdan Bogdanov <[email protected]>
1 parent 6cde9c9 commit 05e4b24

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

scripts/commitlint/angularScopes.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/* eslint-disable @typescript-eslint/explicit-function-return-type */
2+
/* eslint-disable @typescript-eslint/no-var-requires */
3+
4+
const { delimiter } = require('./common');
25

36
const components = [
47
'accordion',
@@ -51,6 +54,6 @@ const components = [
5154
module.exports = {
5255
components,
5356
getScopes: () => {
54-
return components.map(c => `angular/${c}`).concat(['angular']);
57+
return components.map(c => `angular${delimiter}${c}`).concat(['angular']);
5558
},
5659
};

scripts/commitlint/common.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ const findScopes = (path, predicate, topLevel) => {
3636
};
3737

3838
module.exports = {
39+
delimiter: ':',
3940
findScopes,
4041
};

scripts/commitlint/coreScopes.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-var-requires */
22
/* eslint-disable @typescript-eslint/explicit-function-return-type */
33
const { readdirSync } = require('fs');
4-
const { findScopes } = require('./common');
4+
const { findScopes, delimiter } = require('./common');
55

66
const isScopeDirectory = directory => {
77
const dir = readdirSync(directory, { withFileTypes: true });
@@ -19,10 +19,10 @@ module.exports = {
1919
getScopes: coreProjectPath => {
2020
const elements = findScopes(`${coreProjectPath}/src`, isScopeDirectory);
2121

22-
const core = elements.map(x => `core/${x}`);
23-
const react = elements.map(x => `react/${x}`);
22+
const core = elements.map(x => `core${delimiter}${x}`);
23+
const react = elements.map(x => `react${delimiter}${x}`);
2424

25-
const design = findScopes(`${coreProjectPath}/src/styles`, () => true).map(x => `core/${x}`);
25+
const design = findScopes(`${coreProjectPath}/src/styles`, () => true).map(x => `core${delimiter}${x}`);
2626

2727
return new Set([...core, ...react, ...design, 'core', 'react']);
2828
},

scripts/commitlint/customScopes.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
/* eslint-disable @typescript-eslint/no-var-requires */
12
/* eslint-disable @typescript-eslint/explicit-function-return-type */
3+
24
const { readFileSync } = require('fs');
35
const { resolve } = require('path');
6+
const { delimiter } = require('./common');
47

58
const getJsonData = path => {
69
const json = readFileSync(path, 'utf8');
@@ -16,7 +19,7 @@ const generateCommitLintScopes = projects => {
1619
let _scopes = [];
1720

1821
Object.entries(projects).forEach(([project, scopes]) => {
19-
const projectScopes = scopes.map(scope => `${project}/${scope}`);
22+
const projectScopes = scopes.map(scope => `${project}${delimiter}${scope}`);
2023
_scopes = _scopes.concat([project, ...projectScopes]);
2124
});
2225

scripts/commitlint/websiteScopes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-var-requires */
22
/* eslint-disable @typescript-eslint/explicit-function-return-type */
33
const { readdirSync } = require('fs');
4-
const { findScopes } = require('./common');
4+
const { findScopes, delimiter } = require('./common');
55

66
const isScopeDirectory = directory => {
77
const dir = readdirSync(directory, { withFileTypes: true });
@@ -19,7 +19,7 @@ module.exports = {
1919
getScopes: websiteProjectPath => {
2020
const projectName = 'website';
2121
const websiteScopes = findScopes(websiteProjectPath, isScopeDirectory)
22-
.map(x => `${projectName}/${x}`)
22+
.map(x => `${projectName}${delimiter}${x}`)
2323
.concat([projectName]);
2424
return new Set(websiteScopes);
2525
},

0 commit comments

Comments
 (0)