-
Notifications
You must be signed in to change notification settings - Fork 159
Expand file tree
/
Copy path.external.versionrc.js
More file actions
93 lines (89 loc) · 3.07 KB
/
Copy path.external.versionrc.js
File metadata and controls
93 lines (89 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const getShortHash = (commit) => {
const ref = commit.references && commit.references[0]
return ref && typeof ref.issue === 'string' && ref.issue.length > 0
? `${ref.prefix || '#'}${ref.issue}` // e.g. "#9190"
: typeof commit.hash === 'string'
? commit.hash.substring(0, 7) // fallback to 7-char commit hash
: ''
}
module.exports = {
path: ["packages/sdk"],
// Both packageFiles (read current version) and bumpFiles (write new version)
// must point at packages/sdk/package.json. If packageFiles is omitted,
// commit-and-tag-version falls back to reading the root package.json and
// derives the next SDK version from the monorepo version instead.
packageFiles: [{ filename: 'packages/sdk/package.json', type: 'json' }],
bumpFiles: [{ filename: 'packages/sdk/package.json', type: 'json' }],
infile: 'packages/sdk/CHANGELOG.md',
tagPrefix: 'sdk-v',
writerOpts: {
groupBy: 'section',
transform: (commit) => {
commit.shortHash = getShortHash(commit)
commit.references = [] // To avoid "closes #123" / "fixes #123" suffixes
const typeToSection = {
feat: 'Features',
fix: 'Bug Fixes',
perf: 'Performance',
refactor: 'Refactors',
build: 'Builds',
ci: 'CI',
test: 'Tests',
docs: 'Documentation',
style: 'Styles',
chore: 'Chores',
revert: 'Reverts',
}
const matchedSection = typeToSection[commit.type]
commit.section = matchedSection ? matchedSection : 'Miscellaneous'
if (!commit.type) {
return commit
}
if (commit.scope === 'deps') {
commit.section = 'Dependencies'
}
if (commit.scope === 'deps-dev') {
commit.section = 'Dev-Dependencies'
}
const headerPrefix = commit.scope
? `${commit.type}(${commit.scope}): `
: `${commit.type}: `
return {
...commit,
section: commit.section,
shortHash: commit.shortHash,
header: `${headerPrefix}${commit.subject}`,
}
},
// Order sections: Features first, then Bug Fixes, then dependencies, etc.
commitGroupsSort: (a, b) => {
const order = [
'Features',
'Bug Fixes',
'Performance',
'Refactoring',
'Build System',
'CI',
'Tests',
'Documentation',
'Styles',
'Dependencies',
'Dev-Dependencies',
'Chores',
'Reverts',
'Miscellaneous',
]
const aIndex = order.indexOf(a.title)
const bIndex = order.indexOf(b.title)
return (aIndex === -1 ? order.length : aIndex) - (bIndex === -1 ? order.length : bIndex)
},
commitsSort: (a, b) => {
const aHasScope = Boolean(a.scope);
const bHasScope = Boolean(b.scope);
if (aHasScope && !bHasScope) return -1; // scoped first
if (!aHasScope && bHasScope) return 1; // unscoped last
return (a.header || '').localeCompare(b.header || ''); // both scoped or unscoped: sort by scope then header
},
},
releaseCommitMessageFormat: 'chore(sdk): bump version to {{currentTag}}',
};