Skip to content

Commit 673017f

Browse files
committed
style: prettier
1 parent bf717df commit 673017f

38 files changed

+12012
-16554
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
node-version:
16-
- '14.17'
16+
- "14.17"
1717
- 16
1818
os:
1919
- ubuntu-latest

README.md

Lines changed: 29 additions & 27 deletions
Large diffs are not rendered by default.

lib/add-channel.js

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,69 @@
1-
import debugFactory from 'debug';
1+
import debugFactory from "debug";
22

3-
import {RELEASE_NAME} from './definitions/constants.js';
4-
import parseGithubUrl from './parse-github-url.js';
5-
import resolveConfig from './resolve-config.js';
6-
import getClient from './get-client.js';
7-
import isPrerelease from './is-prerelease.js';
3+
import { RELEASE_NAME } from "./definitions/constants.js";
4+
import parseGithubUrl from "./parse-github-url.js";
5+
import resolveConfig from "./resolve-config.js";
6+
import getClient from "./get-client.js";
7+
import isPrerelease from "./is-prerelease.js";
88

9-
const debug = debugFactory('semantic-release:github');
9+
const debug = debugFactory("semantic-release:github");
1010

1111
export default async function addChannel(pluginConfig, context) {
1212
const {
13-
options: {repositoryUrl},
13+
options: { repositoryUrl },
1414
branch,
15-
nextRelease: {name, gitTag, notes},
15+
nextRelease: { name, gitTag, notes },
1616
logger,
1717
} = context;
18-
const {githubToken, githubUrl, githubApiPathPrefix, proxy} = resolveConfig(pluginConfig, context);
19-
const {owner, repo} = parseGithubUrl(repositoryUrl);
20-
const github = getClient({githubToken, githubUrl, githubApiPathPrefix, proxy});
18+
const { githubToken, githubUrl, githubApiPathPrefix, proxy } = resolveConfig(
19+
pluginConfig,
20+
context
21+
);
22+
const { owner, repo } = parseGithubUrl(repositoryUrl);
23+
const github = getClient({
24+
githubToken,
25+
githubUrl,
26+
githubApiPathPrefix,
27+
proxy,
28+
});
2129
let releaseId;
2230

23-
const release = {owner, repo, name, prerelease: isPrerelease(branch), tag_name: gitTag};
31+
const release = {
32+
owner,
33+
repo,
34+
name,
35+
prerelease: isPrerelease(branch),
36+
tag_name: gitTag,
37+
};
2438

25-
debug('release object: %O', release);
39+
debug("release object: %O", release);
2640

2741
try {
2842
({
29-
data: {id: releaseId},
30-
} = await github.repos.getReleaseByTag({owner, repo, tag: gitTag}));
43+
data: { id: releaseId },
44+
} = await github.repos.getReleaseByTag({ owner, repo, tag: gitTag }));
3145
} catch (error) {
3246
if (error.status === 404) {
33-
logger.log('There is no release for tag %s, creating a new one', gitTag);
47+
logger.log("There is no release for tag %s, creating a new one", gitTag);
3448

3549
const {
36-
data: {html_url: url},
37-
} = await github.repos.createRelease({...release, body: notes});
50+
data: { html_url: url },
51+
} = await github.repos.createRelease({ ...release, body: notes });
3852

39-
logger.log('Published GitHub release: %s', url);
40-
return {url, name: RELEASE_NAME};
53+
logger.log("Published GitHub release: %s", url);
54+
return { url, name: RELEASE_NAME };
4155
}
4256

4357
throw error;
4458
}
4559

46-
debug('release release_id: %o', releaseId);
60+
debug("release release_id: %o", releaseId);
4761

4862
const {
49-
data: {html_url: url},
50-
} = await github.repos.updateRelease({...release, release_id: releaseId});
63+
data: { html_url: url },
64+
} = await github.repos.updateRelease({ ...release, release_id: releaseId });
5165

52-
logger.log('Updated GitHub release: %s', url);
66+
logger.log("Updated GitHub release: %s", url);
5367

54-
return {url, name: RELEASE_NAME};
68+
return { url, name: RELEASE_NAME };
5569
}

lib/definitions/constants.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export const ISSUE_ID = '<!-- semantic-release:github -->';
1+
export const ISSUE_ID = "<!-- semantic-release:github -->";
22

3-
export const RELEASE_NAME = 'GitHub release';
3+
export const RELEASE_NAME = "GitHub release";

lib/definitions/errors.js

Lines changed: 76 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,153 +1,179 @@
1-
import {inspect} from 'node:util';
1+
import { inspect } from "node:util";
22

3-
import {isString} from 'lodash-es';
3+
import { isString } from "lodash-es";
44

5-
const HOMEPAGE = 'https://github.com/semantic-release/github';
5+
const HOMEPAGE = "https://github.com/semantic-release/github";
66

77
const stringify = (object) =>
8-
isString(object) ? object : inspect(object, {breakLength: Number.POSITIVE_INFINITY, depth: 2, maxArrayLength: 5});
8+
isString(object)
9+
? object
10+
: inspect(object, {
11+
breakLength: Number.POSITIVE_INFINITY,
12+
depth: 2,
13+
maxArrayLength: 5,
14+
});
915
const linkify = (file) => `${HOMEPAGE}/blob/master/${file}`;
1016

11-
export function EINVALIDASSETS({assets}) {
17+
export function EINVALIDASSETS({ assets }) {
1218
return {
13-
message: 'Invalid `assets` option.',
19+
message: "Invalid `assets` option.",
1420
details: `The [assets option](${linkify(
15-
'README.md#assets'
21+
"README.md#assets"
1622
)}) must be an \`Array\` of \`Strings\` or \`Objects\` with a \`path\` property.
1723
1824
Your configuration for the \`assets\` option is \`${stringify(assets)}\`.`,
1925
};
2026
}
2127

22-
export function EINVALIDSUCCESSCOMMENT({successComment}) {
28+
export function EINVALIDSUCCESSCOMMENT({ successComment }) {
2329
return {
24-
message: 'Invalid `successComment` option.',
30+
message: "Invalid `successComment` option.",
2531
details: `The [successComment option](${linkify(
26-
'README.md#successcomment'
32+
"README.md#successcomment"
2733
)}) if defined, must be a non empty \`String\`.
2834
29-
Your configuration for the \`successComment\` option is \`${stringify(successComment)}\`.`,
35+
Your configuration for the \`successComment\` option is \`${stringify(
36+
successComment
37+
)}\`.`,
3038
};
3139
}
3240

33-
export function EINVALIDFAILTITLE({failTitle}) {
41+
export function EINVALIDFAILTITLE({ failTitle }) {
3442
return {
35-
message: 'Invalid `failTitle` option.',
36-
details: `The [failTitle option](${linkify('README.md#failtitle')}) if defined, must be a non empty \`String\`.
43+
message: "Invalid `failTitle` option.",
44+
details: `The [failTitle option](${linkify(
45+
"README.md#failtitle"
46+
)}) if defined, must be a non empty \`String\`.
3747
38-
Your configuration for the \`failTitle\` option is \`${stringify(failTitle)}\`.`,
48+
Your configuration for the \`failTitle\` option is \`${stringify(
49+
failTitle
50+
)}\`.`,
3951
};
4052
}
4153

42-
export function EINVALIDFAILCOMMENT({failComment}) {
54+
export function EINVALIDFAILCOMMENT({ failComment }) {
4355
return {
44-
message: 'Invalid `failComment` option.',
45-
details: `The [failComment option](${linkify('README.md#failcomment')}) if defined, must be a non empty \`String\`.
56+
message: "Invalid `failComment` option.",
57+
details: `The [failComment option](${linkify(
58+
"README.md#failcomment"
59+
)}) if defined, must be a non empty \`String\`.
4660
47-
Your configuration for the \`failComment\` option is \`${stringify(failComment)}\`.`,
61+
Your configuration for the \`failComment\` option is \`${stringify(
62+
failComment
63+
)}\`.`,
4864
};
4965
}
5066

51-
export function EINVALIDLABELS({labels}) {
67+
export function EINVALIDLABELS({ labels }) {
5268
return {
53-
message: 'Invalid `labels` option.',
69+
message: "Invalid `labels` option.",
5470
details: `The [labels option](${linkify(
55-
'README.md#options'
71+
"README.md#options"
5672
)}) if defined, must be an \`Array\` of non empty \`String\`.
5773
5874
Your configuration for the \`labels\` option is \`${stringify(labels)}\`.`,
5975
};
6076
}
6177

62-
export function EINVALIDASSIGNEES({assignees}) {
78+
export function EINVALIDASSIGNEES({ assignees }) {
6379
return {
64-
message: 'Invalid `assignees` option.',
65-
details: `The [assignees option](${linkify('README.md#options')}) must be an \`Array\` of non empty \`Strings\`.
66-
67-
Your configuration for the \`assignees\` option is \`${stringify(assignees)}\`.`,
80+
message: "Invalid `assignees` option.",
81+
details: `The [assignees option](${linkify(
82+
"README.md#options"
83+
)}) must be an \`Array\` of non empty \`Strings\`.
84+
85+
Your configuration for the \`assignees\` option is \`${stringify(
86+
assignees
87+
)}\`.`,
6888
};
6989
}
7090

71-
export function EINVALIDRELEASEDLABELS({releasedLabels}) {
91+
export function EINVALIDRELEASEDLABELS({ releasedLabels }) {
7292
return {
73-
message: 'Invalid `releasedLabels` option.',
93+
message: "Invalid `releasedLabels` option.",
7494
details: `The [releasedLabels option](${linkify(
75-
'README.md#options'
95+
"README.md#options"
7696
)}) if defined, must be an \`Array\` of non empty \`String\`.
7797
78-
Your configuration for the \`releasedLabels\` option is \`${stringify(releasedLabels)}\`.`,
98+
Your configuration for the \`releasedLabels\` option is \`${stringify(
99+
releasedLabels
100+
)}\`.`,
79101
};
80102
}
81103

82-
export function EINVALIDADDRELEASES({addReleases}) {
104+
export function EINVALIDADDRELEASES({ addReleases }) {
83105
return {
84-
message: 'Invalid `addReleases` option.',
85-
details: `The [addReleases option](${linkify('README.md#options')}) if defined, must be one of \`false|top|bottom\`.
86-
87-
Your configuration for the \`addReleases\` option is \`${stringify(addReleases)}\`.`,
106+
message: "Invalid `addReleases` option.",
107+
details: `The [addReleases option](${linkify(
108+
"README.md#options"
109+
)}) if defined, must be one of \`false|top|bottom\`.
110+
111+
Your configuration for the \`addReleases\` option is \`${stringify(
112+
addReleases
113+
)}\`.`,
88114
};
89115
}
90116

91117
export function EINVALIDGITHUBURL() {
92118
return {
93-
message: 'The git repository URL is not a valid GitHub URL.',
119+
message: "The git repository URL is not a valid GitHub URL.",
94120
details: `The **semantic-release** \`repositoryUrl\` option must a valid GitHub URL with the format \`<GitHub_or_GHE_URL>/<owner>/<repo>.git\`.
95121
96122
By default the \`repositoryUrl\` option is retrieved from the \`repository\` property of your \`package.json\` or the [git origin url](https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes) of the repository cloned by your CI environment.`,
97123
};
98124
}
99125

100-
export function EINVALIDPROXY({proxy}) {
126+
export function EINVALIDPROXY({ proxy }) {
101127
return {
102-
message: 'Invalid `proxy` option.',
128+
message: "Invalid `proxy` option.",
103129
details: `The [proxy option](${linkify(
104-
'README.md#proxy'
130+
"README.md#proxy"
105131
)}) must be a \`String\` or an \`Objects\` with a \`host\` and a \`port\` property.
106132
107133
Your configuration for the \`proxy\` option is \`${stringify(proxy)}\`.`,
108134
};
109135
}
110136

111-
export function EMISSINGREPO({owner, repo}) {
137+
export function EMISSINGREPO({ owner, repo }) {
112138
return {
113139
message: `The repository ${owner}/${repo} doesn't exist.`,
114140
details: `The **semantic-release** \`repositoryUrl\` option must refer to your GitHub repository. The repository must be accessible with the [GitHub API](https://developer.github.com/v3).
115141
116142
By default the \`repositoryUrl\` option is retrieved from the \`repository\` property of your \`package.json\` or the [git origin url](https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes) of the repository cloned by your CI environment.
117143
118144
If you are using [GitHub Enterprise](https://enterprise.github.com) please make sure to configure the \`githubUrl\` and \`githubApiPathPrefix\` [options](${linkify(
119-
'README.md#options'
145+
"README.md#options"
120146
)}).`,
121147
};
122148
}
123149

124-
export function EGHNOPERMISSION({owner, repo}) {
150+
export function EGHNOPERMISSION({ owner, repo }) {
125151
return {
126152
message: `The GitHub token doesn't allow to push on the repository ${owner}/${repo}.`,
127153
details: `The user associated with the [GitHub token](${linkify(
128-
'README.md#github-authentication'
154+
"README.md#github-authentication"
129155
)}) configured in the \`GH_TOKEN\` or \`GITHUB_TOKEN\` environment variable must allows to push to the repository ${owner}/${repo}.
130156
131157
Please make sure the GitHub user associated with the token is an [owner](https://help.github.com/articles/permission-levels-for-a-user-account-repository/#owner-access-on-a-repository-owned-by-a-user-account) or a [collaborator](https://help.github.com/articles/permission-levels-for-a-user-account-repository/#collaborator-access-on-a-repository-owned-by-a-user-account) if the reposotory belong to a user account or has [write permissions](https://help.github.com/articles/managing-team-access-to-an-organization-repository) if the repository [belongs to an organization](https://help.github.com/articles/repository-permission-levels-for-an-organization).`,
132158
};
133159
}
134160

135-
export function EINVALIDGHTOKEN({owner, repo}) {
161+
export function EINVALIDGHTOKEN({ owner, repo }) {
136162
return {
137-
message: 'Invalid GitHub token.',
163+
message: "Invalid GitHub token.",
138164
details: `The [GitHub token](${linkify(
139-
'README.md#github-authentication'
165+
"README.md#github-authentication"
140166
)}) configured in the \`GH_TOKEN\` or \`GITHUB_TOKEN\` environment variable must be a valid [personal token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line) allowing to push to the repository ${owner}/${repo}.
141167
142168
Please make sure to set the \`GH_TOKEN\` or \`GITHUB_TOKEN\` environment variable in your CI with the exact value of the GitHub personal token.`,
143169
};
144170
}
145171

146-
export function ENOGHTOKEN({owner, repo}) {
172+
export function ENOGHTOKEN({ owner, repo }) {
147173
return {
148-
message: 'No GitHub token specified.',
174+
message: "No GitHub token specified.",
149175
details: `A [GitHub personal token](${linkify(
150-
'README.md#github-authentication'
176+
"README.md#github-authentication"
151177
)}) must be created and set in the \`GH_TOKEN\` or \`GITHUB_TOKEN\` environment variable on your CI environment.
152178
153179
Please make sure to create a [GitHub personal token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line) and to set it in the \`GH_TOKEN\` or \`GITHUB_TOKEN\` environment variable on your CI environment. The token must allow to push to the repository ${owner}/${repo}.`,

lib/definitions/rate-limit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Default exponential backoff configuration for retries.
33
*/
4-
export const RETRY_CONF = {retries: 3, factor: 2, minTimeout: 1000};
4+
export const RETRY_CONF = { retries: 3, factor: 2, minTimeout: 1000 };
55

66
/**
77
* Rate limit per API endpoints.

0 commit comments

Comments
 (0)