release-it 19.0.0-next.4 → 19.0.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.
- package/README.md +4 -3
- package/bin/release-it.js +0 -5
- package/lib/config.js +113 -103
- package/lib/index.js +2 -10
- package/lib/plugin/git/Git.js +2 -2
- package/lib/plugin/github/GitHub.js +2 -2
- package/lib/plugin/github/util.js +1 -0
- package/lib/plugin/gitlab/GitLab.js +2 -2
- package/lib/shell.js +6 -6
- package/lib/util.js +4 -0
- package/package.json +13 -14
- package/test/args.js +3 -3
- package/test/config.js +146 -71
- package/test/git.init.js +30 -30
- package/test/git.js +26 -26
- package/test/github.js +21 -21
- package/test/gitlab.js +27 -27
- package/test/npm.js +31 -31
- package/test/prompt.js +6 -5
- package/test/shell.js +5 -5
- package/test/spinner.js +8 -5
- package/test/stub/config/remote/.release-it.json +5 -0
- package/test/stub/config/remote/sub/.release-it.json +5 -0
- package/test/tasks.interactive.js +22 -15
- package/test/tasks.js +1 -1
- package/test/util/fetch.js +32 -0
- package/test/util/helpers.js +13 -8
- package/test/util/index.js +2 -1
- package/test/version.js +42 -42
package/test/git.js
CHANGED
|
@@ -16,14 +16,14 @@ describe('git', () => {
|
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
test('should return whether repo has upstream branch', async () => {
|
|
19
|
-
const gitClient = factory(Git);
|
|
19
|
+
const gitClient = await factory(Git);
|
|
20
20
|
childProcess.execSync('git init', execOpts);
|
|
21
21
|
gitAdd('line', 'file', 'Add file');
|
|
22
22
|
assert.equal(await gitClient.hasUpstreamBranch(), false);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
test('should return branch name', async () => {
|
|
26
|
-
const gitClient = factory(Git);
|
|
26
|
+
const gitClient = await factory(Git);
|
|
27
27
|
childProcess.execSync('git init', execOpts);
|
|
28
28
|
assert.equal(await gitClient.getBranchName(), null);
|
|
29
29
|
childProcess.execSync('git checkout -b feat', execOpts);
|
|
@@ -32,7 +32,7 @@ describe('git', () => {
|
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
test('should return whether tag exists and if working dir is clean', async () => {
|
|
35
|
-
const gitClient = factory(Git);
|
|
35
|
+
const gitClient = await factory(Git);
|
|
36
36
|
childProcess.execSync('git init', execOpts);
|
|
37
37
|
assert.equal(await gitClient.tagExists('1.0.0'), false);
|
|
38
38
|
touch('file');
|
|
@@ -44,7 +44,7 @@ describe('git', () => {
|
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
test('should throw if tag exists', async () => {
|
|
47
|
-
const gitClient = factory(Git);
|
|
47
|
+
const gitClient = await factory(Git);
|
|
48
48
|
childProcess.execSync('git init', execOpts);
|
|
49
49
|
touch('file');
|
|
50
50
|
gitAdd('line', 'file', 'Add file');
|
|
@@ -54,7 +54,7 @@ describe('git', () => {
|
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
test('should only warn if tag exists intentionally', async t => {
|
|
57
|
-
const gitClient = factory(Git);
|
|
57
|
+
const gitClient = await factory(Git);
|
|
58
58
|
const warn = t.mock.method(gitClient.log, 'warn');
|
|
59
59
|
childProcess.execSync('git init', execOpts);
|
|
60
60
|
touch('file');
|
|
@@ -70,21 +70,21 @@ describe('git', () => {
|
|
|
70
70
|
childProcess.execSync(`git init`, execOpts);
|
|
71
71
|
{
|
|
72
72
|
const options = { git: { pushRepo: 'origin' } };
|
|
73
|
-
const gitClient = factory(Git, { options });
|
|
73
|
+
const gitClient = await factory(Git, { options });
|
|
74
74
|
assert.equal(await gitClient.getRemoteUrl(), null);
|
|
75
75
|
childProcess.execSync(`git remote add origin foo`, execOpts);
|
|
76
76
|
assert.equal(await gitClient.getRemoteUrl(), 'foo');
|
|
77
77
|
}
|
|
78
78
|
{
|
|
79
79
|
const options = { git: { pushRepo: 'another' } };
|
|
80
|
-
const gitClient = factory(Git, { options });
|
|
80
|
+
const gitClient = await factory(Git, { options });
|
|
81
81
|
assert.equal(await gitClient.getRemoteUrl(), null);
|
|
82
82
|
childProcess.execSync(`git remote add another bar`, execOpts);
|
|
83
83
|
assert.equal(await gitClient.getRemoteUrl(), 'bar');
|
|
84
84
|
}
|
|
85
85
|
{
|
|
86
86
|
const options = { git: { pushRepo: 'git://github.com/webpro/release-it.git' } };
|
|
87
|
-
const gitClient = factory(Git, { options });
|
|
87
|
+
const gitClient = await factory(Git, { options });
|
|
88
88
|
assert.equal(await gitClient.getRemoteUrl(), 'git://github.com/webpro/release-it.git');
|
|
89
89
|
}
|
|
90
90
|
});
|
|
@@ -95,7 +95,7 @@ describe('git', () => {
|
|
|
95
95
|
childProcess.execSync(`git clone ${bare} .`, execOpts);
|
|
96
96
|
gitAdd('line', 'file', 'Add file');
|
|
97
97
|
childProcess.execSync('git remote rename origin upstream', execOpts);
|
|
98
|
-
const gitClient = factory(Git);
|
|
98
|
+
const gitClient = await factory(Git);
|
|
99
99
|
assert.equal(await gitClient.getRemoteUrl(), bare);
|
|
100
100
|
});
|
|
101
101
|
|
|
@@ -106,12 +106,12 @@ describe('git', () => {
|
|
|
106
106
|
const version = '1.2.3';
|
|
107
107
|
gitAdd(`{"version":"${version}"}`, 'package.json', 'Add package.json');
|
|
108
108
|
{
|
|
109
|
-
const gitClient = factory(Git);
|
|
109
|
+
const gitClient = await factory(Git);
|
|
110
110
|
childProcess.execSync(`git tag ${version}`, execOpts);
|
|
111
111
|
assert.equal(await gitClient.getLatestTagName(), version);
|
|
112
112
|
}
|
|
113
113
|
{
|
|
114
|
-
const gitClient = factory(Git);
|
|
114
|
+
const gitClient = await factory(Git);
|
|
115
115
|
gitAdd('line', 'file', 'Add file');
|
|
116
116
|
childProcess.execSync('npm --no-git-tag-version version patch', execOpts);
|
|
117
117
|
await gitClient.stage('package.json');
|
|
@@ -130,7 +130,7 @@ describe('git', () => {
|
|
|
130
130
|
childProcess.execSync(`git clone ${bare} .`, execOpts);
|
|
131
131
|
gitAdd('line', 'file', 'Add file');
|
|
132
132
|
const options = { git: { commitArgs: '-S', tagArgs: ['-T', 'foo'], pushArgs: ['-U', 'bar', '-V'] } };
|
|
133
|
-
const gitClient = factory(Git, { options });
|
|
133
|
+
const gitClient = await factory(Git, { options });
|
|
134
134
|
const stub = t.mock.method(gitClient.shell, 'exec', () => Promise.resolve());
|
|
135
135
|
await gitClient.stage('package.json');
|
|
136
136
|
await gitClient.commit({ message: `Release v1.2.4` });
|
|
@@ -148,7 +148,7 @@ describe('git', () => {
|
|
|
148
148
|
childProcess.execSync(`git clone ${bare} .`, execOpts);
|
|
149
149
|
gitAdd('line', 'file', 'Add file');
|
|
150
150
|
const options = { git: { commitArgs: ['--amend', '--no-edit', '--no-verify'] } };
|
|
151
|
-
const gitClient = factory(Git, { options });
|
|
151
|
+
const gitClient = await factory(Git, { options });
|
|
152
152
|
const exec = t.mock.method(gitClient.shell, 'exec', () => Promise.resolve());
|
|
153
153
|
await gitClient.stage('package.json');
|
|
154
154
|
await gitClient.commit();
|
|
@@ -159,7 +159,7 @@ describe('git', () => {
|
|
|
159
159
|
const bare = mkTmpDir();
|
|
160
160
|
childProcess.execSync(`git init --bare ${bare}`, execOpts);
|
|
161
161
|
childProcess.execSync(`git clone ${bare} .`, execOpts);
|
|
162
|
-
const gitClient = factory(Git, {
|
|
162
|
+
const gitClient = await factory(Git, {
|
|
163
163
|
options: { git: { commitMessage: 'Release ${version}', tagAnnotation: 'Release ${version}\n\n${changelog}' } }
|
|
164
164
|
});
|
|
165
165
|
touch('file');
|
|
@@ -188,7 +188,7 @@ describe('git', () => {
|
|
|
188
188
|
childProcess.execSync(`git init --bare ${bare}`, execOpts);
|
|
189
189
|
childProcess.execSync(`git clone ${bare} .`, execOpts);
|
|
190
190
|
gitAdd('line', 'file', 'Add file');
|
|
191
|
-
const gitClient = factory(Git);
|
|
191
|
+
const gitClient = await factory(Git);
|
|
192
192
|
const spy = t.mock.method(gitClient.shell, 'exec');
|
|
193
193
|
await gitClient.push();
|
|
194
194
|
assert.deepEqual(spy.mock.calls.at(-1).arguments[0], ['git', 'push']);
|
|
@@ -205,7 +205,7 @@ describe('git', () => {
|
|
|
205
205
|
childProcess.execSync(`git clone ${bare} .`, execOpts);
|
|
206
206
|
childProcess.execSync(`git remote rename origin upstream`, execOpts);
|
|
207
207
|
gitAdd('line', 'file', 'Add file');
|
|
208
|
-
const gitClient = factory(Git);
|
|
208
|
+
const gitClient = await factory(Git);
|
|
209
209
|
const spy = t.mock.method(gitClient.shell, 'exec');
|
|
210
210
|
await gitClient.push();
|
|
211
211
|
assert.deepEqual(spy.mock.calls.at(-1).arguments[0], ['git', 'push']);
|
|
@@ -222,7 +222,7 @@ describe('git', () => {
|
|
|
222
222
|
childProcess.execSync(`git clone ${bare} .`, execOpts);
|
|
223
223
|
gitAdd('line', 'file', 'Add file');
|
|
224
224
|
const options = { git: { pushRepo: 'https://host/repo.git' } };
|
|
225
|
-
const gitClient = factory(Git, { options });
|
|
225
|
+
const gitClient = await factory(Git, { options });
|
|
226
226
|
const spy = t.mock.method(gitClient.shell, 'exec');
|
|
227
227
|
try {
|
|
228
228
|
await gitClient.push();
|
|
@@ -243,7 +243,7 @@ describe('git', () => {
|
|
|
243
243
|
execOpts
|
|
244
244
|
);
|
|
245
245
|
const options = { git: { pushRepo: 'upstream' } };
|
|
246
|
-
const gitClient = factory(Git, { options });
|
|
246
|
+
const gitClient = await factory(Git, { options });
|
|
247
247
|
const spy = t.mock.method(gitClient.shell, 'exec');
|
|
248
248
|
await gitClient.push();
|
|
249
249
|
assert.deepEqual(spy.mock.calls.at(-1).arguments[0], ['git', 'push', 'upstream']);
|
|
@@ -266,7 +266,7 @@ describe('git', () => {
|
|
|
266
266
|
});
|
|
267
267
|
|
|
268
268
|
test('should return repo status', async () => {
|
|
269
|
-
const gitClient = factory(Git);
|
|
269
|
+
const gitClient = await factory(Git);
|
|
270
270
|
childProcess.execSync('git init', execOpts);
|
|
271
271
|
gitAdd('line', 'file1', 'Add file');
|
|
272
272
|
|
|
@@ -278,7 +278,7 @@ describe('git', () => {
|
|
|
278
278
|
});
|
|
279
279
|
|
|
280
280
|
test('should reset files', async t => {
|
|
281
|
-
const gitClient = factory(Git);
|
|
281
|
+
const gitClient = await factory(Git);
|
|
282
282
|
childProcess.execSync('git init', execOpts);
|
|
283
283
|
gitAdd('line', 'file', 'Add file');
|
|
284
284
|
|
|
@@ -297,7 +297,7 @@ describe('git', () => {
|
|
|
297
297
|
const version = '1.2.3';
|
|
298
298
|
gitAdd(`{"version":"${version}"}`, 'package.json', 'Add package.json');
|
|
299
299
|
const options = { git: { requireCleanWorkingDir: true, commit: true, tag: true, tagName: 'v${version}' } };
|
|
300
|
-
const gitClient = factory(Git, { options });
|
|
300
|
+
const gitClient = await factory(Git, { options });
|
|
301
301
|
const exec = t.mock.method(gitClient.shell, 'execFormattedCommand');
|
|
302
302
|
childProcess.execSync(`git tag ${version}`, execOpts);
|
|
303
303
|
gitAdd('line', 'file', 'Add file');
|
|
@@ -325,7 +325,7 @@ describe('git', () => {
|
|
|
325
325
|
const version = '1.2.3';
|
|
326
326
|
gitAdd(`{"version":"${version}"}`, 'package.json', 'Add package.json');
|
|
327
327
|
const options = { git: { requireCleanWorkingDir: true, commit: true, tag: true, tagName: 'v${version}' } };
|
|
328
|
-
const gitClient = factory(Git, { options });
|
|
328
|
+
const gitClient = await factory(Git, { options });
|
|
329
329
|
const exec = t.mock.method(gitClient.shell, 'execFormattedCommand');
|
|
330
330
|
sh.exec(`git push`, execOpts);
|
|
331
331
|
sh.exec(`git checkout HEAD~1`, execOpts);
|
|
@@ -353,7 +353,7 @@ describe('git', () => {
|
|
|
353
353
|
const version = '1.2.3';
|
|
354
354
|
gitAdd(`{"version":"${version}"}`, 'package.json', 'Add package.json');
|
|
355
355
|
const options = { git: { requireCleanWorkingDir: true, commit: true, tag: true } };
|
|
356
|
-
const gitClient = factory(Git, { options });
|
|
356
|
+
const gitClient = await factory(Git, { options });
|
|
357
357
|
childProcess.execSync(`git tag ${version}`, execOpts);
|
|
358
358
|
|
|
359
359
|
const exec = t.mock.method(gitClient.shell, 'execFormattedCommand');
|
|
@@ -368,7 +368,7 @@ describe('git', () => {
|
|
|
368
368
|
test.skip('should not roll back with risky config', async () => {
|
|
369
369
|
childProcess.execSync('git init', execOpts);
|
|
370
370
|
const options = { git: { requireCleanWorkingDir: false, commit: true, tag: true } };
|
|
371
|
-
const gitClient = factory(Git, { options });
|
|
371
|
+
const gitClient = await factory(Git, { options });
|
|
372
372
|
await gitClient.beforeRelease();
|
|
373
373
|
assert.equal('rollbackOnce' in gitClient, false);
|
|
374
374
|
});
|
|
@@ -378,7 +378,7 @@ describe('git', () => {
|
|
|
378
378
|
|
|
379
379
|
{
|
|
380
380
|
const options = { git: { getLatestTagFromAllRefs: true } };
|
|
381
|
-
const gitClient = factory(Git, { options });
|
|
381
|
+
const gitClient = await factory(Git, { options });
|
|
382
382
|
gitAdd('main', 'file', 'Add file in main');
|
|
383
383
|
const defaultBranchName = await gitClient.getBranchName();
|
|
384
384
|
const developBranchName = 'develop';
|
|
@@ -402,7 +402,7 @@ describe('git', () => {
|
|
|
402
402
|
|
|
403
403
|
{
|
|
404
404
|
const options = { git: { getLatestTagFromAllRefs: false } };
|
|
405
|
-
const gitClient = factory(Git, { options });
|
|
405
|
+
const gitClient = await factory(Git, { options });
|
|
406
406
|
assert.equal(await gitClient.getLatestTagName(), '1.1.0-rc.1');
|
|
407
407
|
}
|
|
408
408
|
});
|
package/test/github.js
CHANGED
|
@@ -43,7 +43,7 @@ describe('github', () => {
|
|
|
43
43
|
test('should check token and perform checks', async () => {
|
|
44
44
|
const tokenRef = 'MY_GITHUB_TOKEN';
|
|
45
45
|
const options = { github: { release: true, tokenRef, pushRepo } };
|
|
46
|
-
const github = factory(GitHub, { options });
|
|
46
|
+
const github = await factory(GitHub, { options });
|
|
47
47
|
|
|
48
48
|
interceptAuthentication(api);
|
|
49
49
|
interceptCollaborator(api);
|
|
@@ -53,7 +53,7 @@ describe('github', () => {
|
|
|
53
53
|
test('should check token and warn', async () => {
|
|
54
54
|
const tokenRef = 'MY_GITHUB_TOKEN';
|
|
55
55
|
const options = { github: { release: true, tokenRef, pushRepo } };
|
|
56
|
-
const github = factory(GitHub, { options });
|
|
56
|
+
const github = await factory(GitHub, { options });
|
|
57
57
|
delete process.env[tokenRef];
|
|
58
58
|
|
|
59
59
|
await assert.doesNotReject(github.init());
|
|
@@ -77,7 +77,7 @@ describe('github', () => {
|
|
|
77
77
|
assets: 'test/resources/file-v${version}.txt'
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
|
-
const github = factory(GitHub, { options });
|
|
80
|
+
const github = await factory(GitHub, { options });
|
|
81
81
|
|
|
82
82
|
const original = github.shell.exec.bind(github.shell);
|
|
83
83
|
t.mock.method(github.shell, 'exec', (...args) => {
|
|
@@ -110,7 +110,7 @@ describe('github', () => {
|
|
|
110
110
|
draft: true
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
|
-
const github = factory(GitHub, { options });
|
|
113
|
+
const github = await factory(GitHub, { options });
|
|
114
114
|
|
|
115
115
|
const original = github.shell.exec.bind(github.shell);
|
|
116
116
|
t.mock.method(github.shell, 'exec', (...args) => {
|
|
@@ -141,7 +141,7 @@ describe('github', () => {
|
|
|
141
141
|
autoGenerate: true
|
|
142
142
|
}
|
|
143
143
|
};
|
|
144
|
-
const github = factory(GitHub, { options });
|
|
144
|
+
const github = await factory(GitHub, { options });
|
|
145
145
|
|
|
146
146
|
const original = github.shell.exec.bind(github.shell);
|
|
147
147
|
t.mock.method(github.shell, 'exec', (...args) => {
|
|
@@ -177,7 +177,7 @@ describe('github', () => {
|
|
|
177
177
|
assets: `test/resources/${asset}`
|
|
178
178
|
}
|
|
179
179
|
};
|
|
180
|
-
const github = factory(GitHub, { options });
|
|
180
|
+
const github = await factory(GitHub, { options });
|
|
181
181
|
|
|
182
182
|
const original = github.shell.exec.bind(github.shell);
|
|
183
183
|
t.mock.method(github.shell, 'exec', (...args) => {
|
|
@@ -214,7 +214,7 @@ describe('github', () => {
|
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
};
|
|
217
|
-
const github = factory(GitHub, { options });
|
|
217
|
+
const github = await factory(GitHub, { options });
|
|
218
218
|
|
|
219
219
|
const original = github.shell.exec.bind(github.shell);
|
|
220
220
|
t.mock.method(github.shell, 'exec', (...args) => {
|
|
@@ -248,7 +248,7 @@ describe('github', () => {
|
|
|
248
248
|
releaseNotes: 'echo Custom notes'
|
|
249
249
|
}
|
|
250
250
|
};
|
|
251
|
-
const github = factory(GitHub, { options });
|
|
251
|
+
const github = await factory(GitHub, { options });
|
|
252
252
|
|
|
253
253
|
const original = github.shell.exec.bind(github.shell);
|
|
254
254
|
t.mock.method(github.shell, 'exec', (...args) => {
|
|
@@ -273,7 +273,7 @@ describe('github', () => {
|
|
|
273
273
|
|
|
274
274
|
test('should release to enterprise host', async t => {
|
|
275
275
|
const options = { git, github: { tokenRef, pushRepo: 'git://github.example.org/user/repo' } };
|
|
276
|
-
const github = factory(GitHub, { options });
|
|
276
|
+
const github = await factory(GitHub, { options });
|
|
277
277
|
|
|
278
278
|
const original = github.shell.exec.bind(github.shell);
|
|
279
279
|
t.mock.method(github.shell, 'exec', (...args) => {
|
|
@@ -309,7 +309,7 @@ describe('github', () => {
|
|
|
309
309
|
proxy: 'http://proxy:8080'
|
|
310
310
|
}
|
|
311
311
|
};
|
|
312
|
-
const github = factory(GitHub, { options });
|
|
312
|
+
const github = await factory(GitHub, { options });
|
|
313
313
|
|
|
314
314
|
const original = github.shell.exec.bind(github.shell);
|
|
315
315
|
t.mock.method(github.shell, 'exec', (...args) => {
|
|
@@ -336,7 +336,7 @@ describe('github', () => {
|
|
|
336
336
|
|
|
337
337
|
test('should release to git.pushRepo', async t => {
|
|
338
338
|
const options = { git: { pushRepo: 'upstream', changelog: '' }, github: { tokenRef, skipChecks: true } };
|
|
339
|
-
const github = factory(GitHub, { options });
|
|
339
|
+
const github = await factory(GitHub, { options });
|
|
340
340
|
|
|
341
341
|
const original = github.shell.exec.bind(github.shell);
|
|
342
342
|
t.mock.method(github.shell, 'exec', (...args) => {
|
|
@@ -363,7 +363,7 @@ describe('github', () => {
|
|
|
363
363
|
|
|
364
364
|
testSkipOnActions('should throw for unauthenticated user', async t => {
|
|
365
365
|
const options = { github: { tokenRef, pushRepo, host } };
|
|
366
|
-
const github = factory(GitHub, { options });
|
|
366
|
+
const github = await factory(GitHub, { options });
|
|
367
367
|
|
|
368
368
|
const getAuthenticated = t.mock.method(github.client.users, 'getAuthenticated', () => {
|
|
369
369
|
throw new RequestError('Bad credentials', 401, requestErrorOptions);
|
|
@@ -378,7 +378,7 @@ describe('github', () => {
|
|
|
378
378
|
|
|
379
379
|
testSkipOnActions('should throw for non-collaborator', async t => {
|
|
380
380
|
const options = { github: { tokenRef, pushRepo, host } };
|
|
381
|
-
const github = factory(GitHub, { options });
|
|
381
|
+
const github = await factory(GitHub, { options });
|
|
382
382
|
|
|
383
383
|
t.mock.method(github.client.repos, 'checkCollaborator', () => {
|
|
384
384
|
throw new RequestError('HttpError', 401, requestErrorOptions);
|
|
@@ -397,7 +397,7 @@ describe('github', () => {
|
|
|
397
397
|
}
|
|
398
398
|
|
|
399
399
|
const options = { github: { tokenRef } };
|
|
400
|
-
const github = factory(GitHub, { options });
|
|
400
|
+
const github = await factory(GitHub, { options });
|
|
401
401
|
const authStub = t.mock.method(github, 'isAuthenticated');
|
|
402
402
|
const collaboratorStub = t.mock.method(github, 'isCollaborator');
|
|
403
403
|
|
|
@@ -414,7 +414,7 @@ describe('github', () => {
|
|
|
414
414
|
});
|
|
415
415
|
|
|
416
416
|
test('should handle octokit client error (without retries)', async t => {
|
|
417
|
-
const github = factory(GitHub, { options: { github: { tokenRef, pushRepo, host } } });
|
|
417
|
+
const github = await factory(GitHub, { options: { github: { tokenRef, pushRepo, host } } });
|
|
418
418
|
const createRelease = t.mock.method(github.client.repos, 'createRelease', () => {
|
|
419
419
|
throw new RequestError('Not found', 404, requestErrorOptions);
|
|
420
420
|
});
|
|
@@ -429,7 +429,7 @@ describe('github', () => {
|
|
|
429
429
|
|
|
430
430
|
test('should handle octokit client error (with retries)', async t => {
|
|
431
431
|
const options = { github: { tokenRef, pushRepo, host, retryMinTimeout: 0 } };
|
|
432
|
-
const github = factory(GitHub, { options });
|
|
432
|
+
const github = await factory(GitHub, { options });
|
|
433
433
|
|
|
434
434
|
const createRelease = t.mock.method(github.client.repos, 'createRelease', () => {
|
|
435
435
|
throw new RequestError('Request failed', 500, requestErrorOptions);
|
|
@@ -449,7 +449,7 @@ describe('github', () => {
|
|
|
449
449
|
git,
|
|
450
450
|
github: { tokenRef, pushRepo, releaseName: 'R ${version}', assets: ['*'] }
|
|
451
451
|
};
|
|
452
|
-
const github = factory(GitHub, { options });
|
|
452
|
+
const github = await factory(GitHub, { options });
|
|
453
453
|
|
|
454
454
|
const get = t.mock.getter(github, 'client');
|
|
455
455
|
const original = github.shell.exec.bind(github.shell);
|
|
@@ -479,7 +479,7 @@ describe('github', () => {
|
|
|
479
479
|
releaseNotes: 'echo Custom notes'
|
|
480
480
|
}
|
|
481
481
|
};
|
|
482
|
-
const github = factory(GitHub, { options });
|
|
482
|
+
const github = await factory(GitHub, { options });
|
|
483
483
|
|
|
484
484
|
const original = github.shell.exec.bind(github.shell);
|
|
485
485
|
t.mock.method(github.shell, 'exec', (...args) => {
|
|
@@ -510,7 +510,7 @@ describe('github', () => {
|
|
|
510
510
|
releaseNotes: 'echo It happened'
|
|
511
511
|
}
|
|
512
512
|
};
|
|
513
|
-
const github = factory(GitHub, { options });
|
|
513
|
+
const github = await factory(GitHub, { options });
|
|
514
514
|
|
|
515
515
|
const original = github.shell.exec.bind(github.shell);
|
|
516
516
|
t.mock.method(github.shell, 'exec', (...args) => {
|
|
@@ -542,7 +542,7 @@ describe('github', () => {
|
|
|
542
542
|
releaseNotes: 'echo ' + releaseNotes
|
|
543
543
|
}
|
|
544
544
|
};
|
|
545
|
-
const github = factory(GitHub, { options });
|
|
545
|
+
const github = await factory(GitHub, { options });
|
|
546
546
|
|
|
547
547
|
const original = github.shell.exec.bind(github.shell);
|
|
548
548
|
t.mock.method(github.shell, 'exec', (...args) => {
|
|
@@ -601,7 +601,7 @@ describe('github', () => {
|
|
|
601
601
|
discussionCategoryName: 'Announcement'
|
|
602
602
|
}
|
|
603
603
|
};
|
|
604
|
-
const github = factory(GitHub, { options });
|
|
604
|
+
const github = await factory(GitHub, { options });
|
|
605
605
|
const original = github.shell.exec.bind(github.shell);
|
|
606
606
|
t.mock.method(github.shell, 'exec', (...args) => {
|
|
607
607
|
if (args[0] === 'git describe --tags --match=* --abbrev=0') return Promise.resolve('2.0.1');
|
package/test/gitlab.js
CHANGED
|
@@ -53,7 +53,7 @@ describe('GitLab', () => {
|
|
|
53
53
|
const tokenRef = 'MY_GITLAB_TOKEN';
|
|
54
54
|
const pushRepo = 'https://gitlab.com/user/repo';
|
|
55
55
|
const options = { gitlab: { release: true, tokenRef, tokenHeader, pushRepo } };
|
|
56
|
-
const gitlab = factory(GitLab, { options });
|
|
56
|
+
const gitlab = await factory(GitLab, { options });
|
|
57
57
|
delete process.env[tokenRef];
|
|
58
58
|
|
|
59
59
|
await assert.rejects(gitlab.init(), /Environment variable "MY_GITLAB_TOKEN" is required for GitLab releases/);
|
|
@@ -71,7 +71,7 @@ describe('GitLab', () => {
|
|
|
71
71
|
process.env[tokenRef] = 'j0b-t0k3n';
|
|
72
72
|
const pushRepo = 'https://gitlab.com/user/repo';
|
|
73
73
|
const options = { git: { pushRepo }, gitlab: { release: true, tokenRef, tokenHeader } };
|
|
74
|
-
const gitlab = factory(GitLab, { options });
|
|
74
|
+
const gitlab = await factory(GitLab, { options });
|
|
75
75
|
|
|
76
76
|
interceptPublish(api, { headers: { 'job-token': '1' } });
|
|
77
77
|
|
|
@@ -93,10 +93,10 @@ describe('GitLab', () => {
|
|
|
93
93
|
milestones: ['${version}', '${latestVersion} UAT']
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
|
-
const gitlab = factory(GitLab, { options });
|
|
96
|
+
const gitlab = await factory(GitLab, { options });
|
|
97
97
|
t.mock.method(gitlab, 'getLatestVersion', () => Promise.resolve('2.0.0'));
|
|
98
98
|
|
|
99
|
-
const git = factory(Git);
|
|
99
|
+
const git = await factory(Git);
|
|
100
100
|
const ref = (await git.getBranchName()) ?? 'HEAD';
|
|
101
101
|
|
|
102
102
|
interceptUser(api);
|
|
@@ -141,7 +141,7 @@ describe('GitLab', () => {
|
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
-
const gitlab = factory(GitLab, { options });
|
|
144
|
+
const gitlab = await factory(GitLab, { options });
|
|
145
145
|
t.mock.method(gitlab, 'getLatestVersion', () => Promise.resolve('2.0.0'));
|
|
146
146
|
|
|
147
147
|
interceptUser(api);
|
|
@@ -170,7 +170,7 @@ describe('GitLab', () => {
|
|
|
170
170
|
genericPackageRepositoryName: 'release-it'
|
|
171
171
|
}
|
|
172
172
|
};
|
|
173
|
-
const gitlab = factory(GitLab, { options });
|
|
173
|
+
const gitlab = await factory(GitLab, { options });
|
|
174
174
|
t.mock.method(gitlab, 'getLatestVersion', () => Promise.resolve('2.0.0'));
|
|
175
175
|
|
|
176
176
|
interceptUser(api);
|
|
@@ -196,7 +196,7 @@ describe('GitLab', () => {
|
|
|
196
196
|
milestones: ['${version}', '${latestVersion} UAT']
|
|
197
197
|
}
|
|
198
198
|
};
|
|
199
|
-
const gitlab = factory(GitLab, { options });
|
|
199
|
+
const gitlab = await factory(GitLab, { options });
|
|
200
200
|
t.mock.method(gitlab, 'getLatestVersion', () => Promise.resolve('2.0.0'));
|
|
201
201
|
|
|
202
202
|
interceptUser(api);
|
|
@@ -216,7 +216,7 @@ describe('GitLab', () => {
|
|
|
216
216
|
git: { pushRepo: `${host}/user/repo` },
|
|
217
217
|
gitlab: { releaseName: 'Release ${version}', releaseNotes: 'echo readme', tokenRef }
|
|
218
218
|
};
|
|
219
|
-
const gitlab = factory(GitLab, { options });
|
|
219
|
+
const gitlab = await factory(GitLab, { options });
|
|
220
220
|
t.mock.method(gitlab, 'getLatestVersion', () => Promise.resolve('1.0.0'));
|
|
221
221
|
|
|
222
222
|
interceptUser(example);
|
|
@@ -232,7 +232,7 @@ describe('GitLab', () => {
|
|
|
232
232
|
|
|
233
233
|
test('should release to sub-grouped repo', async () => {
|
|
234
234
|
const options = { gitlab: { tokenRef }, git: { pushRepo: 'git@gitlab.com:group/sub-group/repo.git' } };
|
|
235
|
-
const gitlab = factory(GitLab, { options });
|
|
235
|
+
const gitlab = await factory(GitLab, { options });
|
|
236
236
|
|
|
237
237
|
interceptUser(api, { owner: 'sub-group' });
|
|
238
238
|
interceptCollaborator(api, { owner: 'sub-group', group: 'group' });
|
|
@@ -249,7 +249,7 @@ describe('GitLab', () => {
|
|
|
249
249
|
const host = 'https://gitlab.com';
|
|
250
250
|
const pushRepo = `${host}/user/repo`;
|
|
251
251
|
const options = { gitlab: { tokenRef, pushRepo, host } };
|
|
252
|
-
const gitlab = factory(GitLab, { options });
|
|
252
|
+
const gitlab = await factory(GitLab, { options });
|
|
253
253
|
|
|
254
254
|
api.get('/user', { status: 401 });
|
|
255
255
|
|
|
@@ -263,7 +263,7 @@ describe('GitLab', () => {
|
|
|
263
263
|
const host = 'https://gitlab.com';
|
|
264
264
|
const pushRepo = `${host}/john/repo`;
|
|
265
265
|
const options = { gitlab: { tokenRef, pushRepo, host } };
|
|
266
|
-
const gitlab = factory(GitLab, { options });
|
|
266
|
+
const gitlab = await factory(GitLab, { options });
|
|
267
267
|
|
|
268
268
|
interceptMembers(api, { owner: 'emma' });
|
|
269
269
|
interceptUser(api, { owner: 'john' });
|
|
@@ -275,7 +275,7 @@ describe('GitLab', () => {
|
|
|
275
275
|
const host = 'https://gitlab.com';
|
|
276
276
|
const pushRepo = `${host}/john/repo`;
|
|
277
277
|
const options = { gitlab: { tokenRef, pushRepo, host } };
|
|
278
|
-
const gitlab = factory(GitLab, { options });
|
|
278
|
+
const gitlab = await factory(GitLab, { options });
|
|
279
279
|
|
|
280
280
|
interceptMembers(api, { owner: 'john', access_level: 10 });
|
|
281
281
|
interceptUser(api, { owner: 'john' });
|
|
@@ -287,7 +287,7 @@ describe('GitLab', () => {
|
|
|
287
287
|
const [host, owner, repo] = ['https://gitlab.example.org', 'user', 'repo'];
|
|
288
288
|
const pushRepo = `${host}/${owner}/${repo}`;
|
|
289
289
|
const options = { 'dry-run': true, git: { pushRepo }, gitlab: { releaseName: 'R', tokenRef } };
|
|
290
|
-
const gitlab = factory(GitLab, { options });
|
|
290
|
+
const gitlab = await factory(GitLab, { options });
|
|
291
291
|
t.mock.method(gitlab, 'getLatestVersion', () => Promise.resolve('1.0.0'));
|
|
292
292
|
|
|
293
293
|
await runTasks(gitlab);
|
|
@@ -302,7 +302,7 @@ describe('GitLab', () => {
|
|
|
302
302
|
|
|
303
303
|
test('should skip checks', async () => {
|
|
304
304
|
const options = { gitlab: { tokenRef, skipChecks: true, release: true, milestones: ['v1.0.0'] } };
|
|
305
|
-
const gitlab = factory(GitLab, { options });
|
|
305
|
+
const gitlab = await factory(GitLab, { options });
|
|
306
306
|
|
|
307
307
|
await assert.doesNotReject(gitlab.init());
|
|
308
308
|
await assert.doesNotReject(gitlab.beforeRelease());
|
|
@@ -315,16 +315,16 @@ describe('GitLab', () => {
|
|
|
315
315
|
);
|
|
316
316
|
});
|
|
317
317
|
|
|
318
|
-
test('should not create fetch agent', () => {
|
|
318
|
+
test('should not create fetch agent', async () => {
|
|
319
319
|
const options = { gitlab: {} };
|
|
320
|
-
const gitlab = factory(GitLab, { options });
|
|
320
|
+
const gitlab = await factory(GitLab, { options });
|
|
321
321
|
|
|
322
322
|
assert.deepEqual(gitlab.certificateAuthorityOption, {});
|
|
323
323
|
});
|
|
324
324
|
|
|
325
|
-
test('should create fetch agent if secure == false', () => {
|
|
325
|
+
test('should create fetch agent if secure == false', async () => {
|
|
326
326
|
const options = { gitlab: { secure: false } };
|
|
327
|
-
const gitlab = factory(GitLab, { options });
|
|
327
|
+
const gitlab = await factory(GitLab, { options });
|
|
328
328
|
const { dispatcher } = gitlab.certificateAuthorityOption;
|
|
329
329
|
|
|
330
330
|
assert(dispatcher instanceof Agent, "Fetch dispatcher should be an instance of undici's Agent class");
|
|
@@ -333,11 +333,11 @@ describe('GitLab', () => {
|
|
|
333
333
|
assert.deepEqual(dispatcher[kOptions].connect, { rejectUnauthorized: false, ca: undefined });
|
|
334
334
|
});
|
|
335
335
|
|
|
336
|
-
test('should create fetch agent if certificateAuthorityFile', t => {
|
|
336
|
+
test('should create fetch agent if certificateAuthorityFile', async t => {
|
|
337
337
|
const readFileSync = t.mock.method(fs, 'readFileSync', () => 'test certificate');
|
|
338
338
|
|
|
339
339
|
const options = { gitlab: { certificateAuthorityFile: 'cert.crt' } };
|
|
340
|
-
const gitlab = factory(GitLab, { options });
|
|
340
|
+
const gitlab = await factory(GitLab, { options });
|
|
341
341
|
const { dispatcher } = gitlab.certificateAuthorityOption;
|
|
342
342
|
|
|
343
343
|
assert(dispatcher instanceof Agent, "Fetch dispatcher should be an instance of undici's Agent class");
|
|
@@ -348,12 +348,12 @@ describe('GitLab', () => {
|
|
|
348
348
|
readFileSync.mock.restore();
|
|
349
349
|
});
|
|
350
350
|
|
|
351
|
-
test('should create fetch agent if CI_SERVER_TLS_CA_FILE env is set', t => {
|
|
351
|
+
test('should create fetch agent if CI_SERVER_TLS_CA_FILE env is set', async t => {
|
|
352
352
|
const readFileSync = t.mock.method(fs, 'readFileSync', () => 'test certificate');
|
|
353
353
|
process.env[certificateAuthorityFileRef] = 'ca.crt';
|
|
354
354
|
|
|
355
355
|
const options = { gitlab: {} };
|
|
356
|
-
const gitlab = factory(GitLab, { options });
|
|
356
|
+
const gitlab = await factory(GitLab, { options });
|
|
357
357
|
const { dispatcher } = gitlab.certificateAuthorityOption;
|
|
358
358
|
|
|
359
359
|
assert(dispatcher instanceof Agent, "Fetch dispatcher should be an instance of undici's Agent class");
|
|
@@ -364,12 +364,12 @@ describe('GitLab', () => {
|
|
|
364
364
|
readFileSync.mock.restore();
|
|
365
365
|
});
|
|
366
366
|
|
|
367
|
-
test('should create fetch agent if certificateAuthorityFileRef env is set', t => {
|
|
367
|
+
test('should create fetch agent if certificateAuthorityFileRef env is set', async t => {
|
|
368
368
|
const readFileSync = t.mock.method(fs, 'readFileSync', () => 'test certificate');
|
|
369
369
|
process.env['GITLAB_CA_FILE'] = 'custom-ca.crt';
|
|
370
370
|
|
|
371
371
|
const options = { gitlab: { certificateAuthorityFileRef: 'GITLAB_CA_FILE' } };
|
|
372
|
-
const gitlab = factory(GitLab, { options });
|
|
372
|
+
const gitlab = await factory(GitLab, { options });
|
|
373
373
|
const { dispatcher } = gitlab.certificateAuthorityOption;
|
|
374
374
|
|
|
375
375
|
assert(dispatcher instanceof Agent, "Fetch dispatcher should be an instance of undici's Agent class");
|
|
@@ -387,7 +387,7 @@ describe('GitLab', () => {
|
|
|
387
387
|
git: { pushRepo: `${host}/user/repo` },
|
|
388
388
|
gitlab: { host, tokenRef, origin: host }
|
|
389
389
|
};
|
|
390
|
-
const gitlab = factory(GitLab, { options });
|
|
390
|
+
const gitlab = await factory(GitLab, { options });
|
|
391
391
|
const server = new GitlabTestServer();
|
|
392
392
|
|
|
393
393
|
t.after(async () => {
|
|
@@ -411,7 +411,7 @@ describe('GitLab', () => {
|
|
|
411
411
|
secure: false
|
|
412
412
|
}
|
|
413
413
|
};
|
|
414
|
-
const gitlab = factory(GitLab, { options });
|
|
414
|
+
const gitlab = await factory(GitLab, { options });
|
|
415
415
|
const server = new GitlabTestServer();
|
|
416
416
|
|
|
417
417
|
t.after(async () => {
|
|
@@ -438,7 +438,7 @@ describe('GitLab', () => {
|
|
|
438
438
|
certificateAuthorityFile: 'test/util/https-server/client/my-private-root-ca.cert.pem'
|
|
439
439
|
}
|
|
440
440
|
};
|
|
441
|
-
const gitlab = factory(GitLab, { options });
|
|
441
|
+
const gitlab = await factory(GitLab, { options });
|
|
442
442
|
const server = new GitlabTestServer();
|
|
443
443
|
|
|
444
444
|
t.after(async () => {
|