semantic-release 19.0.4 → 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.
@@ -1,7 +1,10 @@
1
- const {inspect} = require('util');
2
- const {toLower, isString, trim} = require('lodash');
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
- module.exports = {
14
- ENOGITREPO: ({cwd}) => ({
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
- ENOREPOURL: () => ({
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
- EGITNOPERMISSION: ({options: {repositoryUrl}, branch: {name}}) => ({
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
- 'docs/usage/ci-configuration.md#authentication'
41
- )})`,
42
- }),
43
- EINVALIDTAGFORMAT: ({options: {tagFormat}}) => ({
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
- ETAGNOVERSION: ({options: {tagFormat}}) => ({
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
- EPLUGINCONF: ({type, required, pluginConf}) => ({
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
- EPLUGINSCONF: ({plugin}) => ({
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 definions. A plugin definition is an npm module name, optionally wrapped in an array with an object.
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
- EPLUGIN: ({pluginName, type}) => ({
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
- EANALYZECOMMITSOUTPUT: ({result, pluginName}) => ({
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
- EGENERATENOTESOUTPUT: ({result, pluginName}) => ({
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
- EPUBLISHOUTPUT: ({result, pluginName}) => ({
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
- EADDCHANNELOUTPUT: ({result, pluginName}) => ({
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
- EINVALIDBRANCH: ({branch}) => ({
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
- EINVALIDBRANCHNAME: ({branch}) => ({
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
- EDUPLICATEBRANCHES: ({duplicates}) => ({
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
- EMAINTENANCEBRANCH: ({branch}) => ({
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
- EMAINTENANCEBRANCHES: ({branches}) => ({
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
- ERELEASEBRANCHES: ({branches}) => ({
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
- EPRERELEASEBRANCH: ({branch}) => ({
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
- EPRERELEASEBRANCHES: ({branches}) => ({
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
- EINVALIDNEXTVERSION: ({nextRelease: {version}, branch: {name, range}, commits, validBranches}) => ({
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
- commits.length > 1 ? 'Those commits' : 'This commit'
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
- EINVALIDMAINTENANCEMERGE: ({nextRelease: {channel, gitTag, version}, branch: {mergeRange, name}}) => ({
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
- const {isString, isPlainObject} = require('lodash');
4
- const {getGitHead} = require('../git');
5
- const hideSensitive = require('../hide-sensitive');
6
- const {hideSensitiveValues} = require('../utils');
7
- const {RELEASE_TYPE, RELEASE_NOTES_SEPARATOR} = require('./constants');
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
- module.exports = {
9
+ export default {
10
10
  verifyConditions: {
11
11
  required: false,
12
12
  dryRun: true,
@@ -1,5 +1,7 @@
1
- const debug = require('debug')('semantic-release:get-commits');
2
- const {getCommits} = require('./git');
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
- module.exports = async ({cwd, env, lastRelease: {gitHead: from}, nextRelease: {gitHead: to = 'HEAD'} = {}, logger}) => {
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
- const {castArray, pickBy, isNil, isString, isPlainObject} = require('lodash');
2
- const readPkgUp = require('read-pkg-up');
3
- const {cosmiconfig} = require('cosmiconfig');
4
- const resolveFrom = require('resolve-from');
5
- const debug = require('debug')('semantic-release:config');
6
- const {repoUrl} = require('./git');
7
- const PLUGINS_DEFINITIONS = require('./definitions/plugins');
8
- const plugins = require('./plugins');
9
- const {validatePlugin, parseConfig} = require('./plugins/utils');
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
- module.exports = async (context, cliOptions) => {
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((result, extendPath) => {
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 relatively to the config file
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 readPkgUp(options)) || {};
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
- const SemanticReleaseError = require('@semantic-release/error');
2
- const ERROR_DEFINITIONS = require('./definitions/errors');
1
+ import SemanticReleaseError from '@semantic-release/error';
2
+ import * as ERROR_DEFINITIONS from './definitions/errors.js';
3
3
 
4
- module.exports = (code, ctx = {}) => {
4
+ export default (code, ctx = {}) => {
5
5
  const {message, details} = ERROR_DEFINITIONS[code](ctx);
6
6
  return new SemanticReleaseError(message, code, details);
7
- };
7
+ }
@@ -1,8 +1,10 @@
1
- const {parse, format} = require('url'); // eslint-disable-line node/no-deprecated-api
2
- const {isNil} = require('lodash');
3
- const hostedGitInfo = require('hosted-git-info');
4
- const {verifyAuth} = require('./git');
5
- const debug = require('debug')('semantic-release:get-git-auth-url');
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
- module.exports = async (context) => {
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
+ }
@@ -1,6 +1,6 @@
1
- const {isUndefined} = require('lodash');
2
- const semver = require('semver');
3
- const {makeTag, isSameChannel} = require('./utils');
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
- * - Retrive the highest version
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
- module.exports = ({branch, options: {tagFormat}}, {before} = {}) => {
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
- const {Signale} = require('signale');
2
- const figures = require('figures');
1
+ import signale from 'signale';
2
+ import figures from 'figures';
3
3
 
4
- module.exports = ({stdout, stderr}) =>
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
+ })
@@ -1,8 +1,8 @@
1
- const semver = require('semver');
2
- const {FIRST_RELEASE, FIRSTPRERELEASE} = require('./definitions/constants');
3
- const {isSameChannel, getLatestVersion, tagsToVersions, highest} = require('./utils');
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
- module.exports = ({branch, nextRelease: {type, channel}, lastRelease, logger}) => {
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
- const {uniqBy, intersection} = require('lodash');
2
- const semver = require('semver');
3
- const semverDiff = require('semver-diff');
4
- const getLastRelease = require('./get-last-release');
5
- const {makeTag, getLowerBound} = require('./utils');
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
- module.exports = (context) => {
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
+ }