release-it 19.0.0-next.3 → 19.0.0-next.5
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/bin/release-it.js +1 -32
- package/lib/args.js +64 -0
- package/lib/config.js +113 -103
- package/lib/index.js +2 -10
- package/lib/plugin/git/Git.js +3 -3
- package/lib/plugin/github/GitHub.js +2 -2
- package/lib/plugin/gitlab/GitLab.js +2 -2
- package/lib/shell.js +6 -6
- package/package.json +14 -15
- package/schema/git.json +6 -2
- package/test/args.js +27 -0
- 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 +20 -13
- 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/config.js
CHANGED
|
@@ -1,31 +1,34 @@
|
|
|
1
1
|
import test, { describe, before, after, afterEach } from 'node:test';
|
|
2
2
|
import assert from 'node:assert/strict';
|
|
3
3
|
import { isCI } from 'ci-info';
|
|
4
|
-
import Config
|
|
4
|
+
import Config from '../lib/config.js';
|
|
5
5
|
import { readJSON } from '../lib/util.js';
|
|
6
6
|
import { mockFetch } from './util/mock.js';
|
|
7
|
+
import { createTarBlobByRawContents } from './util/fetch.js';
|
|
7
8
|
|
|
8
9
|
const defaultConfig = readJSON(new URL('../config/release-it.json', import.meta.url));
|
|
9
10
|
const projectConfig = readJSON(new URL('../.release-it.json', import.meta.url));
|
|
10
11
|
|
|
11
12
|
const localConfig = { github: { release: true } };
|
|
12
13
|
|
|
13
|
-
describe('config', () => {
|
|
14
|
-
test("should read this project's own configuration", () => {
|
|
14
|
+
describe('config', async () => {
|
|
15
|
+
test("should read this project's own configuration", async () => {
|
|
15
16
|
const config = new Config();
|
|
17
|
+
await config.init();
|
|
16
18
|
assert.deepEqual(config.constructorConfig, {});
|
|
17
19
|
assert.deepEqual(config.localConfig, projectConfig);
|
|
18
20
|
assert.deepEqual(config.defaultConfig, defaultConfig);
|
|
19
21
|
});
|
|
20
22
|
|
|
21
|
-
test('should contain default values', () => {
|
|
23
|
+
test('should contain default values', async () => {
|
|
22
24
|
const config = new Config({ configDir: './test/stub/config/default' });
|
|
25
|
+
await config.init();
|
|
23
26
|
assert.deepEqual(config.constructorConfig, { configDir: './test/stub/config/default' });
|
|
24
27
|
assert.deepEqual(config.localConfig, localConfig);
|
|
25
28
|
assert.deepEqual(config.defaultConfig, defaultConfig);
|
|
26
29
|
});
|
|
27
30
|
|
|
28
|
-
test('should merge provided options', () => {
|
|
31
|
+
test('should merge provided options', async () => {
|
|
29
32
|
const config = new Config({
|
|
30
33
|
configDir: './test/stub/config/merge',
|
|
31
34
|
increment: '1.0.0',
|
|
@@ -34,6 +37,7 @@ describe('config', () => {
|
|
|
34
37
|
release: true
|
|
35
38
|
}
|
|
36
39
|
});
|
|
40
|
+
await config.init();
|
|
37
41
|
const { options } = config;
|
|
38
42
|
assert.equal(config.isVerbose, true);
|
|
39
43
|
assert.equal(config.isDryRun, false);
|
|
@@ -42,67 +46,79 @@ describe('config', () => {
|
|
|
42
46
|
assert.equal(options.github.release, true);
|
|
43
47
|
});
|
|
44
48
|
|
|
45
|
-
test('should set CI mode', () => {
|
|
49
|
+
test('should set CI mode', async () => {
|
|
46
50
|
const config = new Config({ ci: true });
|
|
51
|
+
await config.init();
|
|
47
52
|
assert.equal(config.isCI, true);
|
|
48
53
|
});
|
|
49
54
|
|
|
50
|
-
test('should detect CI mode', () => {
|
|
55
|
+
test('should detect CI mode', async () => {
|
|
51
56
|
const config = new Config();
|
|
57
|
+
await config.init();
|
|
52
58
|
assert.equal(config.options.ci, isCI);
|
|
53
59
|
assert.equal(config.isCI, isCI);
|
|
54
60
|
});
|
|
55
61
|
|
|
56
|
-
test('should override --no-npm.publish', () => {
|
|
62
|
+
test('should override --no-npm.publish', async () => {
|
|
57
63
|
const config = new Config({ npm: { publish: false } });
|
|
64
|
+
await config.init();
|
|
58
65
|
assert.equal(config.options.npm.publish, false);
|
|
59
66
|
});
|
|
60
67
|
|
|
61
|
-
test('should read YAML config', () => {
|
|
68
|
+
test('should read YAML config', async () => {
|
|
62
69
|
const config = new Config({ configDir: './test/stub/config/yaml' });
|
|
70
|
+
await config.init();
|
|
63
71
|
assert.deepEqual(config.options.foo, { bar: 1 });
|
|
64
72
|
});
|
|
65
73
|
|
|
66
|
-
test('should read YML config', () => {
|
|
74
|
+
test('should read YML config', async () => {
|
|
67
75
|
const config = new Config({ configDir: './test/stub/config/yml' });
|
|
76
|
+
await config.init();
|
|
68
77
|
assert.deepEqual(config.options.foo, { bar: 1 });
|
|
69
78
|
});
|
|
70
79
|
|
|
71
|
-
test('should read TOML config', () => {
|
|
80
|
+
test('should read TOML config', async () => {
|
|
72
81
|
const config = new Config({ configDir: './test/stub/config/toml' });
|
|
82
|
+
await config.init();
|
|
73
83
|
assert.deepEqual(config.options.foo, { bar: 1 });
|
|
74
84
|
});
|
|
75
85
|
|
|
76
|
-
test('should throw if provided config file is not found', () => {
|
|
77
|
-
assert.
|
|
86
|
+
test('should throw if provided config file is not found', async () => {
|
|
87
|
+
await assert.rejects(async () => {
|
|
88
|
+
const config = new Config({ config: 'nofile' });
|
|
89
|
+
await config.init();
|
|
90
|
+
}, /no such file.+nofile/);
|
|
78
91
|
});
|
|
79
92
|
|
|
80
|
-
test('should throw if provided config file is invalid (cosmiconfig exception)', () => {
|
|
81
|
-
assert.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
);
|
|
93
|
+
test('should throw if provided config file is invalid (cosmiconfig exception)', async () => {
|
|
94
|
+
await assert.rejects(async () => {
|
|
95
|
+
const config = new Config({ config: './test/stub/config/invalid-config-txt' });
|
|
96
|
+
await config.init();
|
|
97
|
+
}, /Invalid configuration file at/);
|
|
85
98
|
});
|
|
86
99
|
|
|
87
|
-
test('should throw if provided config file is invalid (no object)', () => {
|
|
88
|
-
assert.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
);
|
|
100
|
+
test('should throw if provided config file is invalid (no object)', async () => {
|
|
101
|
+
await assert.rejects(async () => {
|
|
102
|
+
const config = new Config({ config: './test/stub/config/invalid-config-rc' });
|
|
103
|
+
await config.init();
|
|
104
|
+
}, /Invalid configuration file at/);
|
|
92
105
|
});
|
|
93
106
|
|
|
94
|
-
test('should not set default increment (for CI mode)', () => {
|
|
107
|
+
test('should not set default increment (for CI mode)', async () => {
|
|
95
108
|
const config = new Config({ ci: true });
|
|
109
|
+
await config.init();
|
|
96
110
|
assert.equal(config.options.version.increment, undefined);
|
|
97
111
|
});
|
|
98
112
|
|
|
99
|
-
test('should not set default increment (for interactive mode)', () => {
|
|
113
|
+
test('should not set default increment (for interactive mode)', async () => {
|
|
100
114
|
const config = new Config({ ci: false });
|
|
115
|
+
await config.init();
|
|
101
116
|
assert.equal(config.options.version.increment, undefined);
|
|
102
117
|
});
|
|
103
118
|
|
|
104
|
-
test('should expand pre-release shortcut', () => {
|
|
119
|
+
test('should expand pre-release shortcut', async () => {
|
|
105
120
|
const config = new Config({ increment: 'major', preRelease: 'beta' });
|
|
121
|
+
await config.init();
|
|
106
122
|
assert.deepEqual(config.options.version, {
|
|
107
123
|
increment: 'major',
|
|
108
124
|
isPreRelease: true,
|
|
@@ -111,8 +127,9 @@ describe('config', () => {
|
|
|
111
127
|
});
|
|
112
128
|
});
|
|
113
129
|
|
|
114
|
-
test('should expand pre-release shortcut (preRelease boolean)', () => {
|
|
130
|
+
test('should expand pre-release shortcut (preRelease boolean)', async () => {
|
|
115
131
|
const config = new Config({ ci: true, preRelease: true });
|
|
132
|
+
await config.init();
|
|
116
133
|
assert.deepEqual(config.options.version, {
|
|
117
134
|
increment: undefined,
|
|
118
135
|
isPreRelease: true,
|
|
@@ -121,8 +138,9 @@ describe('config', () => {
|
|
|
121
138
|
});
|
|
122
139
|
});
|
|
123
140
|
|
|
124
|
-
test('should expand pre-release shortcut (without increment)', () => {
|
|
141
|
+
test('should expand pre-release shortcut (without increment)', async () => {
|
|
125
142
|
const config = new Config({ ci: false, preRelease: 'alpha' });
|
|
143
|
+
await config.init();
|
|
126
144
|
assert.deepEqual(config.options.version, {
|
|
127
145
|
increment: undefined,
|
|
128
146
|
isPreRelease: true,
|
|
@@ -131,8 +149,9 @@ describe('config', () => {
|
|
|
131
149
|
});
|
|
132
150
|
});
|
|
133
151
|
|
|
134
|
-
test('should expand pre-release shortcut (including increment and npm.tag)', () => {
|
|
152
|
+
test('should expand pre-release shortcut (including increment and npm.tag)', async () => {
|
|
135
153
|
const config = new Config({ increment: 'minor', preRelease: 'rc' });
|
|
154
|
+
await config.init();
|
|
136
155
|
assert.deepEqual(config.options.version, {
|
|
137
156
|
increment: 'minor',
|
|
138
157
|
isPreRelease: true,
|
|
@@ -141,8 +160,9 @@ describe('config', () => {
|
|
|
141
160
|
});
|
|
142
161
|
});
|
|
143
162
|
|
|
144
|
-
test('should use pre-release base', () => {
|
|
163
|
+
test('should use pre-release base', async () => {
|
|
145
164
|
const config = new Config({ increment: 'minor', preRelease: 'next', preReleaseBase: '1' });
|
|
165
|
+
await config.init();
|
|
146
166
|
assert.deepEqual(config.options.version, {
|
|
147
167
|
increment: 'minor',
|
|
148
168
|
isPreRelease: true,
|
|
@@ -151,8 +171,9 @@ describe('config', () => {
|
|
|
151
171
|
});
|
|
152
172
|
});
|
|
153
173
|
|
|
154
|
-
test('should expand pre-release shortcut (snapshot)', () => {
|
|
174
|
+
test('should expand pre-release shortcut (snapshot)', async () => {
|
|
155
175
|
const config = new Config({ snapshot: 'feat' });
|
|
176
|
+
await config.init();
|
|
156
177
|
assert.deepEqual(config.options.version, {
|
|
157
178
|
increment: 'prerelease',
|
|
158
179
|
isPreRelease: true,
|
|
@@ -165,7 +186,7 @@ describe('config', () => {
|
|
|
165
186
|
});
|
|
166
187
|
|
|
167
188
|
describe('fetch extended configuration', () => {
|
|
168
|
-
const [mocker, server] = mockFetch('https://
|
|
189
|
+
const [mocker, server] = mockFetch('https://api.github.com');
|
|
169
190
|
|
|
170
191
|
before(() => {
|
|
171
192
|
mocker.mockGlobal();
|
|
@@ -180,86 +201,140 @@ describe('fetch extended configuration', () => {
|
|
|
180
201
|
});
|
|
181
202
|
|
|
182
203
|
test('should fetch extended configuration with default file and default branch', async () => {
|
|
183
|
-
|
|
204
|
+
const extendedConfiguration = {
|
|
205
|
+
git: {
|
|
206
|
+
commitMessage: 'Released version ${version}'
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
server.head('/repos/release-it/release-it-configuration/tarball/main', {
|
|
211
|
+
status: 200,
|
|
212
|
+
headers: {}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
server.get('/repos/release-it/release-it-configuration/tarball/main', {
|
|
184
216
|
status: 200,
|
|
185
|
-
body:
|
|
217
|
+
body: await new Response(
|
|
218
|
+
createTarBlobByRawContents({
|
|
219
|
+
'.release-it.json': JSON.stringify(extendedConfiguration)
|
|
220
|
+
})
|
|
221
|
+
).arrayBuffer()
|
|
186
222
|
});
|
|
187
223
|
|
|
188
|
-
const config = {
|
|
224
|
+
const config = new Config({
|
|
189
225
|
extends: 'github:release-it/release-it-configuration'
|
|
190
|
-
};
|
|
226
|
+
});
|
|
227
|
+
await config.init();
|
|
228
|
+
|
|
229
|
+
assert(mocker.allRoutesCalled());
|
|
230
|
+
|
|
231
|
+
assert.equal(config.options.git.commitMessage, extendedConfiguration.git.commitMessage);
|
|
232
|
+
});
|
|
191
233
|
|
|
234
|
+
test('should fetch extended configuration with default file and specific tag', async () => {
|
|
192
235
|
const extendedConfiguration = {
|
|
193
236
|
git: {
|
|
194
237
|
commitMessage: 'Released version ${version}'
|
|
195
238
|
}
|
|
196
239
|
};
|
|
197
240
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
241
|
+
server.head('/repos/release-it/release-it-configuration/tarball/1.0.0', {
|
|
242
|
+
status: 200,
|
|
243
|
+
headers: {}
|
|
244
|
+
});
|
|
202
245
|
|
|
203
|
-
|
|
204
|
-
server.get('/release-it/release-it-configuration/refs/tags/1.0.0/.release-it.json', {
|
|
246
|
+
server.get('/repos/release-it/release-it-configuration/tarball/1.0.0', {
|
|
205
247
|
status: 200,
|
|
206
|
-
body:
|
|
248
|
+
body: await new Response(
|
|
249
|
+
createTarBlobByRawContents({
|
|
250
|
+
'.release-it.json': JSON.stringify(extendedConfiguration)
|
|
251
|
+
})
|
|
252
|
+
).arrayBuffer()
|
|
207
253
|
});
|
|
208
254
|
|
|
209
|
-
const config = {
|
|
255
|
+
const config = new Config({
|
|
210
256
|
extends: 'github:release-it/release-it-configuration#1.0.0'
|
|
211
|
-
};
|
|
257
|
+
});
|
|
258
|
+
await config.init();
|
|
259
|
+
|
|
260
|
+
assert(mocker.allRoutesCalled());
|
|
212
261
|
|
|
262
|
+
assert.equal(config.options.git.commitMessage, extendedConfiguration.git.commitMessage);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
test('should fetch extended configuration with sub dir and specific tag', async () => {
|
|
213
266
|
const extendedConfiguration = {
|
|
214
267
|
git: {
|
|
215
268
|
commitMessage: 'Released version ${version}'
|
|
216
269
|
}
|
|
217
270
|
};
|
|
218
271
|
|
|
219
|
-
const
|
|
272
|
+
const extendedSubConfiguration = {
|
|
273
|
+
git: {
|
|
274
|
+
commitMessage: 'Released pkg version ${version}'
|
|
275
|
+
}
|
|
276
|
+
};
|
|
220
277
|
|
|
221
|
-
|
|
222
|
-
|
|
278
|
+
server.head('/repos/release-it/release-it-configuration/tarball/1.0.0', {
|
|
279
|
+
status: 200,
|
|
280
|
+
headers: {}
|
|
281
|
+
});
|
|
223
282
|
|
|
224
|
-
|
|
225
|
-
server.get('/release-it/release-it-configuration/refs/tags/1.0.0/config.json', {
|
|
283
|
+
server.get('/repos/release-it/release-it-configuration/tarball/1.0.0', {
|
|
226
284
|
status: 200,
|
|
227
|
-
body:
|
|
285
|
+
body: await new Response(
|
|
286
|
+
createTarBlobByRawContents({
|
|
287
|
+
'.release-it.json': JSON.stringify(extendedConfiguration),
|
|
288
|
+
'sub/.release-it.json': JSON.stringify(extendedSubConfiguration)
|
|
289
|
+
})
|
|
290
|
+
).arrayBuffer()
|
|
228
291
|
});
|
|
229
292
|
|
|
230
|
-
const config = {
|
|
231
|
-
extends: 'github:release-it/release-it-configuration
|
|
232
|
-
};
|
|
293
|
+
const config = new Config({
|
|
294
|
+
extends: 'github:release-it/release-it-configuration/sub#1.0.0'
|
|
295
|
+
});
|
|
296
|
+
await config.init();
|
|
297
|
+
|
|
298
|
+
assert(mocker.allRoutesCalled());
|
|
299
|
+
|
|
300
|
+
assert.equal(config.options.git.commitMessage, extendedSubConfiguration.git.commitMessage);
|
|
301
|
+
});
|
|
233
302
|
|
|
303
|
+
test('should fetch extended configuration with custom file and default branch', async () => {
|
|
234
304
|
const extendedConfiguration = {
|
|
235
305
|
git: {
|
|
236
306
|
commitMessage: 'Released version ${version}'
|
|
237
307
|
}
|
|
238
308
|
};
|
|
239
309
|
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
310
|
+
const extendedSubConfiguration = {
|
|
311
|
+
git: {
|
|
312
|
+
commitMessage: 'Released pkg version ${version}'
|
|
313
|
+
}
|
|
314
|
+
};
|
|
244
315
|
|
|
245
|
-
|
|
246
|
-
server.get('/release-it/release-it-configuration/HEAD/config.json', {
|
|
316
|
+
server.head('/repos/release-it/release-it-configuration/tarball/main', {
|
|
247
317
|
status: 200,
|
|
248
|
-
|
|
318
|
+
headers: {}
|
|
249
319
|
});
|
|
250
320
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
321
|
+
server.get('/repos/release-it/release-it-configuration/tarball/main', {
|
|
322
|
+
status: 200,
|
|
323
|
+
body: await new Response(
|
|
324
|
+
createTarBlobByRawContents({
|
|
325
|
+
'.release-it.json': JSON.stringify(extendedConfiguration),
|
|
326
|
+
'sub/.release-it.json': JSON.stringify(extendedSubConfiguration)
|
|
327
|
+
})
|
|
328
|
+
).arrayBuffer()
|
|
329
|
+
});
|
|
254
330
|
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
};
|
|
331
|
+
const config = new Config({
|
|
332
|
+
extends: 'github:release-it/release-it-configuration/sub'
|
|
333
|
+
});
|
|
334
|
+
await config.init();
|
|
260
335
|
|
|
261
|
-
|
|
336
|
+
assert(mocker.allRoutesCalled());
|
|
262
337
|
|
|
263
|
-
assert.
|
|
338
|
+
assert.equal(config.options.git.commitMessage, extendedSubConfiguration.git.commitMessage);
|
|
264
339
|
});
|
|
265
340
|
});
|
package/test/git.init.js
CHANGED
|
@@ -26,59 +26,59 @@ describe('git.init', () => {
|
|
|
26
26
|
|
|
27
27
|
test('should throw if on wrong branch', async () => {
|
|
28
28
|
const options = { git: { requireBranch: 'dev' } };
|
|
29
|
-
const gitClient = factory(Git, { options });
|
|
29
|
+
const gitClient = await factory(Git, { options });
|
|
30
30
|
childProcess.execSync('git remote remove origin', execOpts);
|
|
31
31
|
await assert.rejects(gitClient.init(), /Must be on branch dev/);
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
test('should throw if on negated branch', async () => {
|
|
35
35
|
const options = { git: { requireBranch: '!main' } };
|
|
36
|
-
const gitClient = factory(Git, { options });
|
|
36
|
+
const gitClient = await factory(Git, { options });
|
|
37
37
|
sh.exec('git checkout -b main', execOpts);
|
|
38
38
|
await assert.rejects(gitClient.init(), /Must be on branch !main/);
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
test('should not throw if required branch matches', async () => {
|
|
42
42
|
const options = { git: { requireBranch: 'ma?*' } };
|
|
43
|
-
const gitClient = factory(Git, { options });
|
|
43
|
+
const gitClient = await factory(Git, { options });
|
|
44
44
|
await assert.doesNotReject(gitClient.init());
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
test('should not throw if one of required branch matches', async () => {
|
|
48
48
|
const options = { git: { requireBranch: ['release/*', 'hotfix/*'] } };
|
|
49
|
-
const gitClient = factory(Git, { options });
|
|
49
|
+
const gitClient = await factory(Git, { options });
|
|
50
50
|
childProcess.execSync('git checkout -b release/v1', execOpts);
|
|
51
51
|
await assert.doesNotReject(gitClient.init());
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
test('should throw if there is no remote Git url', async () => {
|
|
55
|
-
const gitClient = factory(Git, { options: { git } });
|
|
55
|
+
const gitClient = await factory(Git, { options: { git } });
|
|
56
56
|
childProcess.execSync('git remote remove origin', execOpts);
|
|
57
57
|
await assert.rejects(gitClient.init(), /Could not get remote Git url/);
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
test('should throw if working dir is not clean', async () => {
|
|
61
|
-
const gitClient = factory(Git, { options: { git } });
|
|
61
|
+
const gitClient = await factory(Git, { options: { git } });
|
|
62
62
|
childProcess.execSync('rm file', execOpts);
|
|
63
63
|
await assert.rejects(gitClient.init(), /Working dir must be clean/);
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
test('should throw if no upstream is configured', async () => {
|
|
67
|
-
const gitClient = factory(Git, { options: { git } });
|
|
67
|
+
const gitClient = await factory(Git, { options: { git } });
|
|
68
68
|
childProcess.execSync('git checkout -b foo', execOpts);
|
|
69
69
|
await assert.rejects(gitClient.init(), /No upstream configured for current branch/);
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
test('should throw if there are no commits', async () => {
|
|
73
73
|
const options = { git: { requireCommits: true } };
|
|
74
|
-
const gitClient = factory(Git, { options });
|
|
74
|
+
const gitClient = await factory(Git, { options });
|
|
75
75
|
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
76
76
|
await assert.rejects(gitClient.init(), /There are no commits since the latest tag/);
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
test('should not throw if there are commits', async () => {
|
|
80
80
|
const options = { git: { requireCommits: true } };
|
|
81
|
-
const gitClient = factory(Git, { options });
|
|
81
|
+
const gitClient = await factory(Git, { options });
|
|
82
82
|
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
83
83
|
gitAdd('line', 'file', 'Add file');
|
|
84
84
|
await assert.doesNotReject(gitClient.init(), 'There are no commits since the latest tag');
|
|
@@ -86,21 +86,21 @@ describe('git.init', () => {
|
|
|
86
86
|
|
|
87
87
|
test('should fail (exit code 1) if there are no commits', async () => {
|
|
88
88
|
const options = { git: { requireCommits: true } };
|
|
89
|
-
const gitClient = factory(Git, { options });
|
|
89
|
+
const gitClient = await factory(Git, { options });
|
|
90
90
|
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
91
91
|
await assert.rejects(gitClient.init(), { code: 1 });
|
|
92
92
|
});
|
|
93
93
|
|
|
94
94
|
test('should not fail (exit code 0) if there are no commits', async () => {
|
|
95
95
|
const options = { git: { requireCommits: true, requireCommitsFail: false } };
|
|
96
|
-
const gitClient = factory(Git, { options });
|
|
96
|
+
const gitClient = await factory(Git, { options });
|
|
97
97
|
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
98
98
|
await assert.rejects(gitClient.init(), { code: 0 });
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
test('should throw if there are no commits in specified path', async () => {
|
|
102
102
|
const options = { git: { requireCommits: true, commitsPath: 'dir' } };
|
|
103
|
-
const gitClient = factory(Git, { options });
|
|
103
|
+
const gitClient = await factory(Git, { options });
|
|
104
104
|
mkdirSync('dir', { recursive: true });
|
|
105
105
|
sh.exec('git tag 1.0.0', execOpts);
|
|
106
106
|
await assert.rejects(gitClient.init(), { message: /^There are no commits since the latest tag/ });
|
|
@@ -108,7 +108,7 @@ describe('git.init', () => {
|
|
|
108
108
|
|
|
109
109
|
test('should not throw if there are commits in specified path', async () => {
|
|
110
110
|
const options = { git: { requireCommits: true, commitsPath: 'dir' } };
|
|
111
|
-
const gitClient = factory(Git, { options });
|
|
111
|
+
const gitClient = await factory(Git, { options });
|
|
112
112
|
sh.exec('git tag 1.0.0', execOpts);
|
|
113
113
|
gitAdd('line', 'dir/file', 'Add file');
|
|
114
114
|
await assert.doesNotReject(gitClient.init());
|
|
@@ -116,19 +116,19 @@ describe('git.init', () => {
|
|
|
116
116
|
|
|
117
117
|
test('should not throw if there are no tags', async () => {
|
|
118
118
|
const options = { git: { requireCommits: true } };
|
|
119
|
-
const gitClient = factory(Git, { options });
|
|
119
|
+
const gitClient = await factory(Git, { options });
|
|
120
120
|
gitAdd('line', 'file', 'Add file');
|
|
121
121
|
await assert.doesNotReject(gitClient.init());
|
|
122
122
|
});
|
|
123
123
|
|
|
124
124
|
test('should not throw if origin remote is renamed', async () => {
|
|
125
125
|
childProcess.execSync('git remote rename origin upstream', execOpts);
|
|
126
|
-
const gitClient = factory(Git);
|
|
126
|
+
const gitClient = await factory(Git);
|
|
127
127
|
await assert.doesNotReject(gitClient.init());
|
|
128
128
|
});
|
|
129
129
|
|
|
130
130
|
test('should detect and include version prefix ("v")', async () => {
|
|
131
|
-
const gitClient = factory(Git, { options: { git } });
|
|
131
|
+
const gitClient = await factory(Git, { options: { git } });
|
|
132
132
|
childProcess.execSync('git tag v1.0.0', execOpts);
|
|
133
133
|
await gitClient.init();
|
|
134
134
|
await gitClient.bump('1.0.1');
|
|
@@ -136,7 +136,7 @@ describe('git.init', () => {
|
|
|
136
136
|
});
|
|
137
137
|
|
|
138
138
|
test('should detect and exclude version prefix', async () => {
|
|
139
|
-
const gitClient = factory(Git, { options: { git } });
|
|
139
|
+
const gitClient = await factory(Git, { options: { git } });
|
|
140
140
|
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
141
141
|
await gitClient.init();
|
|
142
142
|
await gitClient.bump('1.0.1');
|
|
@@ -144,7 +144,7 @@ describe('git.init', () => {
|
|
|
144
144
|
});
|
|
145
145
|
|
|
146
146
|
test('should detect and exclude version prefix (configured)', async () => {
|
|
147
|
-
const gitClient = factory(Git, { options: { git: { tagName: 'v${version}' } } });
|
|
147
|
+
const gitClient = await factory(Git, { options: { git: { tagName: 'v${version}' } } });
|
|
148
148
|
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
149
149
|
await gitClient.init();
|
|
150
150
|
await gitClient.bump('1.0.1');
|
|
@@ -152,7 +152,7 @@ describe('git.init', () => {
|
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
test('should honor custom tagName configuration', async () => {
|
|
155
|
-
const gitClient = factory(Git, { options: { git: { tagName: 'TAGNAME-${repo.project}-v${version}' } } });
|
|
155
|
+
const gitClient = await factory(Git, { options: { git: { tagName: 'TAGNAME-${repo.project}-v${version}' } } });
|
|
156
156
|
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
157
157
|
await gitClient.init();
|
|
158
158
|
await gitClient.bump('1.0.1');
|
|
@@ -161,8 +161,8 @@ describe('git.init', () => {
|
|
|
161
161
|
});
|
|
162
162
|
|
|
163
163
|
test('should get the latest tag after fetch', async () => {
|
|
164
|
-
const shell = factory(Shell);
|
|
165
|
-
const gitClient = factory(Git, { container: { shell } });
|
|
164
|
+
const shell = await factory(Shell);
|
|
165
|
+
const gitClient = await factory(Git, { container: { shell } });
|
|
166
166
|
const other = mkTmpDir();
|
|
167
167
|
childProcess.execSync('git push', execOpts);
|
|
168
168
|
childProcess.execSync(`git clone ${bare} ${other}`, execOpts);
|
|
@@ -176,8 +176,8 @@ describe('git.init', () => {
|
|
|
176
176
|
});
|
|
177
177
|
|
|
178
178
|
test('should get the latest custom tag after fetch when tagName is configured', async () => {
|
|
179
|
-
const shell = factory(Shell);
|
|
180
|
-
const gitClient = factory(Git, {
|
|
179
|
+
const shell = await factory(Shell);
|
|
180
|
+
const gitClient = await factory(Git, {
|
|
181
181
|
options: { git: { tagName: 'TAGNAME-v${version}' } },
|
|
182
182
|
container: { shell }
|
|
183
183
|
});
|
|
@@ -195,8 +195,8 @@ describe('git.init', () => {
|
|
|
195
195
|
});
|
|
196
196
|
|
|
197
197
|
test('should get the latest tag based on tagMatch', async () => {
|
|
198
|
-
const shell = factory(Shell);
|
|
199
|
-
const gitClient = factory(Git, {
|
|
198
|
+
const shell = await factory(Shell);
|
|
199
|
+
const gitClient = await factory(Git, {
|
|
200
200
|
options: { git: { tagMatch: '[0-9][0-9]\\.[0-1][0-9]\\.[0-9]*' } },
|
|
201
201
|
container: { shell }
|
|
202
202
|
});
|
|
@@ -209,8 +209,8 @@ describe('git.init', () => {
|
|
|
209
209
|
});
|
|
210
210
|
|
|
211
211
|
test('should get the latest tag based on tagExclude', async () => {
|
|
212
|
-
const shell = factory(Shell);
|
|
213
|
-
const gitClient = factory(Git, {
|
|
212
|
+
const shell = await factory(Shell);
|
|
213
|
+
const gitClient = await factory(Git, {
|
|
214
214
|
options: { git: { tagExclude: '*[-]*' } },
|
|
215
215
|
container: { shell }
|
|
216
216
|
});
|
|
@@ -226,7 +226,7 @@ describe('git.init', () => {
|
|
|
226
226
|
});
|
|
227
227
|
|
|
228
228
|
test('should generate correct changelog', async () => {
|
|
229
|
-
const gitClient = factory(Git, { options: { git } });
|
|
229
|
+
const gitClient = await factory(Git, { options: { git } });
|
|
230
230
|
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
231
231
|
gitAdd('line', 'file', 'Add file');
|
|
232
232
|
gitAdd('line', 'file', 'Add file');
|
|
@@ -236,8 +236,8 @@ describe('git.init', () => {
|
|
|
236
236
|
});
|
|
237
237
|
|
|
238
238
|
test('should get the full changelog since latest major tag', async () => {
|
|
239
|
-
const shell = factory(Shell);
|
|
240
|
-
const gitClient = factory(Git, {
|
|
239
|
+
const shell = await factory(Shell);
|
|
240
|
+
const gitClient = await factory(Git, {
|
|
241
241
|
options: { git: { tagMatch: '[0-9]\\.[0-9]\\.[0-9]', changelog: git.changelog } },
|
|
242
242
|
container: { shell }
|
|
243
243
|
});
|