release-it 19.0.0-next.1 → 19.0.0-next.3
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 +1 -1
- package/lib/cli.js +2 -5
- package/lib/config.js +34 -2
- package/lib/index.js +26 -9
- package/lib/log.js +7 -7
- package/lib/plugin/github/GitHub.js +2 -6
- package/lib/plugin/github/util.js +1 -1
- package/lib/plugin/gitlab/GitLab.js +11 -4
- package/lib/plugin/npm/npm.js +4 -0
- package/lib/plugin/version/Version.js +6 -4
- package/package.json +14 -23
- package/schema/gitlab.json +4 -0
- package/schema/release-it.json +4 -0
- package/test/cli.js +6 -5
- package/test/config.js +228 -122
- package/test/git.init.js +220 -218
- package/test/git.js +359 -364
- package/test/github.js +563 -480
- package/test/gitlab.js +374 -336
- 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 +75 -51
- package/test/tasks.interactive.js +215 -164
- package/test/tasks.js +392 -412
- package/test/util/helpers.js +4 -3
- package/test/util/index.js +34 -7
- package/test/util/mock.js +11 -0
- package/test/utils.js +33 -32
- package/test/version.js +192 -176
- package/test/util/setup.js +0 -3
package/test/tasks.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import childProcess from 'node:child_process';
|
|
3
3
|
import { appendFileSync, mkdirSync, renameSync } from 'node:fs';
|
|
4
|
-
import test from '
|
|
4
|
+
import test, { after, afterEach, before, beforeEach, describe } from 'node:test';
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
5
6
|
import semver from 'semver';
|
|
6
|
-
import sinon from 'sinon';
|
|
7
|
-
import Log from '../lib/log.js';
|
|
8
|
-
import Spinner from '../lib/spinner.js';
|
|
9
7
|
import Config from '../lib/config.js';
|
|
10
8
|
import runTasks from '../lib/index.js';
|
|
11
9
|
import Git from '../lib/plugin/git/Git.js';
|
|
@@ -24,487 +22,471 @@ import {
|
|
|
24
22
|
interceptCreate as interceptGitHubCreate,
|
|
25
23
|
interceptAsset as interceptGitHubAsset
|
|
26
24
|
} from './stub/github.js';
|
|
27
|
-
import { factory } from './util/index.js';
|
|
25
|
+
import { factory, LogStub, SpinnerStub } from './util/index.js';
|
|
26
|
+
import { mockFetch } from './util/mock.js';
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
describe('tasks', () => {
|
|
29
|
+
const rootDir = new URL('..', import.meta.url);
|
|
30
30
|
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
const [mocker, github, assets, gitlab] = mockFetch([
|
|
32
|
+
'https://api.github.com',
|
|
33
|
+
'https://uploads.github.com',
|
|
34
|
+
'https://gitlab.com/api/v4'
|
|
35
|
+
]);
|
|
34
36
|
|
|
35
|
-
const npmMajorVersion = semver.major(process.env.npm_config_user_agent.match(/npm\/([^ ]+)/)[1]);
|
|
37
|
+
const npmMajorVersion = semver.major(process.env.npm_config_user_agent.match(/npm\/([^ ]+)/)[1]);
|
|
36
38
|
|
|
37
|
-
const testConfig = {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
};
|
|
39
|
+
const testConfig = {
|
|
40
|
+
ci: true,
|
|
41
|
+
config: false
|
|
42
|
+
};
|
|
41
43
|
|
|
42
|
-
const log =
|
|
43
|
-
const spinner =
|
|
44
|
-
spinner.show.callsFake(({ enabled = true, task }) => (enabled ? task() : noop));
|
|
44
|
+
const log = new LogStub();
|
|
45
|
+
const spinner = new SpinnerStub();
|
|
45
46
|
|
|
46
|
-
const getContainer = options => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
log,
|
|
51
|
-
spinner,
|
|
52
|
-
config,
|
|
53
|
-
shell
|
|
47
|
+
const getContainer = options => {
|
|
48
|
+
const config = new Config(Object.assign({}, testConfig, options));
|
|
49
|
+
const shell = new ShellStub({ container: { log, config } });
|
|
50
|
+
return { log, spinner, config, shell };
|
|
54
51
|
};
|
|
55
|
-
};
|
|
56
52
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
});
|
|
53
|
+
before(() => {
|
|
54
|
+
mocker.mockGlobal();
|
|
55
|
+
});
|
|
60
56
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
57
|
+
let bare;
|
|
58
|
+
let target;
|
|
59
|
+
beforeEach(async () => {
|
|
60
|
+
bare = mkTmpDir();
|
|
61
|
+
target = mkTmpDir();
|
|
62
|
+
process.chdir(bare);
|
|
63
|
+
childProcess.execSync(`git init --bare .`, execOpts);
|
|
64
|
+
childProcess.execSync(`git clone ${bare} ${target}`, execOpts);
|
|
65
|
+
process.chdir(target);
|
|
66
|
+
gitAdd('line', 'file', 'Add file');
|
|
67
|
+
});
|
|
71
68
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
afterEach(() => {
|
|
70
|
+
mocker.clearAll();
|
|
71
|
+
log.resetCalls();
|
|
72
|
+
});
|
|
75
73
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
t.true(log.obtrusive.firstCall.args[0].includes(`release ${name} (${latestVersion}...${version})`));
|
|
80
|
-
t.regex(log.log.lastCall.args[0], /Done \(in [0-9]+s\.\)/);
|
|
81
|
-
});
|
|
74
|
+
after(() => {
|
|
75
|
+
mocker.unmockGlobal();
|
|
76
|
+
});
|
|
82
77
|
|
|
83
|
-
test
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
{
|
|
78
|
+
test('should run tasks without throwing errors', async () => {
|
|
79
|
+
renameSync('.git', 'foo');
|
|
80
|
+
const { name, latestVersion, version } = await runTasks({}, getContainer());
|
|
81
|
+
assert(log.obtrusive.mock.calls[0].arguments[0].includes(`release ${name} (${latestVersion}...${version})`));
|
|
82
|
+
assert.match(log.log.mock.calls.at(-1).arguments[0], /Done \(in [0-9]+s\.\)/);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('should run tasks without package.json', async () => {
|
|
86
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
87
|
+
gitAdd('line', 'file', 'Add file');
|
|
88
|
+
const { name } = await runTasks({}, getContainer({ increment: 'major', git: { commit: false } }));
|
|
89
|
+
assert(log.obtrusive.mock.calls[0].arguments[0].includes(`release ${name} (1.0.0...2.0.0)`));
|
|
90
|
+
assert.match(log.log.mock.calls.at(-1).arguments[0], /Done \(in [0-9]+s\.\)/);
|
|
91
|
+
assert.equal(log.warn.mock.callCount(), 0);
|
|
91
92
|
const stdout = childProcess.execSync('git describe --tags --match=* --abbrev=0', {
|
|
92
93
|
encoding: 'utf-8'
|
|
93
94
|
});
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
test.serial('should disable plugins', async t => {
|
|
99
|
-
gitAdd('{"name":"my-package","version":"1.2.3"}', 'package.json', 'Add package.json');
|
|
100
|
-
childProcess.execSync('git tag 1.2.3', execOpts);
|
|
101
|
-
gitAdd('line', 'file', 'Add file');
|
|
102
|
-
const container = getContainer({ increment: 'minor', git: false, npm: false });
|
|
103
|
-
const { latestVersion, version } = await runTasks({}, container);
|
|
104
|
-
t.is(latestVersion, '0.0.0');
|
|
105
|
-
t.is(version, '0.1.0');
|
|
106
|
-
t.regex(log.log.lastCall.args[0], /Done \(in [0-9]+s\.\)/);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
test.serial('should run tasks with minimal config and without any warnings/errors', async t => {
|
|
110
|
-
gitAdd('{"name":"my-package","version":"1.2.3"}', 'package.json', 'Add package.json');
|
|
111
|
-
childProcess.execSync('git tag 1.2.3', execOpts);
|
|
112
|
-
gitAdd('line', 'file', 'More file');
|
|
113
|
-
await runTasks({}, getContainer({ increment: 'patch' }));
|
|
114
|
-
t.true(log.obtrusive.firstCall.args[0].includes('release my-package (1.2.3...1.2.4)'));
|
|
115
|
-
t.regex(log.log.lastCall.args[0], /Done \(in [0-9]+s\.\)/);
|
|
116
|
-
const stdout = childProcess.execSync('git describe --tags --match=* --abbrev=0', { encoding: 'utf-8' });
|
|
117
|
-
t.is(stdout.trim(), '1.2.4');
|
|
118
|
-
});
|
|
95
|
+
assert.equal(stdout.trim(), '2.0.0');
|
|
96
|
+
});
|
|
119
97
|
|
|
120
|
-
test
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
98
|
+
test('should disable plugins', async () => {
|
|
99
|
+
gitAdd('{"name":"my-package","version":"1.2.3"}', 'package.json', 'Add package.json');
|
|
100
|
+
childProcess.execSync('git tag 1.2.3', execOpts);
|
|
101
|
+
gitAdd('line', 'file', 'Add file');
|
|
102
|
+
const container = getContainer({ increment: 'minor', git: false, npm: false });
|
|
103
|
+
const { latestVersion, version } = await runTasks({}, container);
|
|
104
|
+
assert.equal(latestVersion, '0.0.0');
|
|
105
|
+
assert.equal(version, '0.1.0');
|
|
106
|
+
assert.match(log.log.mock.calls.at(-1).arguments[0], /Done \(in [0-9]+s\.\)/);
|
|
107
|
+
});
|
|
128
108
|
|
|
129
|
-
test
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
t.regex(log.log.lastCall.args[0], /Done \(in [0-9]+s\.\)/);
|
|
140
|
-
const stdout = childProcess.execSync('git describe --tags --match=* --abbrev=0', { encoding: 'utf-8' });
|
|
141
|
-
t.is(stdout.trim(), '1.0.0');
|
|
142
|
-
const npmArgs = getArgs(exec.args, 'npm');
|
|
143
|
-
t.is(npmArgs[5], 'npm version 1.3.0 --no-git-tag-version');
|
|
144
|
-
exec.restore();
|
|
145
|
-
});
|
|
109
|
+
test('should run tasks with minimal config and without any warnings/errors', async () => {
|
|
110
|
+
gitAdd('{"name":"my-package","version":"1.2.3"}', 'package.json', 'Add package.json');
|
|
111
|
+
childProcess.execSync('git tag 1.2.3', execOpts);
|
|
112
|
+
gitAdd('line', 'file', 'More file');
|
|
113
|
+
await runTasks({}, getContainer({ increment: 'patch' }));
|
|
114
|
+
assert(log.obtrusive.mock.calls[0].arguments[0].includes('release my-package (1.2.3...1.2.4)'));
|
|
115
|
+
assert.match(log.log.mock.calls.at(-1).arguments[0], /Done \(in [0-9]+s\.\)/);
|
|
116
|
+
const stdout = childProcess.execSync('git describe --tags --match=* --abbrev=0', { encoding: 'utf-8' });
|
|
117
|
+
assert.equal(stdout.trim(), '1.2.4');
|
|
118
|
+
});
|
|
146
119
|
|
|
147
|
-
test
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
t.is(stdout.trim(), '1.2.0');
|
|
156
|
-
});
|
|
120
|
+
test('should use pkg.version', async () => {
|
|
121
|
+
gitAdd('{"name":"my-package","version":"1.2.3"}', 'package.json', 'Add package.json');
|
|
122
|
+
await runTasks({}, getContainer({ increment: 'minor' }));
|
|
123
|
+
assert(log.obtrusive.mock.calls[0].arguments[0].includes('release my-package (1.2.3...1.3.0)'));
|
|
124
|
+
assert.match(log.log.mock.calls.at(-1).arguments[0], /Done \(in [0-9]+s\.\)/);
|
|
125
|
+
const stdout = childProcess.execSync('git describe --tags --match=* --abbrev=0', { encoding: 'utf-8' });
|
|
126
|
+
assert.equal(stdout.trim(), '1.3.0');
|
|
127
|
+
});
|
|
157
128
|
|
|
158
|
-
test
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
129
|
+
test('should use pkg.version (in sub dir) w/o tagging repo', async t => {
|
|
130
|
+
gitAdd('{"name":"root-package","version":"1.0.0"}', 'package.json', 'Add package.json');
|
|
131
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
132
|
+
mkdirSync('my-package');
|
|
133
|
+
process.chdir('my-package');
|
|
134
|
+
gitAdd('{"name":"my-package","version":"1.2.3"}', 'package.json', 'Add package.json');
|
|
135
|
+
const container = getContainer({ increment: 'minor', git: { tag: false } });
|
|
136
|
+
const exec = t.mock.method(container.shell, 'exec');
|
|
137
|
+
await runTasks({}, container);
|
|
138
|
+
assert(log.obtrusive.mock.calls[0].arguments[0].endsWith('release my-package (1.2.3...1.3.0)'));
|
|
139
|
+
assert.match(log.log.mock.calls.at(-1).arguments[0], /Done \(in [0-9]+s\.\)/);
|
|
140
|
+
const stdout = childProcess.execSync('git describe --tags --match=* --abbrev=0', { encoding: 'utf-8' });
|
|
141
|
+
assert.equal(stdout.trim(), '1.0.0');
|
|
142
|
+
const npmArgs = getArgs(exec, 'npm');
|
|
143
|
+
assert.equal(npmArgs[5], 'npm version 1.3.0 --no-git-tag-version');
|
|
173
144
|
});
|
|
174
145
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
146
|
+
test('should ignore version in pkg.version and use git tag instead', async () => {
|
|
147
|
+
gitAdd('{"name":"my-package","version":"0.0.0"}', 'package.json', 'Add package.json');
|
|
148
|
+
childProcess.execSync('git tag 1.1.1', execOpts);
|
|
149
|
+
gitAdd('line', 'file', 'More file');
|
|
150
|
+
await runTasks({}, getContainer({ increment: 'minor', npm: { ignoreVersion: true } }));
|
|
151
|
+
assert(log.obtrusive.mock.calls[0].arguments[0].includes('release my-package (1.1.1...1.2.0)'));
|
|
152
|
+
assert.match(log.log.mock.calls.at(-1).arguments[0], /Done \(in [0-9]+s\.\)/);
|
|
153
|
+
const stdout = childProcess.execSync('git describe --tags --match=* --abbrev=0', { encoding: 'utf-8' });
|
|
154
|
+
assert.equal(stdout.trim(), '1.2.0');
|
|
178
155
|
});
|
|
179
|
-
const exec = sinon.spy(container.shell, 'exec');
|
|
180
156
|
|
|
181
|
-
|
|
157
|
+
test('should release all the things (basic)', async t => {
|
|
158
|
+
const project = path.basename(bare);
|
|
159
|
+
const pkgName = path.basename(target);
|
|
160
|
+
const owner = path.basename(path.dirname(bare));
|
|
161
|
+
gitAdd(`{"name":"${pkgName}","version":"1.0.0"}`, 'package.json', 'Add package.json');
|
|
162
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
163
|
+
const sha = gitAdd('line', 'file', 'More file');
|
|
164
|
+
|
|
165
|
+
interceptGitHubAuthentication(github);
|
|
166
|
+
interceptGitHubCollaborator(github, { owner, project });
|
|
167
|
+
interceptGitHubCreate(github, {
|
|
168
|
+
owner,
|
|
169
|
+
project,
|
|
170
|
+
body: { tag_name: '1.0.1', name: 'Release 1.0.1', body: `* More file (${sha})`, prerelease: false }
|
|
171
|
+
});
|
|
182
172
|
|
|
183
|
-
|
|
173
|
+
const container = getContainer({
|
|
174
|
+
github: { release: true, pushRepo: `https://github.com/${owner}/${project}` },
|
|
175
|
+
npm: { name: pkgName }
|
|
176
|
+
});
|
|
184
177
|
|
|
185
|
-
|
|
186
|
-
'npm ping',
|
|
187
|
-
'npm whoami',
|
|
188
|
-
`npm show ${pkgName}@latest version`,
|
|
189
|
-
'npm --version',
|
|
190
|
-
`npm access ${npmMajorVersion >= 9 ? 'list collaborators --json' : 'ls-collaborators'} ${pkgName}`,
|
|
191
|
-
'npm version 1.0.1 --no-git-tag-version',
|
|
192
|
-
'npm publish . --tag latest'
|
|
193
|
-
]);
|
|
178
|
+
const exec = t.mock.method(container.shell, 'exec');
|
|
194
179
|
|
|
195
|
-
|
|
196
|
-
t.true(log.log.firstCall.args[0].endsWith(`https://www.npmjs.com/package/${pkgName}`));
|
|
197
|
-
t.true(log.log.secondCall.args[0].endsWith(`https://github.com/${owner}/${project}/releases/tag/1.0.1`));
|
|
180
|
+
await runTasks({}, container);
|
|
198
181
|
|
|
199
|
-
|
|
200
|
-
});
|
|
182
|
+
const npmArgs = getArgs(exec, 'npm');
|
|
201
183
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const sha = gitAdd('line', 'file', 'More file');
|
|
212
|
-
|
|
213
|
-
interceptGitHubCreate({
|
|
214
|
-
owner,
|
|
215
|
-
project,
|
|
216
|
-
body: {
|
|
217
|
-
tag_name: `${pkgName}-${branchName}-1.0.1`,
|
|
218
|
-
name: 'Release 1.0.1',
|
|
219
|
-
body: `* More file (${sha})`,
|
|
220
|
-
prerelease: false
|
|
221
|
-
}
|
|
222
|
-
});
|
|
184
|
+
assert.deepEqual(npmArgs, [
|
|
185
|
+
'npm ping',
|
|
186
|
+
'npm whoami',
|
|
187
|
+
`npm show ${pkgName}@latest version`,
|
|
188
|
+
'npm --version',
|
|
189
|
+
`npm access ${npmMajorVersion >= 9 ? 'list collaborators --json' : 'ls-collaborators'} ${pkgName}`,
|
|
190
|
+
'npm version 1.0.1 --no-git-tag-version',
|
|
191
|
+
'npm publish . --tag latest'
|
|
192
|
+
]);
|
|
223
193
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
194
|
+
assert(log.obtrusive.mock.calls[0].arguments[0].endsWith(`release ${pkgName} (1.0.0...1.0.1)`));
|
|
195
|
+
assert(log.log.mock.calls[0].arguments[0].endsWith(`https://www.npmjs.com/package/${pkgName}`));
|
|
196
|
+
assert(log.log.mock.calls[1].arguments[0].endsWith(`https://github.com/${owner}/${project}/releases/tag/1.0.1`));
|
|
227
197
|
});
|
|
228
198
|
|
|
229
|
-
|
|
199
|
+
test('should release with correct tag name', async t => {
|
|
200
|
+
const project = path.basename(bare);
|
|
201
|
+
const pkgName = path.basename(target);
|
|
202
|
+
const owner = path.basename(path.dirname(bare));
|
|
203
|
+
const stdout = childProcess.execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf-8' });
|
|
204
|
+
const branchName = stdout.trim();
|
|
205
|
+
gitAdd(`{"name":"${pkgName}","version":"1.0.0"}`, 'package.json', 'Add package.json');
|
|
206
|
+
childProcess.execSync(`git tag ${pkgName}-${branchName}-1.0.0`, execOpts);
|
|
207
|
+
const sha = gitAdd('line', 'file', 'More file');
|
|
208
|
+
|
|
209
|
+
interceptGitHubCreate(github, {
|
|
210
|
+
owner,
|
|
211
|
+
project,
|
|
212
|
+
body: {
|
|
213
|
+
tag_name: `${pkgName}-${branchName}-1.0.1`,
|
|
214
|
+
name: 'Release 1.0.1',
|
|
215
|
+
body: `* More file (${sha})`,
|
|
216
|
+
prerelease: false
|
|
217
|
+
}
|
|
218
|
+
});
|
|
230
219
|
|
|
231
|
-
|
|
220
|
+
const container = getContainer({
|
|
221
|
+
git: { tagName: '${npm.name}-${branchName}-${version}' },
|
|
222
|
+
github: { release: true, skipChecks: true, pushRepo: `https://github.com/${owner}/${project}` }
|
|
223
|
+
});
|
|
232
224
|
|
|
233
|
-
|
|
225
|
+
const exec = t.mock.method(container.shell, 'exec');
|
|
234
226
|
|
|
235
|
-
|
|
236
|
-
t.true(
|
|
237
|
-
log.log.secondCall.args[0].endsWith(
|
|
238
|
-
`https://github.com/${owner}/${project}/releases/tag/${pkgName}-${branchName}-1.0.1`
|
|
239
|
-
)
|
|
240
|
-
);
|
|
227
|
+
await runTasks({}, container);
|
|
241
228
|
|
|
242
|
-
|
|
243
|
-
});
|
|
229
|
+
const gitArgs = getArgs(exec, 'git');
|
|
244
230
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
const owner = path.basename(path.dirname(bare));
|
|
250
|
-
const url = `https://gitlab.com/${owner}/${project}`;
|
|
251
|
-
gitAdd(`{"name":"${pkgName}","version":"1.0.0"}`, 'package.json', 'Add package.json');
|
|
252
|
-
childProcess.execSync('git tag v1.0.0', execOpts);
|
|
253
|
-
const sha = gitAdd('line', 'file', 'More file');
|
|
254
|
-
childProcess.execSync('git push --follow-tags', execOpts);
|
|
255
|
-
const git = factory(Git);
|
|
256
|
-
const ref = (await git.getBranchName()) ?? 'HEAD';
|
|
257
|
-
|
|
258
|
-
interceptGitHubAuthentication();
|
|
259
|
-
interceptGitHubCollaborator({ owner, project });
|
|
260
|
-
interceptGitHubCreate({
|
|
261
|
-
owner,
|
|
262
|
-
project,
|
|
263
|
-
body: {
|
|
264
|
-
tag_name: 'v1.1.0-alpha.0',
|
|
265
|
-
name: 'Release 1.1.0-alpha.0',
|
|
266
|
-
body: `Notes for ${pkgName} [v1.1.0-alpha.0]: ${sha}`,
|
|
267
|
-
prerelease: true
|
|
268
|
-
}
|
|
231
|
+
assert(gitArgs.includes(`git tag --annotate --message Release 1.0.1 ${pkgName}-${branchName}-1.0.1`));
|
|
232
|
+
assert(
|
|
233
|
+
log.log.mock.calls[1].arguments[0].endsWith(`/${owner}/${project}/releases/tag/${pkgName}-${branchName}-1.0.1`)
|
|
234
|
+
);
|
|
269
235
|
});
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
236
|
+
|
|
237
|
+
test('should release all the things (pre-release, github, gitlab)', async t => {
|
|
238
|
+
const project = path.basename(bare);
|
|
239
|
+
const pkgName = path.basename(target);
|
|
240
|
+
const owner = path.basename(path.dirname(bare));
|
|
241
|
+
const url = `https://gitlab.com/${owner}/${project}`;
|
|
242
|
+
gitAdd(`{"name":"${pkgName}","version":"1.0.0"}`, 'package.json', 'Add package.json');
|
|
243
|
+
childProcess.execSync('git tag v1.0.0', execOpts);
|
|
244
|
+
const sha = gitAdd('line', 'file', 'More file');
|
|
245
|
+
childProcess.execSync('git push --follow-tags', execOpts);
|
|
246
|
+
const git = factory(Git);
|
|
247
|
+
const ref = (await git.getBranchName()) ?? 'HEAD';
|
|
248
|
+
|
|
249
|
+
interceptGitHubAuthentication(github);
|
|
250
|
+
interceptGitHubCollaborator(github, { owner, project });
|
|
251
|
+
interceptGitHubAsset(assets, { owner, project, body: 'lineline' });
|
|
252
|
+
interceptGitHubCreate(github, {
|
|
253
|
+
owner,
|
|
254
|
+
project,
|
|
255
|
+
body: {
|
|
256
|
+
tag_name: 'v1.1.0-alpha.0',
|
|
257
|
+
name: 'Release 1.1.0-alpha.0',
|
|
258
|
+
body: `Notes for ${pkgName} [v1.1.0-alpha.0]: ${sha}`,
|
|
259
|
+
prerelease: true
|
|
291
260
|
}
|
|
292
|
-
}
|
|
293
|
-
});
|
|
261
|
+
});
|
|
294
262
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
263
|
+
interceptGitLabUser(gitlab, { owner });
|
|
264
|
+
interceptGitLabCollaborator(gitlab, { owner, project });
|
|
265
|
+
interceptGitLabAsset(gitlab, { owner, project });
|
|
266
|
+
interceptGitLabPublish(gitlab, {
|
|
267
|
+
owner,
|
|
268
|
+
project,
|
|
269
|
+
body: {
|
|
270
|
+
name: 'Release 1.1.0-alpha.0',
|
|
271
|
+
ref,
|
|
272
|
+
tag_name: 'v1.1.0-alpha.0',
|
|
273
|
+
tag_message: `${owner} ${owner}/${project} ${project}`,
|
|
274
|
+
description: `Notes for ${pkgName}: ${sha}`,
|
|
275
|
+
assets: {
|
|
276
|
+
links: [
|
|
277
|
+
{
|
|
278
|
+
name: 'file',
|
|
279
|
+
url: `${url}/uploads/7e8bec1fe27cc46a4bc6a91b9e82a07c/file`
|
|
280
|
+
}
|
|
281
|
+
]
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
});
|
|
317
285
|
|
|
318
|
-
|
|
286
|
+
const container = getContainer({
|
|
287
|
+
increment: 'minor',
|
|
288
|
+
preRelease: 'alpha',
|
|
289
|
+
git: {
|
|
290
|
+
changelog: 'git log --pretty=format:%h ${latestTag}...HEAD',
|
|
291
|
+
commitMessage: 'Release ${version} for ${name} (from ${latestVersion})',
|
|
292
|
+
tagAnnotation: '${repo.owner} ${repo.repository} ${repo.project}'
|
|
293
|
+
},
|
|
294
|
+
github: {
|
|
295
|
+
release: true,
|
|
296
|
+
pushRepo: `https://github.com/${owner}/${project}`,
|
|
297
|
+
releaseNotes: 'echo Notes for ${name} [v${version}]: ${changelog}',
|
|
298
|
+
assets: ['file']
|
|
299
|
+
},
|
|
300
|
+
gitlab: {
|
|
301
|
+
release: true,
|
|
302
|
+
pushRepo: url,
|
|
303
|
+
releaseNotes: 'echo Notes for ${name}: ${changelog}',
|
|
304
|
+
assets: ['file']
|
|
305
|
+
},
|
|
306
|
+
npm: { name: pkgName }
|
|
307
|
+
});
|
|
319
308
|
|
|
320
|
-
|
|
309
|
+
const exec = t.mock.method(container.shell, 'exec');
|
|
321
310
|
|
|
322
|
-
|
|
323
|
-
t.deepEqual(npmArgs, [
|
|
324
|
-
'npm ping',
|
|
325
|
-
'npm whoami',
|
|
326
|
-
`npm show ${pkgName}@latest version`,
|
|
327
|
-
'npm --version',
|
|
328
|
-
`npm access ${npmMajorVersion >= 9 ? 'list collaborators --json' : 'ls-collaborators'} ${pkgName}`,
|
|
329
|
-
'npm version 1.1.0-alpha.0 --no-git-tag-version',
|
|
330
|
-
'npm publish . --tag alpha'
|
|
331
|
-
]);
|
|
311
|
+
process.env['GITLAB_TOKEN'] = '123';
|
|
332
312
|
|
|
333
|
-
|
|
334
|
-
encoding: 'utf-8'
|
|
335
|
-
});
|
|
336
|
-
t.is(commitMessage.trim(), `Release 1.1.0-alpha.0 for ${pkgName} (from 1.0.0)`);
|
|
313
|
+
await runTasks({}, container);
|
|
337
314
|
|
|
338
|
-
|
|
339
|
-
t.is(tagName.trim(), 'v1.1.0-alpha.0');
|
|
315
|
+
const npmArgs = getArgs(exec, 'npm');
|
|
340
316
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
317
|
+
assert.deepEqual(npmArgs, [
|
|
318
|
+
'npm ping',
|
|
319
|
+
'npm whoami',
|
|
320
|
+
`npm show ${pkgName}@latest version`,
|
|
321
|
+
'npm --version',
|
|
322
|
+
`npm access ${npmMajorVersion >= 9 ? 'list collaborators --json' : 'ls-collaborators'} ${pkgName}`,
|
|
323
|
+
'npm version 1.1.0-alpha.0 --no-git-tag-version',
|
|
324
|
+
'npm publish . --tag alpha'
|
|
325
|
+
]);
|
|
345
326
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
t.regex(log.log.lastCall.args[0], /Done \(in [0-9]+s\.\)/);
|
|
327
|
+
const commitMessage = childProcess.execSync('git log --oneline --format=%B -n 1 HEAD', {
|
|
328
|
+
encoding: 'utf-8'
|
|
329
|
+
});
|
|
330
|
+
assert.equal(commitMessage.trim(), `Release 1.1.0-alpha.0 for ${pkgName} (from 1.0.0)`);
|
|
351
331
|
|
|
352
|
-
|
|
353
|
-
|
|
332
|
+
const tagName = childProcess.execSync('git describe --tags --match=* --abbrev=0', { encoding: 'utf-8' });
|
|
333
|
+
assert.equal(tagName.trim(), 'v1.1.0-alpha.0');
|
|
354
334
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
childProcess.execSync('git tag v1.0.0', execOpts);
|
|
360
|
-
|
|
361
|
-
const container = getContainer({ increment: 'major', preRelease: true, npm: { name: pkgName, tag: 'next' } });
|
|
362
|
-
const exec = sinon.spy(container.shell, 'exec');
|
|
363
|
-
|
|
364
|
-
await runTasks({}, container);
|
|
365
|
-
|
|
366
|
-
const npmArgs = getArgs(container.shell.exec.args, 'npm');
|
|
367
|
-
t.deepEqual(npmArgs, [
|
|
368
|
-
'npm ping',
|
|
369
|
-
'npm whoami',
|
|
370
|
-
`npm show ${pkgName}@latest version`,
|
|
371
|
-
'npm --version',
|
|
372
|
-
`npm access ${npmMajorVersion >= 9 ? 'list collaborators --json' : 'ls-collaborators'} ${pkgName}`,
|
|
373
|
-
'npm version 2.0.0-0 --no-git-tag-version',
|
|
374
|
-
'npm publish . --tag next'
|
|
375
|
-
]);
|
|
335
|
+
const tagAnnotation = childProcess.execSync('git for-each-ref refs/tags/v1.1.0-alpha.0 --format="%(contents)"', {
|
|
336
|
+
encoding: 'utf-8'
|
|
337
|
+
});
|
|
338
|
+
assert.equal(tagAnnotation.trim(), `${owner} ${owner}/${project} ${project}`);
|
|
376
339
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
340
|
+
assert(log.obtrusive.mock.calls[0].arguments[0].endsWith(`release ${pkgName} (1.0.0...1.1.0-alpha.0)`));
|
|
341
|
+
assert(log.log.mock.calls[0].arguments[0].endsWith(`https://www.npmjs.com/package/${pkgName}`));
|
|
342
|
+
assert(log.log.mock.calls[1].arguments[0].endsWith(`/${owner}/${project}/releases/tag/v1.1.0-alpha.0`));
|
|
343
|
+
assert(log.log.mock.calls[2].arguments[0].endsWith(`/${project}/-/releases/v1.1.0-alpha.0`));
|
|
344
|
+
assert.match(log.log.mock.calls.at(-1).arguments[0], /Done \(in [0-9]+s\.\)/);
|
|
345
|
+
});
|
|
382
346
|
|
|
383
|
-
|
|
384
|
-
|
|
347
|
+
test('should publish pre-release without pre-id with different npm.tag', async t => {
|
|
348
|
+
const pkgName = path.basename(target);
|
|
349
|
+
gitAdd(`{"name":"${pkgName}","version":"1.0.0"}`, 'package.json', 'Add package.json');
|
|
350
|
+
childProcess.execSync('git tag v1.0.0', execOpts);
|
|
385
351
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
const pkgName = path.basename(target);
|
|
389
|
-
gitAdd(`{"name":"${pkgName}","version":"1.0.0","private":true}`, 'package.json', 'Add package.json');
|
|
390
|
-
gitAdd(`{"name":"${pkgName}","version":"1.0.0","private":true}`, 'package-lock.json', 'Add package-lock.json');
|
|
352
|
+
const container = getContainer({ increment: 'major', preRelease: true, npm: { name: pkgName, tag: 'next' } });
|
|
353
|
+
const exec = t.mock.method(container.shell, 'exec');
|
|
391
354
|
|
|
392
|
-
|
|
393
|
-
const exec = sinon.spy(container.shell, 'exec');
|
|
355
|
+
await runTasks({}, container);
|
|
394
356
|
|
|
395
|
-
|
|
357
|
+
const npmArgs = getArgs(exec, 'npm');
|
|
358
|
+
assert.deepEqual(npmArgs, [
|
|
359
|
+
'npm ping',
|
|
360
|
+
'npm whoami',
|
|
361
|
+
`npm show ${pkgName}@latest version`,
|
|
362
|
+
'npm --version',
|
|
363
|
+
`npm access ${npmMajorVersion >= 9 ? 'list collaborators --json' : 'ls-collaborators'} ${pkgName}`,
|
|
364
|
+
'npm version 2.0.0-0 --no-git-tag-version',
|
|
365
|
+
'npm publish . --tag next'
|
|
366
|
+
]);
|
|
396
367
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
368
|
+
const stdout = childProcess.execSync('git describe --tags --match=* --abbrev=0', { encoding: 'utf-8' });
|
|
369
|
+
assert.equal(stdout.trim(), 'v2.0.0-0');
|
|
370
|
+
assert(log.obtrusive.mock.calls[0].arguments[0].endsWith(`release ${pkgName} (1.0.0...2.0.0-0)`));
|
|
371
|
+
assert(log.log.mock.calls[0].arguments[0].endsWith(`https://www.npmjs.com/package/${pkgName}`));
|
|
372
|
+
assert.match(log.log.mock.calls.at(-1).arguments[0], /Done \(in [0-9]+s\.\)/);
|
|
373
|
+
});
|
|
402
374
|
|
|
403
|
-
|
|
404
|
-
|
|
375
|
+
test('should handle private package correctly, bump lockfile', async t => {
|
|
376
|
+
const pkgName = path.basename(target);
|
|
377
|
+
gitAdd(`{"name":"${pkgName}","version":"1.0.0","private":true}`, 'package.json', 'Add package.json');
|
|
378
|
+
gitAdd(`{"name":"${pkgName}","version":"1.0.0","private":true}`, 'package-lock.json', 'Add package-lock.json');
|
|
405
379
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
380
|
+
const container = getContainer({ npm: { name: pkgName, private: true } });
|
|
381
|
+
const exec = t.mock.method(container.shell, 'exec');
|
|
382
|
+
|
|
383
|
+
await runTasks({}, container);
|
|
410
384
|
|
|
411
|
-
|
|
385
|
+
const npmArgs = getArgs(exec, 'npm');
|
|
386
|
+
assert.deepEqual(npmArgs, ['npm version 1.0.1 --no-git-tag-version']);
|
|
387
|
+
assert(log.obtrusive.mock.calls[0].arguments[0].endsWith(`release ${pkgName} (1.0.0...1.0.1)`));
|
|
388
|
+
assert.equal(log.warn.length, 0);
|
|
389
|
+
assert.match(log.log.mock.calls[0].arguments[0], /Done \(in [0-9]+s\.\)/);
|
|
390
|
+
});
|
|
412
391
|
|
|
413
|
-
|
|
414
|
-
|
|
392
|
+
test('should initially publish non-private scoped npm package privately', async t => {
|
|
393
|
+
const pkgName = path.basename(target);
|
|
394
|
+
gitAdd(`{"name":"@scope/${pkgName}","version":"1.0.0"}`, 'package.json', 'Add package.json');
|
|
415
395
|
|
|
416
|
-
|
|
396
|
+
const container = getContainer({ npm: { name: pkgName } });
|
|
417
397
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
398
|
+
const original = container.shell.exec.bind(container.shell);
|
|
399
|
+
const exec = t.mock.method(container.shell, 'exec', (...args) => {
|
|
400
|
+
if (args[0] === `npm show @scope/${pkgName}@latest version`) return Promise.reject();
|
|
401
|
+
return original(...args);
|
|
402
|
+
});
|
|
422
403
|
|
|
423
|
-
|
|
424
|
-
const { target } = t.context;
|
|
425
|
-
const pkgName = path.basename(target);
|
|
426
|
-
const registry = 'https://my-registry.example.org';
|
|
404
|
+
await runTasks({}, container);
|
|
427
405
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
version: '1.2.3',
|
|
432
|
-
publishConfig: { registry }
|
|
433
|
-
}),
|
|
434
|
-
'package.json',
|
|
435
|
-
'Add package.json'
|
|
436
|
-
);
|
|
406
|
+
const npmArgs = getArgs(exec, 'npm');
|
|
407
|
+
assert.equal(npmArgs[6], 'npm publish . --tag latest');
|
|
408
|
+
});
|
|
437
409
|
|
|
438
|
-
|
|
410
|
+
test('should use pkg.publishConfig.registry', async t => {
|
|
411
|
+
const pkgName = path.basename(target);
|
|
412
|
+
const registry = 'https://my-registry.example.org';
|
|
439
413
|
|
|
440
|
-
|
|
414
|
+
gitAdd(
|
|
415
|
+
JSON.stringify({
|
|
416
|
+
name: pkgName,
|
|
417
|
+
version: '1.2.3',
|
|
418
|
+
publishConfig: { registry }
|
|
419
|
+
}),
|
|
420
|
+
'package.json',
|
|
421
|
+
'Add package.json'
|
|
422
|
+
);
|
|
441
423
|
|
|
442
|
-
|
|
424
|
+
const container = getContainer();
|
|
443
425
|
|
|
444
|
-
|
|
445
|
-
t.is(npmArgs[0], `npm ping --registry ${registry}`);
|
|
446
|
-
t.is(npmArgs[1], `npm whoami --registry ${registry}`);
|
|
447
|
-
t.true(container.log.log.firstCall.args[0].endsWith(`${registry}/package/${pkgName}`));
|
|
426
|
+
const exec = t.mock.method(container.shell, 'exec');
|
|
448
427
|
|
|
449
|
-
|
|
450
|
-
});
|
|
428
|
+
await runTasks({}, container);
|
|
451
429
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
};
|
|
458
|
-
const container = getContainer(config);
|
|
430
|
+
const npmArgs = getArgs(exec, 'npm');
|
|
431
|
+
assert.equal(npmArgs[0], `npm ping --registry ${registry}`);
|
|
432
|
+
assert.equal(npmArgs[1], `npm whoami --registry ${registry}`);
|
|
433
|
+
assert(container.log.log.mock.calls[0].arguments[0].endsWith(`${registry}/package/${pkgName}`));
|
|
434
|
+
});
|
|
459
435
|
|
|
460
|
-
|
|
436
|
+
test('should propagate errors', async () => {
|
|
437
|
+
const config = {
|
|
438
|
+
hooks: {
|
|
439
|
+
'before:init': 'some-failing-command'
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
const container = getContainer(config);
|
|
461
443
|
|
|
462
|
-
|
|
463
|
-
});
|
|
444
|
+
await assert.rejects(runTasks({}, container), { message: /some-failing-command/ });
|
|
464
445
|
|
|
465
|
-
|
|
466
|
-
const { bare } = t.context;
|
|
467
|
-
const project = path.basename(bare);
|
|
468
|
-
const owner = path.basename(path.dirname(bare));
|
|
469
|
-
childProcess.execSync('git tag v1.0.0', execOpts);
|
|
470
|
-
gitAdd('line', 'file', 'More file');
|
|
471
|
-
|
|
472
|
-
interceptGitHubAuthentication();
|
|
473
|
-
interceptGitHubCollaborator({ owner, project });
|
|
474
|
-
interceptGitHubCreate({
|
|
475
|
-
owner,
|
|
476
|
-
project,
|
|
477
|
-
body: {
|
|
478
|
-
tag_name: 'v1.1.0',
|
|
479
|
-
name: 'Release 1.1.0',
|
|
480
|
-
body: 'custom-changelog-generator --from=v1.0.0 --to=v1.1.0',
|
|
481
|
-
draft: false,
|
|
482
|
-
prerelease: false
|
|
483
|
-
}
|
|
446
|
+
assert.equal(log.error.mock.callCount(), 1);
|
|
484
447
|
});
|
|
485
448
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
449
|
+
test('should use custom changelog command with context', async t => {
|
|
450
|
+
const project = path.basename(bare);
|
|
451
|
+
const owner = path.basename(path.dirname(bare));
|
|
452
|
+
childProcess.execSync('git tag v1.0.0', execOpts);
|
|
453
|
+
gitAdd('line', 'file', 'More file');
|
|
454
|
+
|
|
455
|
+
interceptGitHubAuthentication(github);
|
|
456
|
+
interceptGitHubCollaborator(github, { owner, project });
|
|
457
|
+
interceptGitHubCreate(github, {
|
|
458
|
+
owner,
|
|
459
|
+
project,
|
|
460
|
+
body: {
|
|
461
|
+
tag_name: 'v1.1.0',
|
|
462
|
+
name: 'Release 1.1.0',
|
|
463
|
+
body: 'custom-changelog-generator --from=v1.0.0 --to=v1.1.0',
|
|
464
|
+
draft: false,
|
|
465
|
+
prerelease: false
|
|
466
|
+
}
|
|
467
|
+
});
|
|
494
468
|
|
|
495
|
-
|
|
469
|
+
const container = getContainer({
|
|
470
|
+
increment: 'minor',
|
|
471
|
+
github: {
|
|
472
|
+
release: true,
|
|
473
|
+
releaseNotes: 'echo custom-changelog-generator --from=${latestTag} --to=${tagName}',
|
|
474
|
+
pushRepo: `https://github.com/${owner}/${project}`
|
|
475
|
+
}
|
|
476
|
+
});
|
|
496
477
|
|
|
497
|
-
|
|
478
|
+
const exec = t.mock.method(container.shell, 'execStringCommand');
|
|
498
479
|
|
|
499
|
-
|
|
480
|
+
await runTasks({}, container);
|
|
500
481
|
|
|
501
|
-
|
|
482
|
+
const command = exec.mock.calls
|
|
483
|
+
.map(call => call.arguments)
|
|
484
|
+
.find(([command]) => command.includes('custom-changelog-generator'));
|
|
502
485
|
|
|
503
|
-
|
|
504
|
-
});
|
|
486
|
+
assert.equal(command[0], 'echo custom-changelog-generator --from=v1.0.0 --to=v1.1.0');
|
|
487
|
+
});
|
|
505
488
|
|
|
506
|
-
{
|
|
507
|
-
test.serial('should run all hooks', async t => {
|
|
489
|
+
test('should run all hooks', async t => {
|
|
508
490
|
gitAdd(`{"name":"hooked","version":"1.0.0","type":"module"}`, 'package.json', 'Add package.json');
|
|
509
491
|
childProcess.execSync(`npm install ${rootDir}`, execOpts);
|
|
510
492
|
const plugin = "import { Plugin } from 'release-it'; class MyPlugin extends Plugin {}; export default MyPlugin;";
|
|
@@ -524,13 +506,13 @@ test.serial('should use custom changelog command with context', async t => {
|
|
|
524
506
|
git: { requireCleanWorkingDir: false },
|
|
525
507
|
hooks
|
|
526
508
|
});
|
|
527
|
-
const exec =
|
|
509
|
+
const exec = t.mock.method(container.shell, 'execFormattedCommand');
|
|
528
510
|
|
|
529
511
|
await runTasks({}, container);
|
|
530
512
|
|
|
531
|
-
const commands = exec
|
|
513
|
+
const commands = getArgs(exec, 'echo');
|
|
532
514
|
|
|
533
|
-
|
|
515
|
+
assert.deepEqual(commands, [
|
|
534
516
|
'echo before:init',
|
|
535
517
|
'echo before:my-plugin:init',
|
|
536
518
|
'echo after:my-plugin:init',
|
|
@@ -592,7 +574,5 @@ test.serial('should use custom changelog command with context', async t => {
|
|
|
592
574
|
'echo after:my-plugin:afterRelease',
|
|
593
575
|
'echo after:afterRelease'
|
|
594
576
|
]);
|
|
595
|
-
|
|
596
|
-
exec.restore();
|
|
597
577
|
});
|
|
598
|
-
}
|
|
578
|
+
});
|