semantic-release 19.0.5 → 20.0.0-beta.1
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/bin/semantic-release.js +15 -13
- package/cli.js +11 -11
- package/docs/extending/plugins-list.md +4 -0
- package/docs/support/troubleshooting.md +2 -2
- package/docs/usage/ci-configuration.md +1 -1
- package/docs/usage/configuration.md +3 -3
- package/index.js +27 -24
- package/lib/branches/expand.js +5 -5
- package/lib/branches/get-tags.js +10 -7
- package/lib/branches/index.js +11 -11
- package/lib/branches/normalize.js +13 -16
- package/lib/definitions/branches.js +6 -8
- package/lib/definitions/constants.js +9 -21
- package/lib/definitions/errors.js +120 -54
- package/lib/definitions/plugins.js +6 -6
- package/lib/get-commits.js +6 -4
- package/lib/get-config.js +25 -16
- package/lib/get-error.js +4 -4
- package/lib/get-git-auth-url.js +9 -7
- package/lib/get-last-release.js +6 -6
- package/lib/get-logger.js +6 -4
- package/lib/get-next-version.js +5 -5
- package/lib/get-release-to-add.js +7 -7
- package/lib/git.js +26 -46
- package/lib/hide-sensitive.js +4 -4
- package/lib/plugins/index.js +36 -26
- package/lib/plugins/normalize.js +11 -9
- package/lib/plugins/pipeline.js +6 -6
- package/lib/plugins/utils.js +14 -10
- package/lib/utils.js +19 -37
- package/lib/verify.js +6 -6
- package/package.json +37 -31
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {inspect} from 'node:util';
|
|
2
|
+
import {createRequire} from 'node:module';
|
|
3
|
+
import {isString, toLower, trim} from 'lodash-es';
|
|
4
|
+
import {RELEASE_TYPE} from './constants.js';
|
|
5
|
+
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
3
7
|
const pkg = require('../../package.json');
|
|
4
|
-
const {RELEASE_TYPE} = require('./constants');
|
|
5
8
|
|
|
6
9
|
const [homepage] = pkg.homepage.split('#');
|
|
7
10
|
const stringify = (object) =>
|
|
@@ -10,16 +13,19 @@ const linkify = (file) => `${homepage}/blob/master/${file}`;
|
|
|
10
13
|
const wordsList = (words) =>
|
|
11
14
|
`${words.slice(0, -1).join(', ')}${words.length > 1 ? ` or ${words[words.length - 1]}` : trim(words[0])}`;
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
export function ENOGITREPO({cwd}) {
|
|
17
|
+
return {
|
|
15
18
|
message: 'Not running from a git repository.',
|
|
16
19
|
details: `The \`semantic-release\` command must be executed from a Git repository.
|
|
17
20
|
|
|
18
21
|
The current working directory is \`${cwd}\`.
|
|
19
22
|
|
|
20
23
|
Please verify your CI configuration to make sure the \`semantic-release\` command is executed from the root of the cloned repository.`,
|
|
21
|
-
}
|
|
22
|
-
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function ENOREPOURL() {
|
|
28
|
+
return {
|
|
23
29
|
message: 'The `repositoryUrl` option is required.',
|
|
24
30
|
details: `The [repositoryUrl option](${linkify(
|
|
25
31
|
'docs/usage/configuration.md#repositoryurl'
|
|
@@ -28,8 +34,11 @@ Please verify your CI configuration to make sure the \`semantic-release\` comman
|
|
|
28
34
|
Please make sure to add the \`repositoryUrl\` to the [semantic-release configuration] (${linkify(
|
|
29
35
|
'docs/usage/configuration.md'
|
|
30
36
|
)}).`,
|
|
31
|
-
}
|
|
32
|
-
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function EGITNOPERMISSION({options: {repositoryUrl}, branch: {name}}) {
|
|
41
|
+
return {
|
|
33
42
|
message: 'Cannot push to the Git repository.',
|
|
34
43
|
details: `**semantic-release** cannot push the version tag to the branch \`${name}\` on the remote Git repository with URL \`${repositoryUrl}\`.
|
|
35
44
|
|
|
@@ -37,42 +46,57 @@ This can be caused by:
|
|
|
37
46
|
- a misconfiguration of the [repositoryUrl](${linkify('docs/usage/configuration.md#repositoryurl')}) option
|
|
38
47
|
- the repository being unavailable
|
|
39
48
|
- or missing push permission for the user configured via the [Git credentials on your CI environment](${linkify(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
49
|
+
'docs/usage/ci-configuration.md#authentication'
|
|
50
|
+
)})`,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function EINVALIDTAGFORMAT({options: {tagFormat}}) {
|
|
55
|
+
return {
|
|
44
56
|
message: 'Invalid `tagFormat` option.',
|
|
45
57
|
details: `The [tagFormat](${linkify(
|
|
46
58
|
'docs/usage/configuration.md#tagformat'
|
|
47
59
|
)}) must compile to a [valid Git reference](https://git-scm.com/docs/git-check-ref-format#_description).
|
|
48
60
|
|
|
49
61
|
Your configuration for the \`tagFormat\` option is \`${stringify(tagFormat)}\`.`,
|
|
50
|
-
}
|
|
51
|
-
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function ETAGNOVERSION({options: {tagFormat}}) {
|
|
66
|
+
return {
|
|
52
67
|
message: 'Invalid `tagFormat` option.',
|
|
53
68
|
details: `The [tagFormat](${linkify(
|
|
54
69
|
'docs/usage/configuration.md#tagformat'
|
|
55
70
|
)}) option must contain the variable \`version\` exactly once.
|
|
56
71
|
|
|
57
72
|
Your configuration for the \`tagFormat\` option is \`${stringify(tagFormat)}\`.`,
|
|
58
|
-
}
|
|
59
|
-
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function EPLUGINCONF({type, required, pluginConf}) {
|
|
77
|
+
return {
|
|
60
78
|
message: `The \`${type}\` plugin configuration is invalid.`,
|
|
61
79
|
details: `The [${type} plugin configuration](${linkify(`docs/usage/plugins.md#${toLower(type)}-plugin`)}) ${
|
|
62
80
|
required ? 'is required and ' : ''
|
|
63
81
|
} must be a single or an array of plugins definition. A plugin definition is an npm module name, optionally wrapped in an array with an object.
|
|
64
82
|
|
|
65
83
|
Your configuration for the \`${type}\` plugin is \`${stringify(pluginConf)}\`.`,
|
|
66
|
-
}
|
|
67
|
-
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function EPLUGINSCONF({plugin}) {
|
|
88
|
+
return {
|
|
68
89
|
message: 'The `plugins` configuration is invalid.',
|
|
69
90
|
details: `The [plugins](${linkify(
|
|
70
91
|
'docs/usage/configuration.md#plugins'
|
|
71
|
-
)}) option must be an array of plugin
|
|
92
|
+
)}) option must be an array of plugin definitions. A plugin definition is an npm module name, optionally wrapped in an array with an object.
|
|
72
93
|
|
|
73
94
|
The invalid configuration is \`${stringify(plugin)}\`.`,
|
|
74
|
-
}
|
|
75
|
-
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function EPLUGIN({pluginName, type}) {
|
|
99
|
+
return {
|
|
76
100
|
message: `A plugin configured in the step ${type} is not a valid semantic-release plugin.`,
|
|
77
101
|
details: `A valid \`${type}\` **semantic-release** plugin must be a function or an object with a function in the property \`${type}\`.
|
|
78
102
|
|
|
@@ -81,8 +105,11 @@ The plugin \`${pluginName}\` doesn't have the property \`${type}\` and cannot be
|
|
|
81
105
|
Please refer to the \`${pluginName}\` and [semantic-release plugins configuration](${linkify(
|
|
82
106
|
'docs/usage/plugins.md'
|
|
83
107
|
)}) documentation for more details.`,
|
|
84
|
-
}
|
|
85
|
-
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function EANALYZECOMMITSOUTPUT({result, pluginName}) {
|
|
112
|
+
return {
|
|
86
113
|
message: 'The `analyzeCommits` plugin returned an invalid value. It must return a valid semver release type.',
|
|
87
114
|
details: `The \`analyzeCommits\` plugin must return a valid [semver](https://semver.org) release type. The valid values are: ${RELEASE_TYPE.map(
|
|
88
115
|
(type) => `\`${type}\``
|
|
@@ -97,8 +124,11 @@ We recommend to report the issue to the \`${pluginName}\` authors, providing the
|
|
|
97
124
|
- A link to the **semantic-release** plugin developer guide: [${linkify('docs/developer-guide/plugin.md')}](${linkify(
|
|
98
125
|
'docs/developer-guide/plugin.md'
|
|
99
126
|
)})`,
|
|
100
|
-
}
|
|
101
|
-
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function EGENERATENOTESOUTPUT({result, pluginName}) {
|
|
131
|
+
return {
|
|
102
132
|
message: 'The `generateNotes` plugin returned an invalid value. It must return a `String`.',
|
|
103
133
|
details: `The \`generateNotes\` plugin must return a \`String\`.
|
|
104
134
|
|
|
@@ -111,8 +141,11 @@ We recommend to report the issue to the \`${pluginName}\` authors, providing the
|
|
|
111
141
|
- A link to the **semantic-release** plugin developer guide: [${linkify('docs/developer-guide/plugin.md')}](${linkify(
|
|
112
142
|
'docs/developer-guide/plugin.md'
|
|
113
143
|
)})`,
|
|
114
|
-
}
|
|
115
|
-
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function EPUBLISHOUTPUT({result, pluginName}) {
|
|
148
|
+
return {
|
|
116
149
|
message: 'A `publish` plugin returned an invalid value. It must return an `Object`.',
|
|
117
150
|
details: `The \`publish\` plugins must return an \`Object\`.
|
|
118
151
|
|
|
@@ -125,8 +158,11 @@ We recommend to report the issue to the \`${pluginName}\` authors, providing the
|
|
|
125
158
|
- A link to the **semantic-release** plugin developer guide: [${linkify('docs/developer-guide/plugin.md')}](${linkify(
|
|
126
159
|
'docs/developer-guide/plugin.md'
|
|
127
160
|
)})`,
|
|
128
|
-
}
|
|
129
|
-
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function EADDCHANNELOUTPUT({result, pluginName}) {
|
|
165
|
+
return {
|
|
130
166
|
message: 'A `addChannel` plugin returned an invalid value. It must return an `Object`.',
|
|
131
167
|
details: `The \`addChannel\` plugins must return an \`Object\`.
|
|
132
168
|
|
|
@@ -139,48 +175,66 @@ We recommend to report the issue to the \`${pluginName}\` authors, providing the
|
|
|
139
175
|
- A link to the **semantic-release** plugin developer guide: [${linkify('docs/developer-guide/plugin.md')}](${linkify(
|
|
140
176
|
'docs/developer-guide/plugin.md'
|
|
141
177
|
)})`,
|
|
142
|
-
}
|
|
143
|
-
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export function EINVALIDBRANCH({branch}) {
|
|
182
|
+
return {
|
|
144
183
|
message: 'A branch is invalid in the `branches` configuration.',
|
|
145
184
|
details: `Each branch in the [branches configuration](${linkify(
|
|
146
185
|
'docs/usage/configuration.md#branches'
|
|
147
186
|
)}) must be either a string, a regexp or an object with a \`name\` property.
|
|
148
187
|
|
|
149
188
|
Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
|
150
|
-
}
|
|
151
|
-
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function EINVALIDBRANCHNAME({branch}) {
|
|
193
|
+
return {
|
|
152
194
|
message: 'A branch name is invalid in the `branches` configuration.',
|
|
153
195
|
details: `Each branch in the [branches configuration](${linkify(
|
|
154
196
|
'docs/usage/configuration.md#branches'
|
|
155
197
|
)}) must be a [valid Git reference](https://git-scm.com/docs/git-check-ref-format#_description).
|
|
156
198
|
|
|
157
199
|
Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
|
158
|
-
}
|
|
159
|
-
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export function EDUPLICATEBRANCHES({duplicates}) {
|
|
204
|
+
return {
|
|
160
205
|
message: 'The `branches` configuration has duplicate branches.',
|
|
161
206
|
details: `Each branch in the [branches configuration](${linkify(
|
|
162
207
|
'docs/usage/configuration.md#branches'
|
|
163
208
|
)}) must havea unique name.
|
|
164
209
|
|
|
165
210
|
Your configuration contains duplicates for the following branch names: \`${stringify(duplicates)}\`.`,
|
|
166
|
-
}
|
|
167
|
-
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function EMAINTENANCEBRANCH({branch}) {
|
|
215
|
+
return {
|
|
168
216
|
message: 'A maintenance branch is invalid in the `branches` configuration.',
|
|
169
217
|
details: `Each maintenance branch in the [branches configuration](${linkify(
|
|
170
218
|
'docs/usage/configuration.md#branches'
|
|
171
219
|
)}) must have a \`range\` property formatted like \`N.x\`, \`N.x.x\` or \`N.N.x\` (\`N\` is a number).
|
|
172
220
|
|
|
173
221
|
Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
|
174
|
-
}
|
|
175
|
-
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export function EMAINTENANCEBRANCHES({branches}) {
|
|
226
|
+
return {
|
|
176
227
|
message: 'The maintenance branches are invalid in the `branches` configuration.',
|
|
177
228
|
details: `Each maintenance branch in the [branches configuration](${linkify(
|
|
178
229
|
'docs/usage/configuration.md#branches'
|
|
179
230
|
)}) must have a unique \`range\` property.
|
|
180
231
|
|
|
181
232
|
Your configuration for the problematic branches is \`${stringify(branches)}\`.`,
|
|
182
|
-
}
|
|
183
|
-
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export function ERELEASEBRANCHES({branches}) {
|
|
237
|
+
return {
|
|
184
238
|
message: 'The release branches are invalid in the `branches` configuration.',
|
|
185
239
|
details: `A minimum of 1 and a maximum of 3 release branches are required in the [branches configuration](${linkify(
|
|
186
240
|
'docs/usage/configuration.md#branches'
|
|
@@ -189,24 +243,33 @@ Your configuration for the problematic branches is \`${stringify(branches)}\`.`,
|
|
|
189
243
|
This may occur if your repository does not have a release branch, such as \`master\`.
|
|
190
244
|
|
|
191
245
|
Your configuration for the problematic branches is \`${stringify(branches)}\`.`,
|
|
192
|
-
}
|
|
193
|
-
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export function EPRERELEASEBRANCH({branch}) {
|
|
250
|
+
return {
|
|
194
251
|
message: 'A pre-release branch configuration is invalid in the `branches` configuration.',
|
|
195
252
|
details: `Each pre-release branch in the [branches configuration](${linkify(
|
|
196
253
|
'docs/usage/configuration.md#branches'
|
|
197
254
|
)}) must have a \`prerelease\` property valid per the [Semantic Versioning Specification](https://semver.org/#spec-item-9). If the \`prerelease\` property is set to \`true\`, then the \`name\` property is used instead.
|
|
198
255
|
|
|
199
256
|
Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
|
200
|
-
}
|
|
201
|
-
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export function EPRERELEASEBRANCHES({branches}) {
|
|
261
|
+
return {
|
|
202
262
|
message: 'The pre-release branches are invalid in the `branches` configuration.',
|
|
203
263
|
details: `Each pre-release branch in the [branches configuration](${linkify(
|
|
204
264
|
'docs/usage/configuration.md#branches'
|
|
205
265
|
)}) must have a unique \`prerelease\` property. If the \`prerelease\` property is set to \`true\`, then the \`name\` property is used instead.
|
|
206
266
|
|
|
207
267
|
Your configuration for the problematic branches is \`${stringify(branches)}\`.`,
|
|
208
|
-
}
|
|
209
|
-
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export function EINVALIDNEXTVERSION({nextRelease: {version}, branch: {name, range}, commits, validBranches}) {
|
|
272
|
+
return {
|
|
210
273
|
message: `The release \`${version}\` on branch \`${name}\` cannot be published as it is out of range.`,
|
|
211
274
|
details: `Based on the releases published on other branches, only versions within the range \`${range}\` can be published from branch \`${name}\`.
|
|
212
275
|
|
|
@@ -214,19 +277,22 @@ The following commit${commits.length > 1 ? 's are' : ' is'} responsible for the
|
|
|
214
277
|
${commits.map(({commit: {short}, subject}) => `- ${subject} (${short})`).join('\n')}
|
|
215
278
|
|
|
216
279
|
${
|
|
217
|
-
|
|
218
|
-
} should be moved to a valid branch with [git merge](https://git-scm.com/docs/git-merge) or [git cherry-pick](https://git-scm.com/docs/git-cherry-pick) and removed from branch \`${name}\` with [git revert](https://git-scm.com/docs/git-revert) or [git reset](https://git-scm.com/docs/git-reset).
|
|
280
|
+
commits.length > 1 ? 'Those commits' : 'This commit'
|
|
281
|
+
} should be moved to a valid branch with [git merge](https://git-scm.com/docs/git-merge) or [git cherry-pick](https://git-scm.com/docs/git-cherry-pick) and removed from branch \`${name}\` with [git revert](https://git-scm.com/docs/git-revert) or [git reset](https://git-scm.com/docs/git-reset).
|
|
219
282
|
|
|
220
283
|
A valid branch could be ${wordsList(validBranches.map(({name}) => `\`${name}\``))}.
|
|
221
284
|
|
|
222
285
|
See the [workflow configuration documentation](${linkify('docs/usage/workflow-configuration.md')}) for more details.`,
|
|
223
|
-
}
|
|
224
|
-
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export function EINVALIDMAINTENANCEMERGE({nextRelease: {channel, gitTag, version}, branch: {mergeRange, name}}) {
|
|
290
|
+
return {
|
|
225
291
|
message: `The release \`${version}\` on branch \`${name}\` cannot be published as it is out of range.`,
|
|
226
292
|
details: `Only releases within the range \`${mergeRange}\` can be merged into the maintenance branch \`${name}\` and published to the \`${channel}\` distribution channel.
|
|
227
293
|
|
|
228
294
|
The branch \`${name}\` head should be [reset](https://git-scm.com/docs/git-reset) to a previous commit so the commit with tag \`${gitTag}\` is removed from the branch history.
|
|
229
295
|
|
|
230
296
|
See the [workflow configuration documentation](${linkify('docs/usage/workflow-configuration.md')}) for more details.`,
|
|
231
|
-
}
|
|
232
|
-
}
|
|
297
|
+
};
|
|
298
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/* eslint require-atomic-updates: off */
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import {isPlainObject, isString} from 'lodash-es';
|
|
4
|
+
import {getGitHead} from '../git.js';
|
|
5
|
+
import hideSensitive from '../hide-sensitive.js';
|
|
6
|
+
import {hideSensitiveValues} from '../utils.js';
|
|
7
|
+
import {RELEASE_NOTES_SEPARATOR, RELEASE_TYPE} from './constants.js';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
export default {
|
|
10
10
|
verifyConditions: {
|
|
11
11
|
required: false,
|
|
12
12
|
dryRun: true,
|
package/lib/get-commits.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import debugCommits from 'debug';
|
|
2
|
+
import {getCommits} from './git.js';
|
|
3
|
+
|
|
4
|
+
const debug = debugCommits('semantic-release:get-commits');
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* Retrieve the list of commits on the current branch since the commit sha associated with the last release, or all the commits of the current branch if there is no last released version.
|
|
@@ -8,7 +10,7 @@ const {getCommits} = require('./git');
|
|
|
8
10
|
*
|
|
9
11
|
* @return {Promise<Array<Object>>} The list of commits on the branch `branch` since the last release.
|
|
10
12
|
*/
|
|
11
|
-
|
|
13
|
+
export default async ({cwd, env, lastRelease: {gitHead: from}, nextRelease: {gitHead: to = 'HEAD'} = {}, logger}) => {
|
|
12
14
|
if (from) {
|
|
13
15
|
debug('Use from: %s', from);
|
|
14
16
|
} else {
|
|
@@ -20,4 +22,4 @@ module.exports = async ({cwd, env, lastRelease: {gitHead: from}, nextRelease: {g
|
|
|
20
22
|
logger.log(`Found ${commits.length} commits since last release`);
|
|
21
23
|
debug('Parsed commits: %o', commits);
|
|
22
24
|
return commits;
|
|
23
|
-
}
|
|
25
|
+
}
|
package/lib/get-config.js
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import {dirname, resolve} from 'node:path';
|
|
2
|
+
import {fileURLToPath} from 'node:url';
|
|
3
|
+
import {createRequire} from 'node:module';
|
|
4
|
+
|
|
5
|
+
import {castArray, isNil, isPlainObject, isString, pickBy} from 'lodash-es';
|
|
6
|
+
import {readPackageUp} from 'read-pkg-up';
|
|
7
|
+
import {cosmiconfig} from 'cosmiconfig';
|
|
8
|
+
import resolveFrom from 'resolve-from';
|
|
9
|
+
import debugConfig from 'debug';
|
|
10
|
+
import {repoUrl} from './git.js';
|
|
11
|
+
import PLUGINS_DEFINITIONS from './definitions/plugins.js';
|
|
12
|
+
import plugins from './plugins/index.js';
|
|
13
|
+
import {parseConfig, validatePlugin} from './plugins/utils.js';
|
|
14
|
+
|
|
15
|
+
const debug = debugConfig('semantic-release:config');
|
|
16
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
const require = createRequire(import.meta.url);
|
|
10
18
|
|
|
11
19
|
const CONFIG_NAME = 'release';
|
|
12
20
|
|
|
13
|
-
|
|
21
|
+
export default async (context, cliOptions) => {
|
|
14
22
|
const {cwd, env} = context;
|
|
15
23
|
const {config, filepath} = (await cosmiconfig(CONFIG_NAME).search(cwd)) || {};
|
|
16
24
|
|
|
@@ -25,11 +33,12 @@ module.exports = async (context, cliOptions) => {
|
|
|
25
33
|
if (extendPaths) {
|
|
26
34
|
// If `extends` is defined, load and merge each shareable config with `options`
|
|
27
35
|
options = {
|
|
28
|
-
...castArray(extendPaths).reduce((
|
|
36
|
+
...await (castArray(extendPaths).reduce(async(eventualResult, extendPath) => {
|
|
37
|
+
const result = await eventualResult;
|
|
29
38
|
const extendsOptions = require(resolveFrom.silent(__dirname, extendPath) || resolveFrom(cwd, extendPath));
|
|
30
39
|
|
|
31
40
|
// For each plugin defined in a shareable config, save in `pluginsPath` the extendable config path,
|
|
32
|
-
// so those plugin will be loaded
|
|
41
|
+
// so those plugin will be loaded relative to the config file
|
|
33
42
|
Object.entries(extendsOptions)
|
|
34
43
|
.filter(([, value]) => Boolean(value))
|
|
35
44
|
.reduce((pluginsPath, [option, value]) => {
|
|
@@ -47,7 +56,7 @@ module.exports = async (context, cliOptions) => {
|
|
|
47
56
|
}, pluginsPath);
|
|
48
57
|
|
|
49
58
|
return {...result, ...extendsOptions};
|
|
50
|
-
}, {}),
|
|
59
|
+
}, {})),
|
|
51
60
|
...options,
|
|
52
61
|
};
|
|
53
62
|
}
|
|
@@ -70,7 +79,7 @@ module.exports = async (context, cliOptions) => {
|
|
|
70
79
|
'@semantic-release/npm',
|
|
71
80
|
'@semantic-release/github',
|
|
72
81
|
],
|
|
73
|
-
// Remove `null` and `undefined` options so they can be replaced with default ones
|
|
82
|
+
// Remove `null` and `undefined` options, so they can be replaced with default ones
|
|
74
83
|
...pickBy(options, (option) => !isNil(option)),
|
|
75
84
|
...(options.branches ? {branches: castArray(options.branches)} : {}),
|
|
76
85
|
};
|
|
@@ -82,9 +91,9 @@ module.exports = async (context, cliOptions) => {
|
|
|
82
91
|
debug('options values: %O', options);
|
|
83
92
|
|
|
84
93
|
return {options, plugins: await plugins({...context, options}, pluginsPath)};
|
|
85
|
-
}
|
|
94
|
+
}
|
|
86
95
|
|
|
87
96
|
async function pkgRepoUrl(options) {
|
|
88
|
-
const {packageJson} = (await
|
|
97
|
+
const {packageJson} = (await readPackageUp(options)) || {};
|
|
89
98
|
return packageJson && (isPlainObject(packageJson.repository) ? packageJson.repository.url : packageJson.repository);
|
|
90
99
|
}
|
package/lib/get-error.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import SemanticReleaseError from '@semantic-release/error';
|
|
2
|
+
import * as ERROR_DEFINITIONS from './definitions/errors.js';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export default (code, ctx = {}) => {
|
|
5
5
|
const {message, details} = ERROR_DEFINITIONS[code](ctx);
|
|
6
6
|
return new SemanticReleaseError(message, code, details);
|
|
7
|
-
}
|
|
7
|
+
}
|
package/lib/get-git-auth-url.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {format, parse} from 'node:url';
|
|
2
|
+
import {isNil} from 'lodash-es';
|
|
3
|
+
import hostedGitInfo from 'hosted-git-info';
|
|
4
|
+
import debugAuthUrl from 'debug';
|
|
5
|
+
import {verifyAuth} from './git.js';
|
|
6
|
+
|
|
7
|
+
const debug = debugAuthUrl('semantic-release:get-git-auth-url');
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Machinery to format a repository URL with the given credentials
|
|
@@ -57,7 +59,7 @@ async function ensureValidAuthUrl({cwd, env, branch}, authUrl) {
|
|
|
57
59
|
*
|
|
58
60
|
* @return {String} The formatted Git repository URL.
|
|
59
61
|
*/
|
|
60
|
-
|
|
62
|
+
export default async (context) => {
|
|
61
63
|
const {cwd, env, branch} = context;
|
|
62
64
|
const GIT_TOKENS = {
|
|
63
65
|
GIT_CREDENTIALS: undefined,
|
|
@@ -119,4 +121,4 @@ module.exports = async (context) => {
|
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
return repositoryUrl;
|
|
122
|
-
}
|
|
124
|
+
}
|
package/lib/get-last-release.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {isUndefined} from 'lodash-es';
|
|
2
|
+
import semver from 'semver';
|
|
3
|
+
import {isSameChannel, makeTag} from './utils.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Last release.
|
|
@@ -18,7 +18,7 @@ const {makeTag, isSameChannel} = require('./utils');
|
|
|
18
18
|
*
|
|
19
19
|
* - Filter out the branch tags that are not valid semantic version
|
|
20
20
|
* - Sort the versions
|
|
21
|
-
* -
|
|
21
|
+
* - Retrieve the highest version
|
|
22
22
|
*
|
|
23
23
|
* @param {Object} context semantic-release context.
|
|
24
24
|
* @param {Object} params Function parameters.
|
|
@@ -26,7 +26,7 @@ const {makeTag, isSameChannel} = require('./utils');
|
|
|
26
26
|
*
|
|
27
27
|
* @return {LastRelease} The last tagged release or empty object if none is found.
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
export default ({branch, options: {tagFormat}}, {before} = {}) => {
|
|
30
30
|
const [{version, gitTag, channels} = {}] = branch.tags
|
|
31
31
|
.filter(
|
|
32
32
|
(tag) =>
|
|
@@ -41,4 +41,4 @@ module.exports = ({branch, options: {tagFormat}}, {before} = {}) => {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
return {};
|
|
44
|
-
}
|
|
44
|
+
}
|
package/lib/get-logger.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import signale from 'signale';
|
|
2
|
+
import figures from 'figures';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const {Signale} = signale;
|
|
5
|
+
|
|
6
|
+
export default ({stdout, stderr}) =>
|
|
5
7
|
new Signale({
|
|
6
8
|
config: {displayTimestamp: true, underlineMessage: false, displayLabel: false},
|
|
7
9
|
disabled: false,
|
|
@@ -13,4 +15,4 @@ module.exports = ({stdout, stderr}) =>
|
|
|
13
15
|
log: {badge: figures.info, color: 'magenta', label: '', stream: [stdout]},
|
|
14
16
|
success: {badge: figures.tick, color: 'green', label: '', stream: [stdout]},
|
|
15
17
|
},
|
|
16
|
-
})
|
|
18
|
+
})
|
package/lib/get-next-version.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import semver from 'semver';
|
|
2
|
+
import {FIRST_RELEASE, FIRSTPRERELEASE} from './definitions/constants.js';
|
|
3
|
+
import {getLatestVersion, highest, isSameChannel, tagsToVersions} from './utils.js';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export default ({branch, nextRelease: {type, channel}, lastRelease, logger}) => {
|
|
6
6
|
let version;
|
|
7
7
|
if (lastRelease.version) {
|
|
8
8
|
const {major, minor, patch} = semver.parse(lastRelease.version);
|
|
@@ -32,4 +32,4 @@ module.exports = ({branch, nextRelease: {type, channel}, lastRelease, logger}) =
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
return version;
|
|
35
|
-
}
|
|
35
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {intersection, uniqBy} from 'lodash-es';
|
|
2
|
+
import semver from 'semver';
|
|
3
|
+
import semverDiff from 'semver-diff';
|
|
4
|
+
import getLastRelease from './get-last-release.js';
|
|
5
|
+
import {getLowerBound, makeTag} from './utils.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Find releases that have been merged from from a higher branch but not added on the channel of the current branch.
|
|
@@ -11,7 +11,7 @@ const {makeTag, getLowerBound} = require('./utils');
|
|
|
11
11
|
*
|
|
12
12
|
* @return {Array<Object>} Last release and next release to be added on the channel of the current branch.
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
export default (context) => {
|
|
15
15
|
const {
|
|
16
16
|
branch,
|
|
17
17
|
branches,
|
|
@@ -57,4 +57,4 @@ module.exports = (context) => {
|
|
|
57
57
|
},
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
}
|
|
60
|
+
}
|