Skip to content

Commit c9d8243

Browse files
committed
build: use actual list of packages for commit message
Also add the tool type, which should be used for tooling.
1 parent d928c1c commit c9d8243

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

scripts/validate-commit-message/commit-message.json

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,7 @@
99
"perf",
1010
"refactor",
1111
"style",
12-
"test"
13-
],
14-
"scopes": [
15-
"@angular/cli",
16-
"@ngtools/json-schema",
17-
"@ngtools/logger",
18-
"@ngtools/webpack",
19-
20-
"packaging",
21-
"changelog"
12+
"test",
13+
"tool"
2214
]
2315
}

scripts/validate-commit-message/validate-commit-message.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const fs = require('fs');
2121
const path = require('path');
2222
const configPath = path.resolve(__dirname, './commit-message.json');
2323
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
24+
const { packages, tools } = require('../../lib/packages');
2425
const PATTERN = /^(revert\: )?(\w+)(?:\(([^)]+)\))?\: (.+)$/;
2526

2627
module.exports = function(commitSubject) {
@@ -45,14 +46,27 @@ module.exports = function(commitSubject) {
4546
}
4647

4748
const scope = match[3];
49+
const allScopes = Object.keys(packages).concat(Object.keys(tools));
4850

49-
if (scope && !config['scopes'].includes(scope)) {
51+
if (scope && !allScopes.includes(scope)) {
5052
error(
5153
`"${scope}" is not an allowed scope.\n => SCOPES: ${config['scopes'].join(', ')}`,
5254
commitSubject);
5355
return false;
5456
}
5557

58+
// Having a tool scope and not using tool() is an error.
59+
if (scope && Object.keys(tools).includes(scope) && type !== 'tool') {
60+
error(`"${scope}" is a tool, but the type is NOT "tool".`);
61+
return false;
62+
}
63+
64+
// Having a package scope and using tool() is an error.
65+
if (scope && Object.keys(tools).includes(scope) && type !== 'tool') {
66+
error(`"${scope}" is NOT a tool, but the type is "tool".`);
67+
return false;
68+
}
69+
5670
return true;
5771
};
5872

0 commit comments

Comments
 (0)