release-it 19.0.0-next.0 → 19.0.0-next.2
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/lib/cli.js +2 -5
- package/lib/config.js +42 -7
- package/lib/index.js +30 -14
- package/lib/log.js +12 -11
- package/lib/plugin/GitBase.js +2 -1
- package/lib/plugin/GitRelease.js +5 -5
- package/lib/plugin/Plugin.js +6 -4
- package/lib/plugin/factory.js +11 -11
- package/lib/plugin/git/Git.js +5 -6
- package/lib/plugin/github/GitHub.js +13 -16
- package/lib/plugin/github/util.js +1 -1
- package/lib/plugin/gitlab/GitLab.js +6 -4
- package/lib/plugin/npm/npm.js +4 -0
- package/lib/util.js +71 -42
- package/package.json +27 -29
- package/schema/gitlab.json +4 -0
- package/schema/release-it.json +4 -0
- package/test/cli.js +6 -5
- package/test/config.js +232 -122
- package/test/git.init.js +220 -218
- package/test/git.js +359 -364
- package/test/github.js +565 -480
- package/test/gitlab.js +374 -335
- package/test/log.js +141 -138
- package/test/npm.js +315 -373
- package/test/plugin-name.js +7 -6
- package/test/plugins.js +200 -211
- package/test/prompt.js +26 -32
- package/test/shell.js +63 -60
- package/test/spinner.js +20 -24
- package/test/stub/github.js +113 -123
- package/test/stub/gitlab.js +74 -52
- package/test/tasks.interactive.js +217 -165
- package/test/tasks.js +394 -413
- package/test/util/helpers.js +4 -3
- package/test/util/index.js +35 -11
- package/test/utils.js +33 -32
- package/test/version.js +192 -176
- package/test/util/setup.js +0 -3
package/test/config.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import test from '
|
|
1
|
+
import test, { describe, before, after, afterEach } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
2
3
|
import { isCI } from 'ci-info';
|
|
3
|
-
import
|
|
4
|
+
import { MockServer, FetchMocker } from 'mentoss';
|
|
5
|
+
import Config, { getRemoteConfiguration } from '../lib/config.js';
|
|
4
6
|
import { readJSON } from '../lib/util.js';
|
|
5
7
|
|
|
6
8
|
const defaultConfig = readJSON(new URL('../config/release-it.json', import.meta.url));
|
|
@@ -8,152 +10,260 @@ const projectConfig = readJSON(new URL('../.release-it.json', import.meta.url));
|
|
|
8
10
|
|
|
9
11
|
const localConfig = { github: { release: true } };
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
describe('config', () => {
|
|
14
|
+
test("should read this project's own configuration", () => {
|
|
15
|
+
const config = new Config();
|
|
16
|
+
assert.deepEqual(config.constructorConfig, {});
|
|
17
|
+
assert.deepEqual(config.localConfig, projectConfig);
|
|
18
|
+
assert.deepEqual(config.defaultConfig, defaultConfig);
|
|
19
|
+
});
|
|
17
20
|
|
|
18
|
-
test('should contain default values',
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
21
|
+
test('should contain default values', () => {
|
|
22
|
+
const config = new Config({ configDir: './test/stub/config/default' });
|
|
23
|
+
assert.deepEqual(config.constructorConfig, { configDir: './test/stub/config/default' });
|
|
24
|
+
assert.deepEqual(config.localConfig, localConfig);
|
|
25
|
+
assert.deepEqual(config.defaultConfig, defaultConfig);
|
|
26
|
+
});
|
|
24
27
|
|
|
25
|
-
test('should merge provided options',
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
28
|
+
test('should merge provided options', () => {
|
|
29
|
+
const config = new Config({
|
|
30
|
+
configDir: './test/stub/config/merge',
|
|
31
|
+
increment: '1.0.0',
|
|
32
|
+
verbose: true,
|
|
33
|
+
github: {
|
|
34
|
+
release: true
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const { options } = config;
|
|
38
|
+
assert.equal(config.isVerbose, true);
|
|
39
|
+
assert.equal(config.isDryRun, false);
|
|
40
|
+
assert.equal(options.increment, '1.0.0');
|
|
41
|
+
assert.equal(options.git.push, false);
|
|
42
|
+
assert.equal(options.github.release, true);
|
|
43
|
+
});
|
|
41
44
|
|
|
42
|
-
test('should set CI mode',
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
45
|
+
test('should set CI mode', () => {
|
|
46
|
+
const config = new Config({ ci: true });
|
|
47
|
+
assert.equal(config.isCI, true);
|
|
48
|
+
});
|
|
46
49
|
|
|
47
|
-
test('should detect CI mode',
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
});
|
|
50
|
+
test('should detect CI mode', () => {
|
|
51
|
+
const config = new Config();
|
|
52
|
+
assert.equal(config.options.ci, isCI);
|
|
53
|
+
assert.equal(config.isCI, isCI);
|
|
54
|
+
});
|
|
52
55
|
|
|
53
|
-
test('should override --no-npm.publish',
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
56
|
+
test('should override --no-npm.publish', () => {
|
|
57
|
+
const config = new Config({ npm: { publish: false } });
|
|
58
|
+
assert.equal(config.options.npm.publish, false);
|
|
59
|
+
});
|
|
57
60
|
|
|
58
|
-
test('should read YAML config',
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
});
|
|
61
|
+
test('should read YAML config', () => {
|
|
62
|
+
const config = new Config({ configDir: './test/stub/config/yaml' });
|
|
63
|
+
assert.deepEqual(config.options.foo, { bar: 1 });
|
|
64
|
+
});
|
|
62
65
|
|
|
63
|
-
test('should read YML config',
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
});
|
|
66
|
+
test('should read YML config', () => {
|
|
67
|
+
const config = new Config({ configDir: './test/stub/config/yml' });
|
|
68
|
+
assert.deepEqual(config.options.foo, { bar: 1 });
|
|
69
|
+
});
|
|
67
70
|
|
|
68
|
-
test('should read TOML config',
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
});
|
|
71
|
+
test('should read TOML config', () => {
|
|
72
|
+
const config = new Config({ configDir: './test/stub/config/toml' });
|
|
73
|
+
assert.deepEqual(config.options.foo, { bar: 1 });
|
|
74
|
+
});
|
|
72
75
|
|
|
73
|
-
test('should throw if provided config file is not found',
|
|
74
|
-
|
|
75
|
-
});
|
|
76
|
+
test('should throw if provided config file is not found', () => {
|
|
77
|
+
assert.throws(() => new Config({ config: 'nofile' }), /no such file.+nofile/);
|
|
78
|
+
});
|
|
76
79
|
|
|
77
|
-
test('should throw if provided config file is invalid (cosmiconfig exception)',
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
test('should throw if provided config file is invalid (cosmiconfig exception)', () => {
|
|
81
|
+
assert.throws(
|
|
82
|
+
() => new Config({ config: './test/stub/config/invalid-config-txt' }),
|
|
83
|
+
/Invalid configuration file at/
|
|
84
|
+
);
|
|
80
85
|
});
|
|
81
|
-
});
|
|
82
86
|
|
|
83
|
-
test('should throw if provided config file is invalid (no object)',
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
test('should throw if provided config file is invalid (no object)', () => {
|
|
88
|
+
assert.throws(
|
|
89
|
+
() => new Config({ config: './test/stub/config/invalid-config-rc' }),
|
|
90
|
+
/Invalid configuration file at/
|
|
91
|
+
);
|
|
86
92
|
});
|
|
87
|
-
});
|
|
88
93
|
|
|
89
|
-
test('should not set default increment (for CI mode)',
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
});
|
|
94
|
+
test('should not set default increment (for CI mode)', () => {
|
|
95
|
+
const config = new Config({ ci: true });
|
|
96
|
+
assert.equal(config.options.version.increment, undefined);
|
|
97
|
+
});
|
|
93
98
|
|
|
94
|
-
test('should not set default increment (for interactive mode)',
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
});
|
|
99
|
+
test('should not set default increment (for interactive mode)', () => {
|
|
100
|
+
const config = new Config({ ci: false });
|
|
101
|
+
assert.equal(config.options.version.increment, undefined);
|
|
102
|
+
});
|
|
98
103
|
|
|
99
|
-
test('should expand pre-release shortcut',
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
test('should expand pre-release shortcut', () => {
|
|
105
|
+
const config = new Config({ increment: 'major', preRelease: 'beta' });
|
|
106
|
+
assert.deepEqual(config.options.version, {
|
|
107
|
+
increment: 'major',
|
|
108
|
+
isPreRelease: true,
|
|
109
|
+
preReleaseBase: undefined,
|
|
110
|
+
preReleaseId: 'beta'
|
|
111
|
+
});
|
|
106
112
|
});
|
|
107
|
-
});
|
|
108
113
|
|
|
109
|
-
test('should expand pre-release shortcut (preRelease boolean)',
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
test('should expand pre-release shortcut (preRelease boolean)', () => {
|
|
115
|
+
const config = new Config({ ci: true, preRelease: true });
|
|
116
|
+
assert.deepEqual(config.options.version, {
|
|
117
|
+
increment: undefined,
|
|
118
|
+
isPreRelease: true,
|
|
119
|
+
preReleaseBase: undefined,
|
|
120
|
+
preReleaseId: undefined
|
|
121
|
+
});
|
|
116
122
|
});
|
|
117
|
-
});
|
|
118
123
|
|
|
119
|
-
test('should expand pre-release shortcut (without increment)',
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
test('should expand pre-release shortcut (without increment)', () => {
|
|
125
|
+
const config = new Config({ ci: false, preRelease: 'alpha' });
|
|
126
|
+
assert.deepEqual(config.options.version, {
|
|
127
|
+
increment: undefined,
|
|
128
|
+
isPreRelease: true,
|
|
129
|
+
preReleaseBase: undefined,
|
|
130
|
+
preReleaseId: 'alpha'
|
|
131
|
+
});
|
|
126
132
|
});
|
|
127
|
-
});
|
|
128
133
|
|
|
129
|
-
test('should expand pre-release shortcut (including increment and npm.tag)',
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
test('should expand pre-release shortcut (including increment and npm.tag)', () => {
|
|
135
|
+
const config = new Config({ increment: 'minor', preRelease: 'rc' });
|
|
136
|
+
assert.deepEqual(config.options.version, {
|
|
137
|
+
increment: 'minor',
|
|
138
|
+
isPreRelease: true,
|
|
139
|
+
preReleaseBase: undefined,
|
|
140
|
+
preReleaseId: 'rc'
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test('should use pre-release base', () => {
|
|
145
|
+
const config = new Config({ increment: 'minor', preRelease: 'next', preReleaseBase: '1' });
|
|
146
|
+
assert.deepEqual(config.options.version, {
|
|
147
|
+
increment: 'minor',
|
|
148
|
+
isPreRelease: true,
|
|
149
|
+
preReleaseBase: '1',
|
|
150
|
+
preReleaseId: 'next'
|
|
151
|
+
});
|
|
136
152
|
});
|
|
137
|
-
});
|
|
138
153
|
|
|
139
|
-
test('should
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
154
|
+
test('should expand pre-release shortcut (snapshot)', () => {
|
|
155
|
+
const config = new Config({ snapshot: 'feat' });
|
|
156
|
+
assert.deepEqual(config.options.version, {
|
|
157
|
+
increment: 'prerelease',
|
|
158
|
+
isPreRelease: true,
|
|
159
|
+
preReleaseBase: undefined,
|
|
160
|
+
preReleaseId: 'feat'
|
|
161
|
+
});
|
|
162
|
+
assert.equal(config.options.git.tagMatch, '0.0.0-feat.[0-9]*');
|
|
163
|
+
assert.equal(config.options.git.getLatestTagFromAllRefs, true);
|
|
146
164
|
});
|
|
147
165
|
});
|
|
148
166
|
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
167
|
+
describe('fetch extended configuration', () => {
|
|
168
|
+
const server = new MockServer('https://raw.githubusercontent.com');
|
|
169
|
+
|
|
170
|
+
const mocker = new FetchMocker({
|
|
171
|
+
servers: [server]
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
before(() => {
|
|
175
|
+
mocker.mockGlobal();
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
afterEach(() => {
|
|
179
|
+
mocker.clearAll();
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
after(() => {
|
|
183
|
+
mocker.unmockGlobal();
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test('should fetch extended configuration with default file and default branch', async () => {
|
|
187
|
+
server.get('/release-it/release-it-configuration/HEAD/.release-it.json', {
|
|
188
|
+
status: 200,
|
|
189
|
+
body: { git: { commitMessage: 'Released version ${version}' } }
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
const config = {
|
|
193
|
+
extends: 'github:release-it/release-it-configuration'
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const extendedConfiguration = {
|
|
197
|
+
git: {
|
|
198
|
+
commitMessage: 'Released version ${version}'
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const response = await getRemoteConfiguration(config.extends);
|
|
203
|
+
|
|
204
|
+
assert.deepEqual(response, extendedConfiguration);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
test('should fetch extended configuration with default file and specific tag', async () => {
|
|
208
|
+
server.get('/release-it/release-it-configuration/refs/tags/1.0.0/.release-it.json', {
|
|
209
|
+
status: 200,
|
|
210
|
+
body: { git: { commitMessage: 'Released version ${version}' } }
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
const config = {
|
|
214
|
+
extends: 'github:release-it/release-it-configuration#1.0.0'
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const extendedConfiguration = {
|
|
218
|
+
git: {
|
|
219
|
+
commitMessage: 'Released version ${version}'
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const response = await getRemoteConfiguration(config.extends);
|
|
224
|
+
|
|
225
|
+
assert.deepEqual(response, extendedConfiguration);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
test('should fetch extended configuration with custom file and specific tag', async () => {
|
|
229
|
+
server.get('/release-it/release-it-configuration/refs/tags/1.0.0/config.json', {
|
|
230
|
+
status: 200,
|
|
231
|
+
body: { git: { commitMessage: 'Released version ${version}' } }
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
const config = {
|
|
235
|
+
extends: 'github:release-it/release-it-configuration:config.json#1.0.0'
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
const extendedConfiguration = {
|
|
239
|
+
git: {
|
|
240
|
+
commitMessage: 'Released version ${version}'
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const response = await getRemoteConfiguration(config.extends);
|
|
245
|
+
|
|
246
|
+
assert.deepEqual(response, extendedConfiguration);
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
test('should fetch extended configuration with custom file and default branch', async () => {
|
|
250
|
+
server.get('/release-it/release-it-configuration/HEAD/config.json', {
|
|
251
|
+
status: 200,
|
|
252
|
+
body: { git: { commitMessage: 'Released version ${version}' } }
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
const config = {
|
|
256
|
+
extends: 'github:release-it/release-it-configuration:config.json'
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
const extendedConfiguration = {
|
|
260
|
+
git: {
|
|
261
|
+
commitMessage: 'Released version ${version}'
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
const response = await getRemoteConfiguration(config.extends);
|
|
266
|
+
|
|
267
|
+
assert.deepEqual(response, extendedConfiguration);
|
|
156
268
|
});
|
|
157
|
-
t.is(config.options.git.tagMatch, '0.0.0-feat.[0-9]*');
|
|
158
|
-
t.true(config.options.git.getLatestTagFromAllRefs);
|
|
159
269
|
});
|