relion 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -0
- package/dist/index.d.ts +230 -0
- package/dist/index.js +27 -0
- package/package.json +34 -53
- package/src/cli.js +0 -6
- package/src/commands.js +0 -176
- package/src/defaults.js +0 -60
- package/src/index.js +0 -75
- package/src/lib/checkpoint.js +0 -23
- package/src/lib/configuration.js +0 -35
- package/src/lib/detect-package-manager.js +0 -52
- package/src/lib/format-commit-message.js +0 -4
- package/src/lib/latest-semver-tag.js +0 -34
- package/src/lib/lifecycles/bump.js +0 -242
- package/src/lib/lifecycles/changelog.js +0 -106
- package/src/lib/lifecycles/commit.js +0 -67
- package/src/lib/lifecycles/tag.js +0 -61
- package/src/lib/print-error.js +0 -15
- package/src/lib/run-exec.js +0 -20
- package/src/lib/run-execFile.js +0 -20
- package/src/lib/run-lifecycle-script.js +0 -18
- package/src/lib/stringify-package.js +0 -34
- package/src/lib/updaters/index.js +0 -130
- package/src/lib/updaters/types/csproj.js +0 -13
- package/src/lib/updaters/types/gradle.js +0 -16
- package/src/lib/updaters/types/json.js +0 -25
- package/src/lib/updaters/types/maven.js +0 -43
- package/src/lib/updaters/types/openapi.js +0 -15
- package/src/lib/updaters/types/plain-text.js +0 -7
- package/src/lib/updaters/types/python.js +0 -30
- package/src/lib/updaters/types/yaml.js +0 -15
- package/src/lib/write-file.js +0 -6
- package/src/preset/constants.js +0 -16
- package/src/preset/index.js +0 -19
- package/src/preset/parser.js +0 -11
- package/src/preset/templates/commit.hbs +0 -19
- package/src/preset/templates/footer.hbs +0 -10
- package/src/preset/templates/header.hbs +0 -10
- package/src/preset/templates/index.js +0 -13
- package/src/preset/templates/main.hbs +0 -21
- package/src/preset/whatBump.js +0 -33
- package/src/preset/writer.js +0 -201
package/src/preset/writer.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import compareFunc from 'compare-func'
|
|
2
|
-
import { DEFAULT_COMMIT_TYPES } from './constants.js'
|
|
3
|
-
import { main, commit, header, footer } from './templates/index.js'
|
|
4
|
-
|
|
5
|
-
const COMMIT_HASH_LENGTH = 7
|
|
6
|
-
const releaseAsRegex = /release-as:\s*\w*@?([0-9]+\.[0-9]+\.[0-9a-z]+(-[0-9a-z.]+)?)\s*/i
|
|
7
|
-
/**
|
|
8
|
-
* Handlebar partials for various property substitutions based on commit context.
|
|
9
|
-
*/
|
|
10
|
-
const owner = '{{#if this.owner}}{{~this.owner}}{{else}}{{~@root.owner}}{{/if}}'
|
|
11
|
-
const host = '{{~@root.host}}'
|
|
12
|
-
const repository = '{{#if this.repository}}{{~this.repository}}{{else}}{{~@root.repository}}{{/if}}'
|
|
13
|
-
|
|
14
|
-
export async function createWriterOpts(config) {
|
|
15
|
-
const finalConfig = {
|
|
16
|
-
types: DEFAULT_COMMIT_TYPES,
|
|
17
|
-
issueUrlFormat: '{{host}}/{{owner}}/{{repository}}/issues/{{id}}',
|
|
18
|
-
commitUrlFormat: '{{host}}/{{owner}}/{{repository}}/commit/{{hash}}',
|
|
19
|
-
compareUrlFormat: '{{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}',
|
|
20
|
-
userUrlFormat: '{{host}}/{{user}}',
|
|
21
|
-
issuePrefixes: ['#'],
|
|
22
|
-
...config,
|
|
23
|
-
}
|
|
24
|
-
const commitUrlFormat = expandTemplate(finalConfig.commitUrlFormat, {
|
|
25
|
-
host,
|
|
26
|
-
owner,
|
|
27
|
-
repository,
|
|
28
|
-
})
|
|
29
|
-
const compareUrlFormat = expandTemplate(finalConfig.compareUrlFormat, {
|
|
30
|
-
host,
|
|
31
|
-
owner,
|
|
32
|
-
repository,
|
|
33
|
-
})
|
|
34
|
-
const issueUrlFormat = expandTemplate(finalConfig.issueUrlFormat, {
|
|
35
|
-
host,
|
|
36
|
-
owner,
|
|
37
|
-
repository,
|
|
38
|
-
id: '{{this.issue}}',
|
|
39
|
-
prefix: '{{this.prefix}}',
|
|
40
|
-
})
|
|
41
|
-
const writerOpts = getWriterOpts(finalConfig)
|
|
42
|
-
|
|
43
|
-
writerOpts.mainTemplate = main
|
|
44
|
-
writerOpts.headerPartial = header
|
|
45
|
-
.replace(/{{compareUrlFormat}}/g, compareUrlFormat)
|
|
46
|
-
writerOpts.commitPartial = commit
|
|
47
|
-
.replace(/{{commitUrlFormat}}/g, commitUrlFormat)
|
|
48
|
-
.replace(/{{issueUrlFormat}}/g, issueUrlFormat)
|
|
49
|
-
writerOpts.footerPartial = footer
|
|
50
|
-
.replace(/{{compareUrlFormat}}/g, compareUrlFormat)
|
|
51
|
-
|
|
52
|
-
return writerOpts
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function getWriterOpts(config) {
|
|
56
|
-
const commitGroupOrder = config.types.flatMap(t => t.section).filter(t => t)
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
finalizeContext: (context, _writerOpts, _filteredCommits, keyCommit) => {
|
|
60
|
-
if (keyCommit) {
|
|
61
|
-
const versionTagRegex = /tag:\s*([^,\s)]+)/i
|
|
62
|
-
const keyCommitTag = keyCommit.gitTags?.match(versionTagRegex)
|
|
63
|
-
if (keyCommitTag) {
|
|
64
|
-
context.currentTag = keyCommitTag[1]
|
|
65
|
-
const currentTagIndex = context.gitSemverTags.indexOf(context.currentTag)
|
|
66
|
-
context.previousTag = (currentTagIndex === -1) ? null : context.gitSemverTags[currentTagIndex + 1]
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
context.currentTag = context.newTag || null
|
|
71
|
-
context.previousTag = context.gitSemverTags[0] || null
|
|
72
|
-
}
|
|
73
|
-
return context
|
|
74
|
-
},
|
|
75
|
-
transform: (commit, context) => {
|
|
76
|
-
let discard = true
|
|
77
|
-
const issues = []
|
|
78
|
-
const entry = findTypeEntry(config.types, commit)
|
|
79
|
-
|
|
80
|
-
// Add an entry in the CHANGELOG if special Release-As footer
|
|
81
|
-
// is used:
|
|
82
|
-
if ((commit.footer && releaseAsRegex.test(commit.footer))
|
|
83
|
-
|| (commit.body && releaseAsRegex.test(commit.body))) {
|
|
84
|
-
discard = false
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const notes = commit.notes.map((note) => {
|
|
88
|
-
discard = false
|
|
89
|
-
|
|
90
|
-
return {
|
|
91
|
-
...note,
|
|
92
|
-
title: 'BREAKING CHANGES',
|
|
93
|
-
}
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
// breaking changes attached to any type are still displayed.
|
|
97
|
-
if (discard && (entry === undefined
|
|
98
|
-
|| entry.hidden)) {
|
|
99
|
-
return undefined
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const type = entry
|
|
103
|
-
? entry.section
|
|
104
|
-
: commit.type
|
|
105
|
-
const scope = commit.scope === '*'
|
|
106
|
-
? ''
|
|
107
|
-
: commit.scope
|
|
108
|
-
const shortHash = typeof commit.hash === 'string'
|
|
109
|
-
? commit.hash.substring(0, COMMIT_HASH_LENGTH)
|
|
110
|
-
: commit.shortHash
|
|
111
|
-
let { subject } = commit
|
|
112
|
-
|
|
113
|
-
if (typeof subject === 'string') {
|
|
114
|
-
// Issue URLs.
|
|
115
|
-
const issueRegEx = `(${config.issuePrefixes.join('|')})([a-z0-9]+)`
|
|
116
|
-
const re = new RegExp(issueRegEx, 'g')
|
|
117
|
-
|
|
118
|
-
subject = subject.replace(re, (_, prefix, issue) => {
|
|
119
|
-
issues.push(prefix + issue)
|
|
120
|
-
|
|
121
|
-
const url = expandTemplate(config.issueUrlFormat, {
|
|
122
|
-
host: context.host,
|
|
123
|
-
owner: context.owner,
|
|
124
|
-
repository: context.repository,
|
|
125
|
-
id: issue,
|
|
126
|
-
prefix,
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
return `[${prefix}${issue}](${url})`
|
|
130
|
-
})
|
|
131
|
-
// User URLs.
|
|
132
|
-
subject = subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, user) => {
|
|
133
|
-
// TODO: investigate why this code exists.
|
|
134
|
-
if (user.includes('/')) {
|
|
135
|
-
return `@${user}`
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const usernameUrl = expandTemplate(config.userUrlFormat, {
|
|
139
|
-
host: context.host,
|
|
140
|
-
owner: context.owner,
|
|
141
|
-
repository: context.repository,
|
|
142
|
-
user,
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
return `[@${user}](${usernameUrl})`
|
|
146
|
-
})
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// remove references that already appear in the subject
|
|
150
|
-
const references = commit.references.filter(reference => !issues.includes(reference.prefix + reference.issue))
|
|
151
|
-
|
|
152
|
-
return {
|
|
153
|
-
notes,
|
|
154
|
-
type,
|
|
155
|
-
scope,
|
|
156
|
-
shortHash,
|
|
157
|
-
subject,
|
|
158
|
-
references,
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
groupBy: 'type',
|
|
162
|
-
// the groupings of commit messages, e.g., Features vs., Bug Fixes, are
|
|
163
|
-
// sorted based on their probable importance:
|
|
164
|
-
commitGroupsSort: (a, b) => {
|
|
165
|
-
const gRankA = commitGroupOrder.indexOf(a.title)
|
|
166
|
-
const gRankB = commitGroupOrder.indexOf(b.title)
|
|
167
|
-
|
|
168
|
-
return gRankA - gRankB
|
|
169
|
-
},
|
|
170
|
-
commitsSort: ['scope', 'subject'],
|
|
171
|
-
noteGroupsSort: 'title',
|
|
172
|
-
notesSort: compareFunc,
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function findTypeEntry(types, commit) {
|
|
177
|
-
const typeKey = (commit.revert ? 'revert' : commit.type || '').toLowerCase()
|
|
178
|
-
|
|
179
|
-
return types.find((entry) => {
|
|
180
|
-
if (entry.type !== typeKey) {
|
|
181
|
-
return false
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (entry.scope && entry.scope !== commit.scope) {
|
|
185
|
-
return false
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
return true
|
|
189
|
-
})
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// expand on the simple mustache-style templates supported in
|
|
193
|
-
// configuration (we may eventually want to use handlebars for this).
|
|
194
|
-
function expandTemplate(template, context) {
|
|
195
|
-
let expanded = template
|
|
196
|
-
|
|
197
|
-
Object.keys(context).forEach((key) => {
|
|
198
|
-
expanded = expanded.replace(new RegExp(`{{${key}}}`, 'g'), context[key])
|
|
199
|
-
})
|
|
200
|
-
return expanded
|
|
201
|
-
}
|