Skip to content

Commit 834bde6

Browse files
committed
fix(package): update got to version 10.0.1
1 parent 2f602e0 commit 834bde6

File tree

4 files changed

+16
-20
lines changed

4 files changed

+16
-20
lines changed

lib/publish.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = async (pluginConfig, context) => {
2222
const repoId = getRepoId(context, gitlabUrl, repositoryUrl);
2323
const encodedRepoId = encodeURIComponent(repoId);
2424
const encodedGitTag = encodeURIComponent(gitTag);
25-
const apiOptions = {json: true, headers: {'PRIVATE-TOKEN': gitlabToken}};
25+
const apiOptions = {headers: {'PRIVATE-TOKEN': gitlabToken}};
2626

2727
debug('repoId: %o', repoId);
2828
debug('release name: %o', gitTag);
@@ -56,12 +56,9 @@ module.exports = async (pluginConfig, context) => {
5656
// Uploaded assets to the project
5757
const form = new FormData();
5858
form.append('file', createReadStream(file));
59-
const {body} = await got.post(urlJoin(gitlabApiUrl, `/projects/${encodedRepoId}/uploads`), {
60-
...apiOptions,
61-
json: false,
62-
body: form,
63-
});
64-
const {url, alt} = JSON.parse(body);
59+
const {url, alt} = await got
60+
.post(urlJoin(gitlabApiUrl, `/projects/${encodedRepoId}/uploads`), {...apiOptions, body: form})
61+
.json();
6562

6663
assetsList.push({label, alt, url});
6764

@@ -73,7 +70,7 @@ module.exports = async (pluginConfig, context) => {
7370
debug('Update git tag %o with commit %o and release description', gitTag, gitHead);
7471
await got.post(urlJoin(gitlabApiUrl, `/projects/${encodedRepoId}/repository/tags/${encodedGitTag}/release`), {
7572
...apiOptions,
76-
body: {tag_name: gitTag, description: notes}, // eslint-disable-line camelcase
73+
json: {tag_name: gitTag, description: notes}, // eslint-disable-line camelcase
7774
});
7875

7976
if (assetsList.length > 0) {
@@ -82,7 +79,7 @@ module.exports = async (pluginConfig, context) => {
8279
debug('Add link to asset %o', label || alt);
8380
return got.post(urlJoin(gitlabApiUrl, `/projects/${encodedRepoId}/releases/${encodedGitTag}/assets/links`), {
8481
...apiOptions,
85-
body: {name: label || alt, url: urlJoin(gitlabUrl, repoId, url)},
82+
json: {name: label || alt, url: urlJoin(gitlabUrl, repoId, url)},
8683
});
8784
})
8885
);

lib/verify.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,20 @@ module.exports = async (pluginConfig, context) => {
4848

4949
try {
5050
({
51-
body: {
52-
permissions: {project_access: projectAccess, group_access: groupAccess},
53-
},
54-
} = await got.get(urlJoin(gitlabApiUrl, `/projects/${encodeURIComponent(repoId)}`), {
55-
json: true,
56-
headers: {'Private-Token': gitlabToken},
57-
}));
51+
permissions: {project_access: projectAccess, group_access: groupAccess},
52+
} = await got
53+
.get(urlJoin(gitlabApiUrl, `/projects/${encodeURIComponent(repoId)}`), {
54+
headers: {'PRIVATE-TOKEN': gitlabToken},
55+
})
56+
.json());
5857

5958
if (!((projectAccess && projectAccess.access_level >= 30) || (groupAccess && groupAccess.access_level >= 30))) {
6059
errors.push(getError('EGLNOPERMISSION', {repoId}));
6160
}
6261
} catch (error) {
63-
if (error.statusCode === 401) {
62+
if (error.response.statusCode === 401) {
6463
errors.push(getError('EINVALIDGLTOKEN', {repoId}));
65-
} else if (error.statusCode === 404) {
64+
} else if (error.response.statusCode === 404) {
6665
errors.push(getError('EMISSINGREPO', {repoId}));
6766
} else {
6867
throw error;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"form-data": "^3.0.0",
2828
"fs-extra": "^8.0.0",
2929
"globby": "^10.0.0",
30-
"got": "^9.1.0",
30+
"got": "^10.0.1",
3131
"lodash": "^4.17.11",
3232
"parse-path": "^4.0.0",
3333
"url-join": "^4.0.0"

test/verify.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,6 @@ test.serial('Throw error if GitLab API return any other errors', async t => {
516516
verify({}, {env, options: {repositoryUrl: `https://gitlab.com:${owner}/${repo}.git`}, logger: t.context.logger})
517517
);
518518

519-
t.is(error.statusCode, 500);
519+
t.is(error.response.statusCode, 500);
520520
t.true(gitlab.isDone());
521521
});

0 commit comments

Comments
 (0)