release-it 14.9.0 → 14.10.0
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.
|
@@ -19,7 +19,8 @@ const DEFAULT_RETRY_MIN_TIMEOUT = 1000;
|
|
|
19
19
|
const parseErrormsg = err => {
|
|
20
20
|
let msg = err;
|
|
21
21
|
if (err instanceof Error) {
|
|
22
|
-
const { status, message
|
|
22
|
+
const { status, message } = err;
|
|
23
|
+
const { headers } = err.response;
|
|
23
24
|
msg = `${_.get(headers, 'status', status)} (${message})`;
|
|
24
25
|
}
|
|
25
26
|
return msg;
|
|
@@ -259,6 +260,7 @@ class GitHub extends Release {
|
|
|
259
260
|
uploadAssets() {
|
|
260
261
|
const { assets } = this.options;
|
|
261
262
|
const { isReleased } = this.getContext();
|
|
263
|
+
const context = this.config.getContext();
|
|
262
264
|
const { isDryRun } = this.config;
|
|
263
265
|
|
|
264
266
|
this.log.exec('octokit repos.uploadReleaseAssets', assets, { isDryRun });
|
|
@@ -267,7 +269,9 @@ class GitHub extends Release {
|
|
|
267
269
|
return true;
|
|
268
270
|
}
|
|
269
271
|
|
|
270
|
-
|
|
272
|
+
const patterns = _.castArray(assets).map(pattern => format(pattern, context));
|
|
273
|
+
|
|
274
|
+
return globby(patterns).then(files => {
|
|
271
275
|
if (!files.length) {
|
|
272
276
|
this.log.warn(`octokit repos.uploadReleaseAssets: did not find "${assets}" relative to ${process.cwd()}`);
|
|
273
277
|
}
|
|
@@ -3,6 +3,7 @@ const path = require('path');
|
|
|
3
3
|
const got = require('got');
|
|
4
4
|
const globby = require('globby');
|
|
5
5
|
const FormData = require('form-data');
|
|
6
|
+
const _ = require('lodash');
|
|
6
7
|
const Release = require('../GitRelease');
|
|
7
8
|
const { format, e } = require('../../util');
|
|
8
9
|
const prompts = require('./prompts');
|
|
@@ -195,6 +196,7 @@ class GitLab extends Release {
|
|
|
195
196
|
uploadAssets() {
|
|
196
197
|
const { assets } = this.options;
|
|
197
198
|
const { isDryRun } = this.config;
|
|
199
|
+
const context = this.config.getContext();
|
|
198
200
|
|
|
199
201
|
this.log.exec('gitlab releases#uploadAssets', assets, { isDryRun });
|
|
200
202
|
|
|
@@ -202,7 +204,9 @@ class GitLab extends Release {
|
|
|
202
204
|
return noop;
|
|
203
205
|
}
|
|
204
206
|
|
|
205
|
-
|
|
207
|
+
const patterns = _.castArray(assets).map(pattern => format(pattern, context));
|
|
208
|
+
|
|
209
|
+
return globby(patterns).then(files => {
|
|
206
210
|
if (!files.length) {
|
|
207
211
|
this.log.warn(`gitlab releases#uploadAssets: could not find "${assets}" relative to ${process.cwd()}`);
|
|
208
212
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "release-it",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.10.0",
|
|
4
4
|
"description": "Generic CLI tool to automate versioning and package publishing related tasks.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"build",
|
|
@@ -58,24 +58,24 @@
|
|
|
58
58
|
"license": "MIT",
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@iarna/toml": "2.2.5",
|
|
61
|
-
"@octokit/rest": "18.
|
|
61
|
+
"@octokit/rest": "18.6.0",
|
|
62
62
|
"async-retry": "1.3.1",
|
|
63
63
|
"chalk": "4.1.1",
|
|
64
64
|
"cosmiconfig": "7.0.0",
|
|
65
65
|
"debug": "4.3.1",
|
|
66
66
|
"deprecated-obj": "2.0.0",
|
|
67
|
-
"execa": "5.
|
|
67
|
+
"execa": "5.1.1",
|
|
68
68
|
"find-up": "5.0.0",
|
|
69
69
|
"form-data": "4.0.0",
|
|
70
70
|
"git-url-parse": "11.4.4",
|
|
71
|
-
"globby": "11.0.
|
|
71
|
+
"globby": "11.0.4",
|
|
72
72
|
"got": "11.8.2",
|
|
73
73
|
"import-cwd": "3.0.0",
|
|
74
|
-
"inquirer": "8.1.
|
|
74
|
+
"inquirer": "8.1.1",
|
|
75
75
|
"is-ci": "3.0.0",
|
|
76
76
|
"lodash": "4.17.21",
|
|
77
|
-
"mime-types": "2.1.
|
|
78
|
-
"ora": "5.4.
|
|
77
|
+
"mime-types": "2.1.31",
|
|
78
|
+
"ora": "5.4.1",
|
|
79
79
|
"os-name": "4.0.0",
|
|
80
80
|
"parse-json": "5.2.0",
|
|
81
81
|
"semver": "7.3.5",
|
|
@@ -87,22 +87,22 @@
|
|
|
87
87
|
"yargs-parser": "20.2.7"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
|
-
"@octokit/request-error": "2.0
|
|
90
|
+
"@octokit/request-error": "2.1.0",
|
|
91
91
|
"ava": "3.15.0",
|
|
92
92
|
"codecov": "3.8.2",
|
|
93
|
-
"eslint": "7.
|
|
93
|
+
"eslint": "7.29.0",
|
|
94
94
|
"eslint-config-prettier": "8.3.0",
|
|
95
95
|
"eslint-plugin-ava": "12.0.0",
|
|
96
|
-
"eslint-plugin-import": "2.23.
|
|
96
|
+
"eslint-plugin-import": "2.23.4",
|
|
97
97
|
"eslint-plugin-prettier": "3.4.0",
|
|
98
98
|
"markdown-toc": "1.2.0",
|
|
99
|
-
"mock-fs": "
|
|
99
|
+
"mock-fs": "5.0.0",
|
|
100
100
|
"mock-stdio": "1.0.3",
|
|
101
|
-
"nock": "13.0
|
|
101
|
+
"nock": "13.1.0",
|
|
102
102
|
"nyc": "15.1.0",
|
|
103
|
-
"prettier": "2.3.
|
|
103
|
+
"prettier": "2.3.1",
|
|
104
104
|
"proxyquire": "2.1.3",
|
|
105
|
-
"sinon": "
|
|
105
|
+
"sinon": "11.1.1",
|
|
106
106
|
"strip-ansi": "6.0.0"
|
|
107
107
|
},
|
|
108
108
|
"engines": {
|
package/test/github.js
CHANGED
|
@@ -16,6 +16,7 @@ const tokenRef = 'GITHUB_TOKEN';
|
|
|
16
16
|
const pushRepo = 'git://github.com:user/repo';
|
|
17
17
|
const host = 'github.com';
|
|
18
18
|
const git = { changelog: null };
|
|
19
|
+
const requestErrorOptions = { request: { url: '', headers: {} }, response: { headers: {} } };
|
|
19
20
|
|
|
20
21
|
test.serial('should validate token', async t => {
|
|
21
22
|
const tokenRef = 'MY_GITHUB_TOKEN';
|
|
@@ -34,7 +35,6 @@ test.serial('should validate token', async t => {
|
|
|
34
35
|
});
|
|
35
36
|
|
|
36
37
|
test('should release and upload assets', async t => {
|
|
37
|
-
const asset = 'file1';
|
|
38
38
|
const options = {
|
|
39
39
|
git,
|
|
40
40
|
github: {
|
|
@@ -43,7 +43,7 @@ test('should release and upload assets', async t => {
|
|
|
43
43
|
release: true,
|
|
44
44
|
releaseName: 'Release ${tagName}',
|
|
45
45
|
releaseNotes: 'echo Custom notes',
|
|
46
|
-
assets:
|
|
46
|
+
assets: 'test/resources/file-v${version}.txt'
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
const github = factory(GitHub, { options });
|
|
@@ -53,7 +53,7 @@ test('should release and upload assets', async t => {
|
|
|
53
53
|
interceptAuthentication();
|
|
54
54
|
interceptCollaborator();
|
|
55
55
|
interceptCreate({ body: { tag_name: '2.0.2', name: 'Release 2.0.2', body: 'Custom notes' } });
|
|
56
|
-
interceptAsset({ body:
|
|
56
|
+
interceptAsset({ body: '*' });
|
|
57
57
|
|
|
58
58
|
await runTasks(github);
|
|
59
59
|
|
|
@@ -225,7 +225,7 @@ test('should throw for unauthenticated user', async t => {
|
|
|
225
225
|
const options = { github: { tokenRef, pushRepo, host } };
|
|
226
226
|
const github = factory(GitHub, { options });
|
|
227
227
|
const stub = sinon.stub(github.client.users, 'getAuthenticated');
|
|
228
|
-
stub.throws(new RequestError('Bad credentials', 401,
|
|
228
|
+
stub.throws(new RequestError('Bad credentials', 401, requestErrorOptions));
|
|
229
229
|
|
|
230
230
|
await t.throwsAsync(runTasks(github), {
|
|
231
231
|
message: /^Could not authenticate with GitHub using environment variable "GITHUB_TOKEN"/
|
|
@@ -240,7 +240,7 @@ test('should throw for non-collaborator', async t => {
|
|
|
240
240
|
const options = { github: { tokenRef, pushRepo, host } };
|
|
241
241
|
const github = factory(GitHub, { options });
|
|
242
242
|
const stub = sinon.stub(github.client.repos, 'checkCollaborator');
|
|
243
|
-
stub.throws(new RequestError('HttpError', 401,
|
|
243
|
+
stub.throws(new RequestError('HttpError', 401, requestErrorOptions));
|
|
244
244
|
|
|
245
245
|
await t.throwsAsync(runTasks(github), { message: /^User john is not a collaborator for user\/repo/ });
|
|
246
246
|
|
|
@@ -271,7 +271,7 @@ test.serial('should skip authentication and collaborator checks when running on
|
|
|
271
271
|
test('should handle octokit client error (without retries)', async t => {
|
|
272
272
|
const github = factory(GitHub, { options: { github: { tokenRef, pushRepo, host } } });
|
|
273
273
|
const stub = sinon.stub(github.client.repos, 'createRelease');
|
|
274
|
-
stub.throws(new RequestError('Not found', 404,
|
|
274
|
+
stub.throws(new RequestError('Not found', 404, requestErrorOptions));
|
|
275
275
|
interceptAuthentication();
|
|
276
276
|
interceptCollaborator();
|
|
277
277
|
|
|
@@ -285,7 +285,7 @@ test('should handle octokit client error (with retries)', async t => {
|
|
|
285
285
|
const options = { github: { tokenRef, pushRepo, host, retryMinTimeout: 0 } };
|
|
286
286
|
const github = factory(GitHub, { options });
|
|
287
287
|
const stub = sinon.stub(github.client.repos, 'createRelease');
|
|
288
|
-
stub.throws(new RequestError('Request failed', 500,
|
|
288
|
+
stub.throws(new RequestError('Request failed', 500, requestErrorOptions));
|
|
289
289
|
interceptAuthentication();
|
|
290
290
|
interceptCollaborator();
|
|
291
291
|
|
|
@@ -310,7 +310,7 @@ test('should not call octokit client in dry run', async t => {
|
|
|
310
310
|
const { isReleased, releaseUrl } = github.getContext();
|
|
311
311
|
t.true(isReleased);
|
|
312
312
|
t.is(releaseUrl, 'https://github.com/user/repo/releases/tag/v1.0.1');
|
|
313
|
-
spy.restore();
|
|
313
|
+
spy.get.restore();
|
|
314
314
|
exec.restore();
|
|
315
315
|
});
|
|
316
316
|
|
package/test/gitlab.js
CHANGED
|
@@ -48,7 +48,6 @@ test.serial('should support CI Job token header', async t => {
|
|
|
48
48
|
|
|
49
49
|
test.serial('should upload assets and release', async t => {
|
|
50
50
|
const pushRepo = 'https://gitlab.com/user/repo';
|
|
51
|
-
const asset = 'file1';
|
|
52
51
|
const options = {
|
|
53
52
|
git: { pushRepo },
|
|
54
53
|
gitlab: {
|
|
@@ -56,7 +55,7 @@ test.serial('should upload assets and release', async t => {
|
|
|
56
55
|
release: true,
|
|
57
56
|
releaseName: 'Release ${version}',
|
|
58
57
|
releaseNotes: 'echo Custom notes',
|
|
59
|
-
assets:
|
|
58
|
+
assets: 'test/resources/file-v${version}.txt'
|
|
60
59
|
}
|
|
61
60
|
};
|
|
62
61
|
const gitlab = factory(GitLab, { options });
|
|
@@ -73,8 +72,8 @@ test.serial('should upload assets and release', async t => {
|
|
|
73
72
|
assets: {
|
|
74
73
|
links: [
|
|
75
74
|
{
|
|
76
|
-
name:
|
|
77
|
-
url: `${pushRepo}/uploads/7e8bec1fe27cc46a4bc6a91b9e82a07c
|
|
75
|
+
name: 'file-v2.0.1.txt',
|
|
76
|
+
url: `${pushRepo}/uploads/7e8bec1fe27cc46a4bc6a91b9e82a07c/file-v2.0.1.txt`
|
|
78
77
|
}
|
|
79
78
|
]
|
|
80
79
|
}
|
|
@@ -83,7 +82,7 @@ test.serial('should upload assets and release', async t => {
|
|
|
83
82
|
|
|
84
83
|
await runTasks(gitlab);
|
|
85
84
|
|
|
86
|
-
t.is(gitlab.assets[0].url, `${pushRepo}/uploads/7e8bec1fe27cc46a4bc6a91b9e82a07c
|
|
85
|
+
t.is(gitlab.assets[0].url, `${pushRepo}/uploads/7e8bec1fe27cc46a4bc6a91b9e82a07c/file-v2.0.1.txt`);
|
|
87
86
|
const { isReleased, releaseUrl } = gitlab.getContext();
|
|
88
87
|
t.true(isReleased);
|
|
89
88
|
t.is(releaseUrl, `${pushRepo}/-/releases`);
|
|
@@ -192,7 +191,7 @@ test('should not make requests in dry run', async t => {
|
|
|
192
191
|
t.is(gitlab.log.exec.args[2][0], 'gitlab releases#createRelease "R" (1.0.1)');
|
|
193
192
|
t.true(isReleased);
|
|
194
193
|
t.is(releaseUrl, `${pushRepo}/-/releases`);
|
|
195
|
-
spy.restore();
|
|
194
|
+
spy.get.restore();
|
|
196
195
|
});
|
|
197
196
|
|
|
198
197
|
test('should skip checks', async t => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*
|