release-it 19.0.0-next.1 → 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 +34 -2
- package/lib/index.js +26 -9
- package/lib/log.js +4 -4
- package/lib/plugin/github/GitHub.js +2 -6
- package/lib/plugin/github/util.js +1 -1
- package/lib/plugin/gitlab/GitLab.js +4 -1
- package/lib/plugin/npm/npm.js +4 -0
- package/package.json +13 -19
- 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 -164
- package/test/tasks.js +394 -412
- package/test/util/helpers.js +4 -3
- package/test/util/index.js +34 -7
- package/test/utils.js +33 -32
- package/test/version.js +192 -176
- package/test/util/setup.js +0 -3
package/test/git.init.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import childProcess from 'node:child_process';
|
|
2
|
+
import test, { beforeEach, describe } from 'node:test';
|
|
2
3
|
import { mkdirSync } from 'node:fs';
|
|
3
|
-
import
|
|
4
|
+
import assert from 'node:assert/strict';
|
|
4
5
|
import Shell from '../lib/shell.js';
|
|
5
6
|
import Git from '../lib/plugin/git/Git.js';
|
|
6
7
|
import { execOpts, readJSON } from '../lib/util.js';
|
|
@@ -8,246 +9,247 @@ import sh from './util/sh.js';
|
|
|
8
9
|
import { factory } from './util/index.js';
|
|
9
10
|
import { mkTmpDir, gitAdd } from './util/helpers.js';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
describe('git.init', () => {
|
|
13
|
+
const { git } = readJSON(new URL('../config/release-it.json', import.meta.url));
|
|
14
|
+
|
|
15
|
+
let bare;
|
|
16
|
+
let target;
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
bare = mkTmpDir();
|
|
19
|
+
target = mkTmpDir();
|
|
20
|
+
process.chdir(bare);
|
|
21
|
+
sh.exec(`git init --bare .`, execOpts);
|
|
22
|
+
sh.exec(`git clone ${bare} ${target}`, execOpts);
|
|
23
|
+
process.chdir(target);
|
|
24
|
+
gitAdd('line', 'file', 'Add file');
|
|
25
|
+
});
|
|
23
26
|
|
|
24
|
-
test
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
27
|
+
test('should throw if on wrong branch', async () => {
|
|
28
|
+
const options = { git: { requireBranch: 'dev' } };
|
|
29
|
+
const gitClient = factory(Git, { options });
|
|
30
|
+
childProcess.execSync('git remote remove origin', execOpts);
|
|
31
|
+
await assert.rejects(gitClient.init(), /Must be on branch dev/);
|
|
32
|
+
});
|
|
30
33
|
|
|
31
|
-
test
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
});
|
|
34
|
+
test('should throw if on negated branch', async () => {
|
|
35
|
+
const options = { git: { requireBranch: '!main' } };
|
|
36
|
+
const gitClient = factory(Git, { options });
|
|
37
|
+
sh.exec('git checkout -b main', execOpts);
|
|
38
|
+
await assert.rejects(gitClient.init(), /Must be on branch !main/);
|
|
39
|
+
});
|
|
37
40
|
|
|
38
|
-
test
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
41
|
+
test('should not throw if required branch matches', async () => {
|
|
42
|
+
const options = { git: { requireBranch: 'ma?*' } };
|
|
43
|
+
const gitClient = factory(Git, { options });
|
|
44
|
+
await assert.doesNotReject(gitClient.init());
|
|
45
|
+
});
|
|
43
46
|
|
|
44
|
-
test
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
47
|
+
test('should not throw if one of required branch matches', async () => {
|
|
48
|
+
const options = { git: { requireBranch: ['release/*', 'hotfix/*'] } };
|
|
49
|
+
const gitClient = factory(Git, { options });
|
|
50
|
+
childProcess.execSync('git checkout -b release/v1', execOpts);
|
|
51
|
+
await assert.doesNotReject(gitClient.init());
|
|
52
|
+
});
|
|
50
53
|
|
|
51
|
-
test
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
});
|
|
54
|
+
test('should throw if there is no remote Git url', async () => {
|
|
55
|
+
const gitClient = factory(Git, { options: { git } });
|
|
56
|
+
childProcess.execSync('git remote remove origin', execOpts);
|
|
57
|
+
await assert.rejects(gitClient.init(), /Could not get remote Git url/);
|
|
58
|
+
});
|
|
56
59
|
|
|
57
|
-
test
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
});
|
|
60
|
+
test('should throw if working dir is not clean', async () => {
|
|
61
|
+
const gitClient = factory(Git, { options: { git } });
|
|
62
|
+
childProcess.execSync('rm file', execOpts);
|
|
63
|
+
await assert.rejects(gitClient.init(), /Working dir must be clean/);
|
|
64
|
+
});
|
|
62
65
|
|
|
63
|
-
test
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
66
|
+
test('should throw if no upstream is configured', async () => {
|
|
67
|
+
const gitClient = factory(Git, { options: { git } });
|
|
68
|
+
childProcess.execSync('git checkout -b foo', execOpts);
|
|
69
|
+
await assert.rejects(gitClient.init(), /No upstream configured for current branch/);
|
|
70
|
+
});
|
|
68
71
|
|
|
69
|
-
test
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
});
|
|
72
|
+
test('should throw if there are no commits', async () => {
|
|
73
|
+
const options = { git: { requireCommits: true } };
|
|
74
|
+
const gitClient = factory(Git, { options });
|
|
75
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
76
|
+
await assert.rejects(gitClient.init(), /There are no commits since the latest tag/);
|
|
77
|
+
});
|
|
75
78
|
|
|
76
|
-
test
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
});
|
|
79
|
+
test('should not throw if there are commits', async () => {
|
|
80
|
+
const options = { git: { requireCommits: true } };
|
|
81
|
+
const gitClient = factory(Git, { options });
|
|
82
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
83
|
+
gitAdd('line', 'file', 'Add file');
|
|
84
|
+
await assert.doesNotReject(gitClient.init(), 'There are no commits since the latest tag');
|
|
85
|
+
});
|
|
83
86
|
|
|
84
|
-
test
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
});
|
|
87
|
+
test('should fail (exit code 1) if there are no commits', async () => {
|
|
88
|
+
const options = { git: { requireCommits: true } };
|
|
89
|
+
const gitClient = factory(Git, { options });
|
|
90
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
91
|
+
await assert.rejects(gitClient.init(), { code: 1 });
|
|
92
|
+
});
|
|
90
93
|
|
|
91
|
-
test
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
});
|
|
94
|
+
test('should not fail (exit code 0) if there are no commits', async () => {
|
|
95
|
+
const options = { git: { requireCommits: true, requireCommitsFail: false } };
|
|
96
|
+
const gitClient = factory(Git, { options });
|
|
97
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
98
|
+
await assert.rejects(gitClient.init(), { code: 0 });
|
|
99
|
+
});
|
|
97
100
|
|
|
98
|
-
test
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
});
|
|
101
|
+
test('should throw if there are no commits in specified path', async () => {
|
|
102
|
+
const options = { git: { requireCommits: true, commitsPath: 'dir' } };
|
|
103
|
+
const gitClient = factory(Git, { options });
|
|
104
|
+
mkdirSync('dir', { recursive: true });
|
|
105
|
+
sh.exec('git tag 1.0.0', execOpts);
|
|
106
|
+
await assert.rejects(gitClient.init(), { message: /^There are no commits since the latest tag/ });
|
|
107
|
+
});
|
|
105
108
|
|
|
106
|
-
test
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
});
|
|
109
|
+
test('should not throw if there are commits in specified path', async () => {
|
|
110
|
+
const options = { git: { requireCommits: true, commitsPath: 'dir' } };
|
|
111
|
+
const gitClient = factory(Git, { options });
|
|
112
|
+
sh.exec('git tag 1.0.0', execOpts);
|
|
113
|
+
gitAdd('line', 'dir/file', 'Add file');
|
|
114
|
+
await assert.doesNotReject(gitClient.init());
|
|
115
|
+
});
|
|
113
116
|
|
|
114
|
-
test
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
});
|
|
117
|
+
test('should not throw if there are no tags', async () => {
|
|
118
|
+
const options = { git: { requireCommits: true } };
|
|
119
|
+
const gitClient = factory(Git, { options });
|
|
120
|
+
gitAdd('line', 'file', 'Add file');
|
|
121
|
+
await assert.doesNotReject(gitClient.init());
|
|
122
|
+
});
|
|
120
123
|
|
|
121
|
-
test
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
});
|
|
124
|
+
test('should not throw if origin remote is renamed', async () => {
|
|
125
|
+
childProcess.execSync('git remote rename origin upstream', execOpts);
|
|
126
|
+
const gitClient = factory(Git);
|
|
127
|
+
await assert.doesNotReject(gitClient.init());
|
|
128
|
+
});
|
|
126
129
|
|
|
127
|
-
test
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
});
|
|
130
|
+
test('should detect and include version prefix ("v")', async () => {
|
|
131
|
+
const gitClient = factory(Git, { options: { git } });
|
|
132
|
+
childProcess.execSync('git tag v1.0.0', execOpts);
|
|
133
|
+
await gitClient.init();
|
|
134
|
+
await gitClient.bump('1.0.1');
|
|
135
|
+
assert.equal(gitClient.config.getContext('tagName'), 'v1.0.1');
|
|
136
|
+
});
|
|
134
137
|
|
|
135
|
-
test
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
});
|
|
138
|
+
test('should detect and exclude version prefix', async () => {
|
|
139
|
+
const gitClient = factory(Git, { options: { git } });
|
|
140
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
141
|
+
await gitClient.init();
|
|
142
|
+
await gitClient.bump('1.0.1');
|
|
143
|
+
assert.equal(gitClient.config.getContext('tagName'), '1.0.1');
|
|
144
|
+
});
|
|
142
145
|
|
|
143
|
-
test
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
});
|
|
146
|
+
test('should detect and exclude version prefix (configured)', async () => {
|
|
147
|
+
const gitClient = factory(Git, { options: { git: { tagName: 'v${version}' } } });
|
|
148
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
149
|
+
await gitClient.init();
|
|
150
|
+
await gitClient.bump('1.0.1');
|
|
151
|
+
assert.equal(gitClient.config.getContext('tagName'), 'v1.0.1');
|
|
152
|
+
});
|
|
150
153
|
|
|
151
|
-
test
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
});
|
|
154
|
+
test('should honor custom tagName configuration', async () => {
|
|
155
|
+
const gitClient = factory(Git, { options: { git: { tagName: 'TAGNAME-${repo.project}-v${version}' } } });
|
|
156
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
157
|
+
await gitClient.init();
|
|
158
|
+
await gitClient.bump('1.0.1');
|
|
159
|
+
const { project } = gitClient.getContext('repo');
|
|
160
|
+
assert.equal(gitClient.config.getContext('tagName'), `TAGNAME-${project}-v1.0.1`);
|
|
161
|
+
});
|
|
159
162
|
|
|
160
|
-
test
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
});
|
|
163
|
+
test('should get the latest tag after fetch', async () => {
|
|
164
|
+
const shell = factory(Shell);
|
|
165
|
+
const gitClient = factory(Git, { container: { shell } });
|
|
166
|
+
const other = mkTmpDir();
|
|
167
|
+
childProcess.execSync('git push', execOpts);
|
|
168
|
+
childProcess.execSync(`git clone ${bare} ${other}`, execOpts);
|
|
169
|
+
|
|
170
|
+
process.chdir(other);
|
|
171
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
172
|
+
childProcess.execSync('git push --tags', execOpts);
|
|
173
|
+
process.chdir(target);
|
|
174
|
+
await gitClient.init();
|
|
175
|
+
assert.equal(gitClient.config.getContext('latestTag'), '1.0.0');
|
|
176
|
+
});
|
|
175
177
|
|
|
176
|
-
test
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
});
|
|
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, {
|
|
181
|
+
options: { git: { tagName: 'TAGNAME-v${version}' } },
|
|
182
|
+
container: { shell }
|
|
183
|
+
});
|
|
184
|
+
const other = mkTmpDir();
|
|
185
|
+
childProcess.execSync('git push', execOpts);
|
|
186
|
+
childProcess.execSync(`git clone ${bare} ${other}`, execOpts);
|
|
187
|
+
process.chdir(other);
|
|
188
|
+
childProcess.execSync('git tag TAGNAME-OTHER-v2.0.0', execOpts);
|
|
189
|
+
childProcess.execSync('git tag TAGNAME-v1.0.0', execOpts);
|
|
190
|
+
childProcess.execSync('git tag TAGNAME-OTHER-v2.0.2', execOpts);
|
|
191
|
+
childProcess.execSync('git push --tags', execOpts);
|
|
192
|
+
process.chdir(target);
|
|
193
|
+
await gitClient.init();
|
|
194
|
+
assert.equal(gitClient.config.getContext('latestTag'), 'TAGNAME-v1.0.0');
|
|
195
|
+
});
|
|
195
196
|
|
|
196
|
-
test
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
});
|
|
197
|
+
test('should get the latest tag based on tagMatch', async () => {
|
|
198
|
+
const shell = factory(Shell);
|
|
199
|
+
const gitClient = factory(Git, {
|
|
200
|
+
options: { git: { tagMatch: '[0-9][0-9]\\.[0-1][0-9]\\.[0-9]*' } },
|
|
201
|
+
container: { shell }
|
|
202
|
+
});
|
|
203
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
204
|
+
childProcess.execSync('git tag 21.04.3', execOpts);
|
|
205
|
+
childProcess.execSync('git tag 1.0.1', execOpts);
|
|
206
|
+
childProcess.execSync('git push --tags', execOpts);
|
|
207
|
+
await gitClient.init();
|
|
208
|
+
assert.equal(gitClient.config.getContext('latestTag'), '21.04.3');
|
|
209
|
+
});
|
|
209
210
|
|
|
210
|
-
test
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
});
|
|
211
|
+
test('should get the latest tag based on tagExclude', async () => {
|
|
212
|
+
const shell = factory(Shell);
|
|
213
|
+
const gitClient = factory(Git, {
|
|
214
|
+
options: { git: { tagExclude: '*[-]*' } },
|
|
215
|
+
container: { shell }
|
|
216
|
+
});
|
|
217
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
218
|
+
childProcess.execSync('git commit --allow-empty -m "commit 1"', execOpts);
|
|
219
|
+
childProcess.execSync('git tag 1.0.1-rc.0', execOpts);
|
|
220
|
+
childProcess.execSync('git tag 1.0.1', execOpts);
|
|
221
|
+
childProcess.execSync('git commit --allow-empty -m "commit 2"', execOpts);
|
|
222
|
+
childProcess.execSync('git tag 1.1.0-rc.0', execOpts);
|
|
223
|
+
childProcess.execSync('git push --tags', execOpts);
|
|
224
|
+
await gitClient.init();
|
|
225
|
+
assert.equal(gitClient.config.getContext('latestTag'), '1.0.1');
|
|
226
|
+
});
|
|
226
227
|
|
|
227
|
-
test
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
});
|
|
228
|
+
test('should generate correct changelog', async () => {
|
|
229
|
+
const gitClient = factory(Git, { options: { git } });
|
|
230
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
231
|
+
gitAdd('line', 'file', 'Add file');
|
|
232
|
+
gitAdd('line', 'file', 'Add file');
|
|
233
|
+
await gitClient.init();
|
|
234
|
+
const changelog = await gitClient.getChangelog();
|
|
235
|
+
assert.match(changelog, /\* Add file \(\w{7}\)\n\* Add file \(\w{7}\)/);
|
|
236
|
+
});
|
|
236
237
|
|
|
237
|
-
test
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
238
|
+
test('should get the full changelog since latest major tag', async () => {
|
|
239
|
+
const shell = factory(Shell);
|
|
240
|
+
const gitClient = factory(Git, {
|
|
241
|
+
options: { git: { tagMatch: '[0-9]\\.[0-9]\\.[0-9]', changelog: git.changelog } },
|
|
242
|
+
container: { shell }
|
|
243
|
+
});
|
|
244
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
245
|
+
gitAdd('line', 'file', 'Add file');
|
|
246
|
+
childProcess.execSync('git tag 2.0.0-rc.0', execOpts);
|
|
247
|
+
gitAdd('line', 'file', 'Add file');
|
|
248
|
+
childProcess.execSync('git tag 2.0.0-rc.1', execOpts);
|
|
249
|
+
gitAdd('line', 'file', 'Add file');
|
|
250
|
+
await gitClient.init();
|
|
251
|
+
assert.equal(gitClient.config.getContext('latestTag'), '1.0.0');
|
|
252
|
+
const changelog = await gitClient.getChangelog();
|
|
253
|
+
assert.match(changelog, /\* Add file \(\w{7}\)\n\* Add file \(\w{7}\)\n\* Add file \(\w{7}\)/);
|
|
254
|
+
});
|
|
253
255
|
});
|