Skip to content

Commit 833e212

Browse files
committed
style: switched from xo to prettier
1 parent f094cb0 commit 833e212

File tree

8 files changed

+6422
-17108
lines changed

8 files changed

+6422
-17108
lines changed

README.md

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![npm next version](https://img.shields.io/npm/v/@semantic-release/release-notes-generator/next.svg)](https://www.npmjs.com/package/@semantic-release/release-notes-generator)
77

88
| Step | Description |
9-
|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
9+
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1010
| `generateNotes` | Generate release notes for the commits added since the last release with [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog). |
1111

1212
## Install
@@ -22,26 +22,33 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
2222
```json
2323
{
2424
"plugins": [
25-
["@semantic-release/commit-analyzer", {
26-
"preset": "angular",
27-
"parserOpts": {
28-
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"]
25+
[
26+
"@semantic-release/commit-analyzer",
27+
{
28+
"preset": "angular",
29+
"parserOpts": {
30+
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"]
31+
}
2932
}
30-
}],
31-
["@semantic-release/release-notes-generator", {
32-
"preset": "angular",
33-
"parserOpts": {
34-
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"]
35-
},
36-
"writerOpts": {
37-
"commitsSort": ["subject", "scope"]
33+
],
34+
[
35+
"@semantic-release/release-notes-generator",
36+
{
37+
"preset": "angular",
38+
"parserOpts": {
39+
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"]
40+
},
41+
"writerOpts": {
42+
"commitsSort": ["subject", "scope"]
43+
}
3844
}
39-
}]
45+
]
4046
]
4147
}
4248
```
4349

4450
With this example:
51+
4552
- the commits that contains `BREAKING CHANGE`, `BREAKING CHANGES` or `BREAKING` in their body will be considered breaking changes (by default the [angular preset](https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog-angular/index.js#L14) checks only for `BREAKING CHANGE` and `BREAKING CHANGES`)
4653
- the commits will be sorted in the changelog by `subject` then `scope` (by default the [angular preset](https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog-angular/index.js#L90) sort the commits in the changelog by `scope` then `subject`)
4754

@@ -50,7 +57,7 @@ With this example:
5057
### Options
5158

5259
| Option | Description | Default |
53-
|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
60+
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
5461
| `preset` | [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) preset (possible values: [`angular`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular), [`atom`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-atom), [`codemirror`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-codemirror), [`ember`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-ember), [`eslint`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-eslint), [`express`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-express), [`jquery`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-jquery), [`jshint`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-jshint), [`conventionalcommits`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-conventionalcommits)). | [`angular`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular) |
5562
| `config` | NPM package name of a custom [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) preset. | - |
5663
| `parserOpts` | Additional [conventional-commits-parser](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser#conventionalcommitsparseroptions) options that will extends the ones loaded by `preset` or `config`. This is convenient to use a [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) preset with some customizations without having to create a new module. | - |

index.js

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { format } from 'url';
2-
import { find, merge } from 'lodash-es';
3-
import getStream from 'get-stream';
4-
import intoStream from 'into-stream';
5-
import { sync as parser } from 'conventional-commits-parser';
6-
import writer from './wrappers/conventional-changelog-writer.js';
7-
import filter from 'conventional-commits-filter';
8-
import {readPackageUp} from 'read-pkg-up';
9-
import debugFactory from 'debug';
10-
import loadChangelogConfig from './lib/load-changelog-config.js';
11-
import HOSTS_CONFIG from './lib/hosts-config.js';
1+
import { format } from "url";
2+
import { find, merge } from "lodash-es";
3+
import getStream from "get-stream";
4+
import intoStream from "into-stream";
5+
import { sync as parser } from "conventional-commits-parser";
6+
import writer from "./wrappers/conventional-changelog-writer.js";
7+
import filter from "conventional-commits-filter";
8+
import { readPackageUp } from "read-pkg-up";
9+
import debugFactory from "debug";
10+
import loadChangelogConfig from "./lib/load-changelog-config.js";
11+
import HOSTS_CONFIG from "./lib/hosts-config.js";
1212

13-
const debug = debugFactory('semantic-release:release-notes-generator');
13+
const debug = debugFactory("semantic-release:release-notes-generator");
1414

1515
/**
1616
* Generate the changelog for all the commits in `options.commits`.
@@ -29,64 +29,64 @@ const debug = debugFactory('semantic-release:release-notes-generator');
2929
* @returns {String} The changelog for all the commits in `context.commits`.
3030
*/
3131
export async function generateNotes(pluginConfig, context) {
32-
const {commits, lastRelease, nextRelease, options, cwd} = context;
33-
const repositoryUrl = options.repositoryUrl.replace(/\.git$/i, '');
34-
const {parserOpts, writerOpts} = await loadChangelogConfig(pluginConfig, context);
32+
const { commits, lastRelease, nextRelease, options, cwd } = context;
33+
const repositoryUrl = options.repositoryUrl.replace(/\.git$/i, "");
34+
const { parserOpts, writerOpts } = await loadChangelogConfig(pluginConfig, context);
3535

3636
const [match, auth, host, path] = /^(?!.+:\/\/)(?:(?<auth>.*)@)?(?<host>.*?):(?<path>.*)$/.exec(repositoryUrl) || [];
37-
let {hostname, port, pathname, protocol} = new URL(
38-
match ? `ssh://${auth ? `${auth}@` : ''}${host}/${path}` : repositoryUrl
37+
let { hostname, port, pathname, protocol } = new URL(
38+
match ? `ssh://${auth ? `${auth}@` : ""}${host}/${path}` : repositoryUrl
3939
);
40-
port = protocol.includes('ssh') ? '' : port;
41-
protocol = protocol && /http[^s]/.test(protocol) ? 'http' : 'https';
40+
port = protocol.includes("ssh") ? "" : port;
41+
protocol = protocol && /http[^s]/.test(protocol) ? "http" : "https";
4242
const [, owner, repository] = /^\/(?<owner>[^/]+)?\/?(?<repository>.+)?$/.exec(pathname);
4343

44-
const {issue, commit, referenceActions, issuePrefixes} =
44+
const { issue, commit, referenceActions, issuePrefixes } =
4545
find(HOSTS_CONFIG, (conf) => conf.hostname === hostname) || HOSTS_CONFIG.default;
4646
const parsedCommits = filter(
4747
commits
48-
.filter(({message, hash}) => {
48+
.filter(({ message, hash }) => {
4949
if (!message.trim()) {
50-
debug('Skip commit %s with empty message', hash);
50+
debug("Skip commit %s with empty message", hash);
5151
return false;
5252
}
5353

5454
return true;
5555
})
5656
.map((rawCommit) => ({
5757
...rawCommit,
58-
...parser(rawCommit.message, {referenceActions, issuePrefixes, ...parserOpts}),
58+
...parser(rawCommit.message, { referenceActions, issuePrefixes, ...parserOpts }),
5959
}))
6060
);
6161
const previousTag = lastRelease.gitTag || lastRelease.gitHead;
6262
const currentTag = nextRelease.gitTag || nextRelease.gitHead;
63-
const {host: hostConfig, linkCompare, linkReferences, commit: commitConfig, issue: issueConfig} = pluginConfig;
63+
const { host: hostConfig, linkCompare, linkReferences, commit: commitConfig, issue: issueConfig } = pluginConfig;
6464
const changelogContext = merge(
6565
{
6666
version: nextRelease.version,
67-
host: format({protocol, hostname, port}),
67+
host: format({ protocol, hostname, port }),
6868
owner,
6969
repository,
7070
previousTag,
7171
currentTag,
7272
linkCompare: currentTag && previousTag,
7373
issue,
7474
commit,
75-
packageData: ((await readPackageUp({normalize: false, cwd})) || {}).packageJson,
75+
packageData: ((await readPackageUp({ normalize: false, cwd })) || {}).packageJson,
7676
},
77-
{host: hostConfig, linkCompare, linkReferences, commit: commitConfig, issue: issueConfig}
77+
{ host: hostConfig, linkCompare, linkReferences, commit: commitConfig, issue: issueConfig }
7878
);
7979

80-
debug('version: %o', changelogContext.version);
81-
debug('host: %o', changelogContext.hostname);
82-
debug('owner: %o', changelogContext.owner);
83-
debug('repository: %o', changelogContext.repository);
84-
debug('previousTag: %o', changelogContext.previousTag);
85-
debug('currentTag: %o', changelogContext.currentTag);
86-
debug('host: %o', changelogContext.host);
87-
debug('linkReferences: %o', changelogContext.linkReferences);
88-
debug('issue: %o', changelogContext.issue);
89-
debug('commit: %o', changelogContext.commit);
80+
debug("version: %o", changelogContext.version);
81+
debug("host: %o", changelogContext.hostname);
82+
debug("owner: %o", changelogContext.owner);
83+
debug("repository: %o", changelogContext.repository);
84+
debug("previousTag: %o", changelogContext.previousTag);
85+
debug("currentTag: %o", changelogContext.currentTag);
86+
debug("host: %o", changelogContext.host);
87+
debug("linkReferences: %o", changelogContext.linkReferences);
88+
debug("issue: %o", changelogContext.issue);
89+
debug("commit: %o", changelogContext.commit);
9090

9191
return getStream(intoStream.object(parsedCommits).pipe(writer(changelogContext, writerOpts)));
9292
}

lib/hosts-config.js

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
export default {
22
github: {
3-
hostname: 'github.com',
4-
issue: 'issues',
5-
commit: 'commit',
6-
referenceActions: ['close', 'closes', 'closed', 'fix', 'fixes', 'fixed', 'resolve', 'resolves', 'resolved'],
7-
issuePrefixes: ['#', 'gh-'],
3+
hostname: "github.com",
4+
issue: "issues",
5+
commit: "commit",
6+
referenceActions: ["close", "closes", "closed", "fix", "fixes", "fixed", "resolve", "resolves", "resolved"],
7+
issuePrefixes: ["#", "gh-"],
88
},
99
bitbucket: {
10-
hostname: 'bitbucket.org',
11-
issue: 'issue',
12-
commit: 'commits',
10+
hostname: "bitbucket.org",
11+
issue: "issue",
12+
commit: "commits",
1313
referenceActions: [
14-
'close',
15-
'closes',
16-
'closed',
17-
'closing',
18-
'fix',
19-
'fixes',
20-
'fixed',
21-
'fixing',
22-
'resolve',
23-
'resolves',
24-
'resolved',
25-
'resolving',
14+
"close",
15+
"closes",
16+
"closed",
17+
"closing",
18+
"fix",
19+
"fixes",
20+
"fixed",
21+
"fixing",
22+
"resolve",
23+
"resolves",
24+
"resolved",
25+
"resolving",
2626
],
27-
issuePrefixes: ['#'],
27+
issuePrefixes: ["#"],
2828
},
2929
gitlab: {
30-
hostname: 'gitlab.com',
31-
issue: 'issues',
32-
commit: 'commit',
33-
referenceActions: ['close', 'closes', 'closed', 'closing', 'fix', 'fixes', 'fixed', 'fixing'],
34-
issuePrefixes: ['#'],
30+
hostname: "gitlab.com",
31+
issue: "issues",
32+
commit: "commit",
33+
referenceActions: ["close", "closes", "closed", "closing", "fix", "fixes", "fixed", "fixing"],
34+
issuePrefixes: ["#"],
3535
},
3636
default: {
37-
issue: 'issues',
38-
commit: 'commit',
37+
issue: "issues",
38+
commit: "commit",
3939
referenceActions: [
40-
'close',
41-
'closes',
42-
'closed',
43-
'closing',
44-
'fix',
45-
'fixes',
46-
'fixed',
47-
'fixing',
48-
'resolve',
49-
'resolves',
50-
'resolved',
51-
'resolving',
40+
"close",
41+
"closes",
42+
"closed",
43+
"closing",
44+
"fix",
45+
"fixes",
46+
"fixed",
47+
"fixing",
48+
"resolve",
49+
"resolves",
50+
"resolved",
51+
"resolving",
5252
],
53-
issuePrefixes: ['#', 'gh-'],
53+
issuePrefixes: ["#", "gh-"],
5454
},
5555
};

0 commit comments

Comments
 (0)