commit-and-tag-version 11.3.0 → 12.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +46 -3
- package/.gitattributes +2 -0
- package/.github/dependabot.yml +19 -0
- package/.github/workflows/ci.yaml +12 -5
- package/.github/workflows/release-please.yml +3 -3
- package/.prettierrc +3 -0
- package/CHANGELOG.md +19 -0
- package/README.md +7 -1
- package/bin/cli.js +6 -6
- package/command.js +43 -37
- package/defaults.js +12 -11
- package/index.js +44 -42
- package/jest.config.js +28 -0
- package/lib/checkpoint.js +19 -8
- package/lib/configuration.js +17 -17
- package/lib/detect-package-manager.js +20 -20
- package/lib/format-commit-message.js +3 -3
- package/lib/latest-semver-tag.js +13 -11
- package/lib/lifecycles/bump.js +136 -105
- package/lib/lifecycles/changelog.js +88 -48
- package/lib/lifecycles/commit.js +41 -42
- package/lib/lifecycles/tag.js +41 -31
- package/lib/preset-loader.js +12 -10
- package/lib/print-error.js +10 -7
- package/lib/run-exec.js +10 -10
- package/lib/run-execFile.js +10 -10
- package/lib/run-lifecycle-script.js +16 -11
- package/lib/stringify-package.js +10 -10
- package/lib/updaters/index.js +40 -33
- package/lib/updaters/types/csproj.js +9 -7
- package/lib/updaters/types/gradle.js +10 -8
- package/lib/updaters/types/json.js +14 -14
- package/lib/updaters/types/plain-text.js +4 -4
- package/lib/write-file.js +4 -4
- package/package.json +20 -25
- package/test/commit-message-config.integration-test.js +106 -0
- package/test/config-files.integration-test.js +114 -0
- package/test/config-keys.integration-test.js +83 -0
- package/test/core.spec.js +1594 -874
- package/test/git.integration-test.js +363 -0
- package/test/invalid-config.integration-test.js +73 -0
- package/test/mocks/jest-mocks.js +48 -0
- package/test/mocks/updater/customer-updater.js +5 -8
- package/test/mocks/updater/increment-updater.js +5 -5
- package/test/pre-commit-hook.integration-test.js +192 -0
- package/test/preset.integration-test.js +56 -0
- package/test/stringify-package.spec.js +18 -22
- package/test/utils.spec.js +26 -42
- package/renovate.json +0 -9
- package/test/config-files.spec.js +0 -176
- package/test/git.spec.js +0 -480
- package/test/preset.spec.js +0 -52
package/test/core.spec.js
CHANGED
|
@@ -1,1031 +1,1751 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const shell = require('shelljs');
|
|
4
|
+
const stripAnsi = require('strip-ansi');
|
|
5
|
+
const fs = require('fs');
|
|
4
6
|
|
|
5
|
-
const
|
|
6
|
-
const fs = require('fs')
|
|
7
|
-
const { resolve } = require('path')
|
|
8
|
-
const { Readable } = require('stream')
|
|
9
|
-
const mockFS = require('mock-fs')
|
|
10
|
-
const mockery = require('mockery')
|
|
11
|
-
const stdMocks = require('std-mocks')
|
|
12
|
-
const stripAnsi = require('strip-ansi')
|
|
7
|
+
const mockers = require('./mocks/jest-mocks');
|
|
13
8
|
|
|
14
|
-
const
|
|
15
|
-
const formatCommitMessage = require('../lib/format-commit-message')
|
|
9
|
+
const runExecFile = require('../lib/run-execFile');
|
|
16
10
|
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const expect = chai.expect
|
|
20
|
-
chai.use(require('chai-as-promised'))
|
|
11
|
+
const cli = require('../command');
|
|
12
|
+
const formatCommitMessage = require('../lib/format-commit-message');
|
|
21
13
|
|
|
22
14
|
// set by mock()
|
|
23
|
-
let standardVersion
|
|
15
|
+
let standardVersion;
|
|
16
|
+
let readFileSyncSpy;
|
|
17
|
+
let lstatSyncSpy;
|
|
24
18
|
|
|
25
|
-
|
|
19
|
+
// Rather than trying to re-read something written out during tests, we can spy on writeFileSync
|
|
20
|
+
// we can trust fs is capable of writing the file
|
|
21
|
+
let writeFileSyncSpy;
|
|
22
|
+
|
|
23
|
+
const consoleErrorSpy = jest.spyOn(console, 'warn').mockImplementation();
|
|
24
|
+
const consoleInfoSpy = jest.spyOn(console, 'info').mockImplementation();
|
|
25
|
+
|
|
26
|
+
jest.mock('../lib/run-execFile');
|
|
27
|
+
|
|
28
|
+
const { readFileSync: readFileSyncActual, lstatSync: lstatSyncActual } = fs;
|
|
29
|
+
|
|
30
|
+
function exec(opt = '', git) {
|
|
26
31
|
if (typeof opt === 'string') {
|
|
27
|
-
opt = cli.parse(`commit-and-tag-version ${opt}`)
|
|
32
|
+
opt = cli.parse(`commit-and-tag-version ${opt}`);
|
|
28
33
|
}
|
|
29
|
-
if (!git) opt.skip = Object.assign({}, opt.skip, { commit: true, tag: true })
|
|
30
|
-
return standardVersion(opt)
|
|
34
|
+
if (!git) opt.skip = Object.assign({}, opt.skip, { commit: true, tag: true });
|
|
35
|
+
return standardVersion(opt);
|
|
31
36
|
}
|
|
32
37
|
|
|
33
|
-
function
|
|
34
|
-
return
|
|
38
|
+
function attemptingToReadPackageJson(path) {
|
|
39
|
+
return path.includes('package.json') || path.includes('package-lock.json');
|
|
35
40
|
}
|
|
36
41
|
|
|
42
|
+
/**
|
|
43
|
+
* @param fs - reference to 'fs' - needs to be defined in the root test class so that mocking works correctly
|
|
44
|
+
* @param readFileSyncActual - actual implementation of fs.readFileSync - reference should be defined as a variable in root test class so we can unset spy after
|
|
45
|
+
* @param existingChangelog ?: string - Existing CHANGELOG.md content
|
|
46
|
+
* @param testFiles ?: object[] - with Path and Value fields, for mocking readFileSynch on packageFiles such as package.json, bower.json, manifest.json
|
|
47
|
+
* @param realTestFiles ?: object[] - with Filename (e.g. mix.exs) and Path to real file in a directory
|
|
48
|
+
* @return Jest spy on readFileSync
|
|
49
|
+
*/
|
|
50
|
+
const mockReadFilesFromDisk = ({
|
|
51
|
+
fs,
|
|
52
|
+
readFileSyncActual,
|
|
53
|
+
existingChangelog,
|
|
54
|
+
testFiles,
|
|
55
|
+
realTestFiles,
|
|
56
|
+
}) =>
|
|
57
|
+
jest.spyOn(fs, 'readFileSync').mockImplementation((path, opts) => {
|
|
58
|
+
if (path === 'CHANGELOG.md') {
|
|
59
|
+
if (existingChangelog) {
|
|
60
|
+
return existingChangelog;
|
|
61
|
+
}
|
|
62
|
+
return '';
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// If deliberately set to null when mocking, don't create a fake package.json
|
|
66
|
+
if (testFiles === null && attemptingToReadPackageJson(path)) {
|
|
67
|
+
return '{}';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (testFiles) {
|
|
71
|
+
const file = testFiles.find((otherFile) => {
|
|
72
|
+
return path.includes(otherFile.path);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
if (file) {
|
|
76
|
+
if (file.value instanceof String || typeof file.value === 'string') {
|
|
77
|
+
return file.value;
|
|
78
|
+
}
|
|
79
|
+
return JSON.stringify(file.value);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// For scenarios where we have defined testFiles such as bower.json
|
|
83
|
+
// Do not create a fake package.json file
|
|
84
|
+
if (attemptingToReadPackageJson(path)) {
|
|
85
|
+
return '{}';
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// If no package files defined and not explicitly set to null, create a fake package json
|
|
90
|
+
// otherwise fs will read the real package.json in the root of this project!
|
|
91
|
+
if (attemptingToReadPackageJson(path)) {
|
|
92
|
+
return JSON.stringify({ version: '1.0.0' });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (realTestFiles) {
|
|
96
|
+
const testFile = realTestFiles.find((testFile) => {
|
|
97
|
+
return path.includes(testFile.filename);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
if (testFile) {
|
|
101
|
+
return readFileSyncActual(testFile.path, opts);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return readFileSyncActual(path, opts);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @param fs - reference to 'fs' - needs to be defined in the root test class so that mocking works correctly
|
|
110
|
+
* @param lstatSyncActual - actual implementation of fs.lstatSync
|
|
111
|
+
* @param testFiles ?: object[] - with Path and Value fields, for mocking lstatSync on packageFiles such as package.json, bower.json, manifest.json
|
|
112
|
+
* @param realTestFiles ?: object[] - with Filename (e.g. mix.exs) and Path to real file in a directory
|
|
113
|
+
* @return Jest spy on lstatSync
|
|
114
|
+
*/
|
|
115
|
+
const mockFsLStat = ({ fs, lstatSyncActual, testFiles, realTestFiles }) =>
|
|
116
|
+
jest.spyOn(fs, 'lstatSync').mockImplementation((path) => {
|
|
117
|
+
if (testFiles) {
|
|
118
|
+
const file = testFiles.find((otherFile) => {
|
|
119
|
+
return path.includes(otherFile.path);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
if (file) {
|
|
123
|
+
return {
|
|
124
|
+
isFile: () => true,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (realTestFiles) {
|
|
130
|
+
const file = realTestFiles.find((otherFile) => {
|
|
131
|
+
return path.includes(otherFile.filename);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
if (file) {
|
|
135
|
+
return {
|
|
136
|
+
isFile: () => true,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return lstatSyncActual(path);
|
|
142
|
+
});
|
|
143
|
+
|
|
37
144
|
/**
|
|
38
145
|
* Mock external conventional-changelog modules
|
|
39
146
|
*
|
|
40
147
|
* Mocks should be unregistered in test cleanup by calling unmock()
|
|
41
148
|
*
|
|
42
149
|
* bump?: 'major' | 'minor' | 'patch' | Error | (opt, parserOpts, cb) => { cb(err) | cb(null, { releaseType }) }
|
|
43
|
-
* changelog?: string | Error | Array<string | Error | (opt) => string | null>
|
|
150
|
+
* changelog?: string | Error | Array<string | Error | (opt) => string | null> - Changelog to be "generated" by conventional-changelog when reading commit history
|
|
44
151
|
* execFile?: ({ dryRun, silent }, cmd, cmdArgs) => Promise<string>
|
|
45
|
-
* fs?: { [string]: string | Buffer | any }
|
|
46
|
-
* pkg?: { [string]: any }
|
|
47
152
|
* tags?: string[] | Error
|
|
153
|
+
* existingChangelog?: string - Existing CHANGELOG.md content
|
|
154
|
+
* testFiles?: object[] - with Path and Value fields, for mocking readFileSynch on packageFiles such as package.json, bower.json, manifest.json
|
|
155
|
+
* realTestFiles?: object[] - with Filename (e.g. mix.exs) and Path to real file in test directory
|
|
48
156
|
*/
|
|
49
|
-
function mock
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
this.push(next(opt))
|
|
69
|
-
} else {
|
|
70
|
-
this.push(next ? Buffer.from(next, 'utf8') : null)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
})
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
mockery.registerMock('git-semver-tags', function (cb) {
|
|
77
|
-
if (tags instanceof Error) cb(tags)
|
|
78
|
-
else cb(null, tags | [])
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
if (typeof execFile === 'function') {
|
|
82
|
-
// called from commit & tag lifecycle methods
|
|
83
|
-
mockery.registerMock('../run-execFile', execFile)
|
|
84
|
-
}
|
|
157
|
+
function mock({
|
|
158
|
+
bump,
|
|
159
|
+
changelog,
|
|
160
|
+
tags,
|
|
161
|
+
existingChangelog,
|
|
162
|
+
testFiles,
|
|
163
|
+
realTestFiles,
|
|
164
|
+
} = {}) {
|
|
165
|
+
mockers.mockRecommendedBump({ bump });
|
|
166
|
+
|
|
167
|
+
if (!Array.isArray(changelog)) changelog = [changelog];
|
|
168
|
+
|
|
169
|
+
mockers.mockConventionalChangelog({
|
|
170
|
+
changelog,
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
mockers.mockGitSemverTags({
|
|
174
|
+
tags,
|
|
175
|
+
});
|
|
85
176
|
|
|
86
177
|
// needs to be set after mockery, but before mock-fs
|
|
87
|
-
standardVersion = require('../index')
|
|
178
|
+
standardVersion = require('../index');
|
|
179
|
+
|
|
180
|
+
// For fake and injected test files pretend they exist at root level when Fs queries lstat
|
|
181
|
+
// Package.json works without this as it'll check the one in this actual repo...
|
|
182
|
+
lstatSyncSpy = mockFsLStat({
|
|
183
|
+
fs,
|
|
184
|
+
lstatSyncActual,
|
|
185
|
+
testFiles,
|
|
186
|
+
realTestFiles,
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
readFileSyncSpy = mockReadFilesFromDisk({
|
|
190
|
+
fs,
|
|
191
|
+
readFileSyncActual,
|
|
192
|
+
existingChangelog,
|
|
193
|
+
testFiles,
|
|
194
|
+
realTestFiles,
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
// Spies on writeFileSync to capture calls and ensure we don't actually try write anything to disc
|
|
198
|
+
writeFileSyncSpy = jest.spyOn(fs, 'writeFileSync').mockImplementation();
|
|
199
|
+
}
|
|
88
200
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
fs['package.json'] = JSON.stringify({ version: '1.0.0' })
|
|
94
|
-
}
|
|
95
|
-
mockFS(fs)
|
|
201
|
+
function clearCapturedSpyCalls() {
|
|
202
|
+
consoleInfoSpy.mockClear();
|
|
203
|
+
consoleErrorSpy.mockClear();
|
|
204
|
+
}
|
|
96
205
|
|
|
97
|
-
|
|
98
|
-
|
|
206
|
+
function restoreMocksToRealImplementation() {
|
|
207
|
+
readFileSyncSpy.mockRestore();
|
|
208
|
+
writeFileSyncSpy.mockRestore();
|
|
209
|
+
lstatSyncSpy.mockRestore();
|
|
99
210
|
}
|
|
100
211
|
|
|
101
|
-
function unmock
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
standardVersion = null
|
|
107
|
-
|
|
108
|
-
// push out prints from the Mocha reporter
|
|
109
|
-
const { stdout } = stdMocks.flush()
|
|
110
|
-
for (const str of stdout) {
|
|
111
|
-
if (str.startsWith(' ')) process.stdout.write(str)
|
|
112
|
-
}
|
|
212
|
+
function unmock() {
|
|
213
|
+
clearCapturedSpyCalls();
|
|
214
|
+
|
|
215
|
+
restoreMocksToRealImplementation();
|
|
216
|
+
|
|
217
|
+
standardVersion = null;
|
|
113
218
|
}
|
|
114
219
|
|
|
115
220
|
describe('format-commit-message', function () {
|
|
116
221
|
it('works for no {{currentTag}}', function () {
|
|
117
|
-
formatCommitMessage('chore(release): 1.0.0', '1.0.0').
|
|
118
|
-
'chore(release): 1.0.0'
|
|
119
|
-
)
|
|
120
|
-
})
|
|
222
|
+
expect(formatCommitMessage('chore(release): 1.0.0', '1.0.0')).toEqual(
|
|
223
|
+
'chore(release): 1.0.0',
|
|
224
|
+
);
|
|
225
|
+
});
|
|
121
226
|
it('works for one {{currentTag}}', function () {
|
|
122
|
-
|
|
123
|
-
'chore(release): 1.0.0'
|
|
124
|
-
)
|
|
125
|
-
})
|
|
227
|
+
expect(
|
|
228
|
+
formatCommitMessage('chore(release): {{currentTag}}', '1.0.0'),
|
|
229
|
+
).toEqual('chore(release): 1.0.0');
|
|
230
|
+
});
|
|
126
231
|
it('works for two {{currentTag}}', function () {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
)
|
|
133
|
-
|
|
134
|
-
|
|
232
|
+
expect(
|
|
233
|
+
formatCommitMessage(
|
|
234
|
+
'chore(release): {{currentTag}} \n\n* CHANGELOG: https://github.com/absolute-version/commit-and-tag-version/blob/v{{currentTag}}/CHANGELOG.md',
|
|
235
|
+
'1.0.0',
|
|
236
|
+
),
|
|
237
|
+
).toEqual(
|
|
238
|
+
'chore(release): 1.0.0 \n\n* CHANGELOG: https://github.com/absolute-version/commit-and-tag-version/blob/v1.0.0/CHANGELOG.md',
|
|
239
|
+
);
|
|
240
|
+
});
|
|
241
|
+
});
|
|
135
242
|
|
|
136
243
|
describe('cli', function () {
|
|
137
|
-
afterEach(unmock)
|
|
244
|
+
afterEach(unmock);
|
|
138
245
|
|
|
139
246
|
describe('CHANGELOG.md does not exist', function () {
|
|
140
247
|
it('populates changelog with commits since last tag by default', async function () {
|
|
141
|
-
mock({ bump: 'patch', changelog: 'patch release\n', tags: ['v1.0.0'] })
|
|
142
|
-
await exec()
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
248
|
+
mock({ bump: 'patch', changelog: 'patch release\n', tags: ['v1.0.0'] });
|
|
249
|
+
await exec();
|
|
250
|
+
verifyNewChangelogContentMatches({
|
|
251
|
+
writeFileSyncSpy,
|
|
252
|
+
expectedContent: /patch release/,
|
|
253
|
+
});
|
|
254
|
+
});
|
|
146
255
|
|
|
147
256
|
it('includes all commits if --first-release is true', async function () {
|
|
148
257
|
mock({
|
|
149
258
|
bump: 'minor',
|
|
150
259
|
changelog: 'first commit\npatch release\n',
|
|
151
|
-
|
|
152
|
-
})
|
|
153
|
-
await exec('--first-release')
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
260
|
+
testFiles: [{ path: 'package.json', value: { version: '1.0.1' } }],
|
|
261
|
+
});
|
|
262
|
+
await exec('--first-release');
|
|
263
|
+
verifyNewChangelogContentMatches({
|
|
264
|
+
writeFileSyncSpy,
|
|
265
|
+
expectedContent: /patch release/,
|
|
266
|
+
});
|
|
267
|
+
verifyNewChangelogContentMatches({
|
|
268
|
+
writeFileSyncSpy,
|
|
269
|
+
expectedContent: /first commit/,
|
|
270
|
+
});
|
|
271
|
+
});
|
|
158
272
|
|
|
159
273
|
it('skipping changelog will not create a changelog file', async function () {
|
|
160
|
-
mock({ bump: 'minor', changelog: 'foo\n' })
|
|
161
|
-
await exec('--skip.changelog true')
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
274
|
+
mock({ bump: 'minor', changelog: 'foo\n' });
|
|
275
|
+
await exec('--skip.changelog true');
|
|
276
|
+
|
|
277
|
+
verifyPackageVersion({ writeFileSyncSpy, expectedVersion: '1.1.0' });
|
|
278
|
+
expect(writeFileSyncSpy).not.toHaveBeenCalledWith('CHANGELOG.md');
|
|
279
|
+
});
|
|
280
|
+
});
|
|
166
281
|
|
|
167
282
|
describe('CHANGELOG.md exists', function () {
|
|
168
|
-
|
|
283
|
+
afterEach(unmock);
|
|
284
|
+
|
|
285
|
+
it('appends the new release above the last release, removing the old header (legacy format), and does not retain any front matter', async function () {
|
|
286
|
+
const frontMatter = '---\nstatus: new\n---\n';
|
|
169
287
|
mock({
|
|
170
288
|
bump: 'patch',
|
|
171
289
|
changelog: 'release 1.0.1\n',
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
290
|
+
existingChangelog:
|
|
291
|
+
frontMatter + 'legacy header format<a name="1.0.0">\n',
|
|
292
|
+
tags: ['v1.0.0'],
|
|
293
|
+
});
|
|
294
|
+
await exec();
|
|
295
|
+
|
|
296
|
+
verifyNewChangelogContentMatches({
|
|
297
|
+
writeFileSyncSpy,
|
|
298
|
+
expectedContent: /1\.0\.1/,
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
verifyNewChangelogContentDoesNotMatch({
|
|
302
|
+
writeFileSyncSpy,
|
|
303
|
+
expectedContent: /legacy header format/,
|
|
304
|
+
});
|
|
305
|
+
verifyNewChangelogContentDoesNotMatch({
|
|
306
|
+
writeFileSyncSpy,
|
|
307
|
+
expectedContent: /---status: new---/,
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
it('appends the new release above the last release, replacing the old header (standard-version format) with header (new format), and retains any front matter', async function () {
|
|
312
|
+
const { header } = require('../defaults');
|
|
313
|
+
|
|
314
|
+
const standardVersionHeader =
|
|
315
|
+
'# Changelog\n\nAll notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.';
|
|
316
|
+
|
|
317
|
+
const frontMatter = '---\nstatus: new\n---\n';
|
|
318
|
+
|
|
319
|
+
const changelog101 =
|
|
320
|
+
'### [1.0.1](/compare/v1.0.0...v1.0.1) (YYYY-MM-DD)\n\n\n### Bug Fixes\n\n* patch release ABCDEFXY\n';
|
|
321
|
+
|
|
322
|
+
const changelog100 =
|
|
323
|
+
'### [1.0.0](/compare/v0.0.1...v1.0.0) (YYYY-MM-DD)\n\n\n### Features\n\n* Version one feature set\n';
|
|
324
|
+
|
|
325
|
+
const initialChangelog =
|
|
326
|
+
frontMatter + '\n' + standardVersionHeader + '\n' + changelog100;
|
|
327
|
+
|
|
328
|
+
mock({
|
|
329
|
+
bump: 'patch',
|
|
330
|
+
changelog: changelog101,
|
|
331
|
+
existingChangelog: initialChangelog,
|
|
332
|
+
tags: ['v1.0.0'],
|
|
333
|
+
});
|
|
334
|
+
await exec();
|
|
335
|
+
|
|
336
|
+
verifyNewChangelogContentEquals({
|
|
337
|
+
writeFileSyncSpy,
|
|
338
|
+
expectedContent:
|
|
339
|
+
frontMatter + '\n' + header + '\n' + changelog101 + changelog100,
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
it('appends the new release above the last release, removing the old header (new format), and retains any front matter', async function () {
|
|
344
|
+
const { header } = require('../defaults');
|
|
345
|
+
const frontMatter = '---\nstatus: new\n---\n';
|
|
346
|
+
|
|
347
|
+
const changelog101 =
|
|
348
|
+
'### [1.0.1](/compare/v1.0.0...v1.0.1) (YYYY-MM-DD)\n\n\n### Bug Fixes\n\n* patch release ABCDEFXY\n';
|
|
349
|
+
|
|
350
|
+
const changelog100 =
|
|
351
|
+
'### [1.0.0](/compare/v0.0.1...v1.0.0) (YYYY-MM-DD)\n\n\n### Features\n\n* Version one feature set\n';
|
|
352
|
+
|
|
353
|
+
const initialChangelog =
|
|
354
|
+
frontMatter + '\n' + header + '\n' + changelog100;
|
|
355
|
+
|
|
356
|
+
mock({
|
|
357
|
+
bump: 'patch',
|
|
358
|
+
changelog: changelog101,
|
|
359
|
+
existingChangelog: initialChangelog,
|
|
360
|
+
tags: ['v1.0.0'],
|
|
361
|
+
});
|
|
362
|
+
await exec();
|
|
363
|
+
|
|
364
|
+
verifyNewChangelogContentEquals({
|
|
365
|
+
writeFileSyncSpy,
|
|
366
|
+
expectedContent:
|
|
367
|
+
frontMatter + '\n' + header + '\n' + changelog101 + changelog100,
|
|
368
|
+
});
|
|
369
|
+
});
|
|
180
370
|
|
|
181
371
|
it('appends the new release above the last release, removing the old header (new format)', async function () {
|
|
182
|
-
const { header } = require('../defaults')
|
|
372
|
+
const { header } = require('../defaults');
|
|
183
373
|
const changelog1 =
|
|
184
|
-
'### [1.0.1](/compare/v1.0.0...v1.0.1) (YYYY-MM-DD)\n\n\n### Bug Fixes\n\n* patch release ABCDEFXY\n'
|
|
185
|
-
mock({ bump: 'patch', changelog: changelog1, tags: ['v1.0.0'] })
|
|
186
|
-
await exec()
|
|
187
|
-
|
|
188
|
-
|
|
374
|
+
'### [1.0.1](/compare/v1.0.0...v1.0.1) (YYYY-MM-DD)\n\n\n### Bug Fixes\n\n* patch release ABCDEFXY\n';
|
|
375
|
+
mock({ bump: 'patch', changelog: changelog1, tags: ['v1.0.0'] });
|
|
376
|
+
await exec();
|
|
377
|
+
const content = header + '\n' + changelog1;
|
|
378
|
+
verifyNewChangelogContentEquals({
|
|
379
|
+
writeFileSyncSpy,
|
|
380
|
+
expectedContent: content,
|
|
381
|
+
});
|
|
189
382
|
|
|
190
383
|
const changelog2 =
|
|
191
|
-
'### [1.0.2](/compare/v1.0.1...v1.0.2) (YYYY-MM-DD)\n\n\n### Bug Fixes\n\n* another patch release ABCDEFXY\n'
|
|
192
|
-
unmock()
|
|
384
|
+
'### [1.0.2](/compare/v1.0.1...v1.0.2) (YYYY-MM-DD)\n\n\n### Bug Fixes\n\n* another patch release ABCDEFXY\n';
|
|
385
|
+
unmock();
|
|
386
|
+
|
|
193
387
|
mock({
|
|
194
388
|
bump: 'patch',
|
|
195
389
|
changelog: changelog2,
|
|
196
|
-
|
|
197
|
-
tags: ['v1.0.0', 'v1.0.1']
|
|
198
|
-
})
|
|
199
|
-
await exec()
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
390
|
+
existingChangelog: content,
|
|
391
|
+
tags: ['v1.0.0', 'v1.0.1'],
|
|
392
|
+
});
|
|
393
|
+
await exec();
|
|
394
|
+
verifyNewChangelogContentEquals({
|
|
395
|
+
writeFileSyncSpy,
|
|
396
|
+
expectedContent: header + '\n' + changelog2 + changelog1,
|
|
397
|
+
});
|
|
398
|
+
});
|
|
203
399
|
|
|
204
400
|
it('[DEPRECATED] (--changelogHeader) allows for a custom changelog header', async function () {
|
|
205
|
-
const header = '# Pork Chop Log'
|
|
401
|
+
const header = '# Pork Chop Log';
|
|
206
402
|
mock({
|
|
207
403
|
bump: 'minor',
|
|
208
404
|
changelog: header + '\n',
|
|
209
|
-
|
|
210
|
-
})
|
|
211
|
-
await exec(`--changelogHeader="${header}"`)
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
405
|
+
existingChangelog: '',
|
|
406
|
+
});
|
|
407
|
+
await exec(`--changelogHeader="${header}"`);
|
|
408
|
+
verifyNewChangelogContentMatches({
|
|
409
|
+
writeFileSyncSpy,
|
|
410
|
+
expectedContent: new RegExp(header),
|
|
411
|
+
});
|
|
412
|
+
});
|
|
215
413
|
|
|
216
414
|
it('[DEPRECATED] (--changelogHeader) exits with error if changelog header matches last version search regex', async function () {
|
|
217
|
-
mock({ bump: 'minor',
|
|
218
|
-
expect(exec('--changelogHeader="## 3.0.2"')).
|
|
219
|
-
|
|
220
|
-
|
|
415
|
+
mock({ bump: 'minor', existingChangelog: '' });
|
|
416
|
+
await expect(exec('--changelogHeader="## 3.0.2"')).rejects.toThrow(
|
|
417
|
+
/custom changelog header must not match/,
|
|
418
|
+
);
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
describe('lifecycle scripts', function () {
|
|
423
|
+
afterEach(unmock);
|
|
221
424
|
|
|
222
|
-
describe('lifecycle scripts', () => {
|
|
223
425
|
describe('prerelease hook', function () {
|
|
224
426
|
it('should run the prerelease hook when provided', async function () {
|
|
225
|
-
|
|
427
|
+
mock({
|
|
226
428
|
bump: 'minor',
|
|
227
|
-
|
|
228
|
-
})
|
|
429
|
+
existingChangelog: 'legacy header format<a name="1.0.0">\n',
|
|
430
|
+
});
|
|
229
431
|
|
|
230
432
|
await exec({
|
|
231
433
|
scripts: {
|
|
232
|
-
prerelease: "node -e \"console.error('prerelease' + ' ran')\""
|
|
233
|
-
}
|
|
234
|
-
})
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
434
|
+
prerelease: "node -e \"console.error('prerelease' + ' ran')\"",
|
|
435
|
+
},
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
const expectedLog = 'prerelease ran';
|
|
439
|
+
verifyLogPrinted({ consoleInfoSpy: consoleErrorSpy, expectedLog });
|
|
440
|
+
});
|
|
238
441
|
|
|
239
442
|
it('should abort if the hook returns a non-zero exit code', async function () {
|
|
240
443
|
mock({
|
|
241
444
|
bump: 'minor',
|
|
242
|
-
|
|
243
|
-
})
|
|
244
|
-
|
|
245
|
-
expect(
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
445
|
+
existingChangelog: 'legacy header format<a name="1.0.0">\n',
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
await expect(
|
|
449
|
+
exec({
|
|
450
|
+
scripts: {
|
|
451
|
+
prerelease: "node -e \"throw new Error('prerelease' + ' fail')\"",
|
|
452
|
+
},
|
|
453
|
+
}),
|
|
454
|
+
).rejects.toThrow(/prerelease fail/);
|
|
455
|
+
});
|
|
456
|
+
});
|
|
252
457
|
|
|
253
458
|
describe('prebump hook', function () {
|
|
254
459
|
it('should allow prebump hook to return an alternate version #', async function () {
|
|
255
|
-
|
|
460
|
+
mock({
|
|
256
461
|
bump: 'minor',
|
|
257
|
-
|
|
258
|
-
})
|
|
462
|
+
existingChangelog: 'legacy header format<a name="1.0.0">\n',
|
|
463
|
+
});
|
|
259
464
|
|
|
260
465
|
await exec({
|
|
261
466
|
scripts: {
|
|
262
|
-
prebump:
|
|
263
|
-
}
|
|
264
|
-
})
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
})
|
|
467
|
+
prebump: 'node -e "console.log(Array.of(9, 9, 9).join(\'.\'))"',
|
|
468
|
+
},
|
|
469
|
+
});
|
|
470
|
+
verifyLogPrinted({ consoleInfoSpy, expectedLog: '9.9.9' });
|
|
471
|
+
verifyPackageVersion({ writeFileSyncSpy, expectedVersion: '9.9.9' });
|
|
472
|
+
});
|
|
269
473
|
|
|
270
474
|
it('should not allow prebump hook to return a releaseAs command', async function () {
|
|
271
475
|
mock({
|
|
272
476
|
bump: 'minor',
|
|
273
|
-
|
|
274
|
-
})
|
|
477
|
+
existingChangelog: 'legacy header format<a name="1.0.0">\n',
|
|
478
|
+
});
|
|
275
479
|
|
|
276
480
|
await exec({
|
|
277
481
|
scripts: {
|
|
278
|
-
prebump:
|
|
279
|
-
}
|
|
280
|
-
})
|
|
281
|
-
|
|
282
|
-
})
|
|
482
|
+
prebump: 'node -e "console.log(\'major\')"',
|
|
483
|
+
},
|
|
484
|
+
});
|
|
485
|
+
verifyPackageVersion({ writeFileSyncSpy, expectedVersion: '1.1.0' });
|
|
486
|
+
});
|
|
283
487
|
|
|
284
488
|
it('should allow prebump hook to return an arbitrary string', async function () {
|
|
285
489
|
mock({
|
|
286
490
|
bump: 'minor',
|
|
287
|
-
|
|
288
|
-
})
|
|
491
|
+
existingChangelog: 'legacy header format<a name="1.0.0">\n',
|
|
492
|
+
});
|
|
289
493
|
|
|
290
494
|
await exec({
|
|
291
495
|
scripts: {
|
|
292
|
-
prebump:
|
|
293
|
-
}
|
|
294
|
-
})
|
|
295
|
-
|
|
296
|
-
})
|
|
496
|
+
prebump: 'node -e "console.log(\'Hello World\')"',
|
|
497
|
+
},
|
|
498
|
+
});
|
|
499
|
+
verifyPackageVersion({ writeFileSyncSpy, expectedVersion: '1.1.0' });
|
|
500
|
+
});
|
|
297
501
|
|
|
298
502
|
it('should allow prebump hook to return a version with build info', async function () {
|
|
299
503
|
mock({
|
|
300
504
|
bump: 'minor',
|
|
301
|
-
|
|
302
|
-
})
|
|
505
|
+
existingChangelog: 'legacy header format<a name="1.0.0">\n',
|
|
506
|
+
});
|
|
303
507
|
|
|
304
508
|
await exec({
|
|
305
509
|
scripts: {
|
|
306
|
-
prebump:
|
|
307
|
-
}
|
|
308
|
-
})
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
510
|
+
prebump: 'node -e "console.log(\'9.9.9-test+build\')"',
|
|
511
|
+
},
|
|
512
|
+
});
|
|
513
|
+
verifyPackageVersion({
|
|
514
|
+
writeFileSyncSpy,
|
|
515
|
+
expectedVersion: '9.9.9-test+build',
|
|
516
|
+
});
|
|
517
|
+
});
|
|
518
|
+
});
|
|
312
519
|
|
|
313
520
|
describe('postbump hook', function () {
|
|
314
521
|
it('should run the postbump hook when provided', async function () {
|
|
315
|
-
|
|
522
|
+
mock({
|
|
316
523
|
bump: 'minor',
|
|
317
|
-
|
|
318
|
-
})
|
|
524
|
+
existingChangelog: 'legacy header format<a name="1.0.0">\n',
|
|
525
|
+
});
|
|
319
526
|
|
|
320
527
|
await exec({
|
|
321
528
|
scripts: {
|
|
322
|
-
postbump: "node -e \"console.error('postbump' + ' ran')\""
|
|
323
|
-
}
|
|
324
|
-
})
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
529
|
+
postbump: "node -e \"console.error('postbump' + ' ran')\"",
|
|
530
|
+
},
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
const expectedLog = 'postbump ran';
|
|
534
|
+
verifyLogPrinted({ consoleInfoSpy: consoleErrorSpy, expectedLog });
|
|
535
|
+
});
|
|
328
536
|
|
|
329
537
|
it('should run the postbump and exit with error when postbump fails', async function () {
|
|
330
538
|
mock({
|
|
331
539
|
bump: 'minor',
|
|
332
|
-
|
|
333
|
-
})
|
|
334
|
-
|
|
335
|
-
expect(
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
540
|
+
existingChangelog: 'legacy header format<a name="1.0.0">\n',
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
await expect(
|
|
544
|
+
exec({
|
|
545
|
+
scripts: {
|
|
546
|
+
postbump: "node -e \"throw new Error('postbump' + ' fail')\"",
|
|
547
|
+
},
|
|
548
|
+
}),
|
|
549
|
+
).rejects.toThrow(/postbump fail/);
|
|
550
|
+
});
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
describe('manual-release', function () {
|
|
554
|
+
describe('release-types', function () {
|
|
555
|
+
const regularTypes = ['major', 'minor', 'patch'];
|
|
556
|
+
const nextVersion = { major: '2.0.0', minor: '1.1.0', patch: '1.0.1' };
|
|
557
|
+
|
|
558
|
+
regularTypes.forEach(function (type) {
|
|
559
|
+
it('creates a ' + type + ' release', async function () {
|
|
560
|
+
mock({
|
|
561
|
+
bump: 'patch',
|
|
562
|
+
existingChangelog: 'legacy header format<a name="1.0.0">\n',
|
|
563
|
+
});
|
|
564
|
+
await exec('--release-as ' + type);
|
|
565
|
+
verifyPackageVersion({
|
|
566
|
+
writeFileSyncSpy,
|
|
567
|
+
expectedVersion: nextVersion[type],
|
|
568
|
+
});
|
|
569
|
+
});
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
// this is for pre-releases
|
|
573
|
+
regularTypes.forEach(function (type) {
|
|
574
|
+
it('creates a pre' + type + ' release', async function () {
|
|
575
|
+
mock({
|
|
576
|
+
bump: 'patch',
|
|
577
|
+
existingChangelog: 'legacy header format<a name="1.0.0">\n',
|
|
578
|
+
});
|
|
579
|
+
await exec('--release-as ' + type + ' --prerelease ' + type);
|
|
580
|
+
verifyPackageVersion({
|
|
581
|
+
writeFileSyncSpy,
|
|
582
|
+
expectedVersion: `${nextVersion[type]}-${type}.0`,
|
|
583
|
+
});
|
|
584
|
+
});
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
it('exits with error if an invalid release type is provided', async function () {
|
|
588
|
+
mock({ bump: 'minor', existingChangelog: '' });
|
|
589
|
+
|
|
590
|
+
await expect(exec('--release-as invalid')).rejects.toThrow(
|
|
591
|
+
/releaseAs must be one of/,
|
|
592
|
+
);
|
|
593
|
+
});
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
describe('release-as-exact', function () {
|
|
597
|
+
it('releases as v100.0.0', async function () {
|
|
598
|
+
mock({
|
|
599
|
+
bump: 'patch',
|
|
600
|
+
existingChangelog: 'legacy header format<a name="1.0.0">\n',
|
|
601
|
+
});
|
|
602
|
+
await exec('--release-as v100.0.0');
|
|
603
|
+
verifyPackageVersion({
|
|
604
|
+
writeFileSyncSpy,
|
|
605
|
+
expectedVersion: '100.0.0',
|
|
606
|
+
});
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
it('releases as 200.0.0-amazing', async function () {
|
|
610
|
+
mock({
|
|
611
|
+
bump: 'patch',
|
|
612
|
+
existingChangelog: 'legacy header format<a name="1.0.0">\n',
|
|
613
|
+
});
|
|
614
|
+
await exec('--release-as 200.0.0-amazing');
|
|
615
|
+
verifyPackageVersion({
|
|
616
|
+
writeFileSyncSpy,
|
|
617
|
+
expectedVersion: '200.0.0-amazing',
|
|
618
|
+
});
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
it('releases as 100.0.0 with prerelease amazing', async function () {
|
|
622
|
+
mock({
|
|
623
|
+
bump: 'patch',
|
|
624
|
+
existingChangelog: 'legacy header format<a name="1.0.0">\n',
|
|
625
|
+
testFiles: [
|
|
626
|
+
{
|
|
627
|
+
path: 'package.json',
|
|
628
|
+
value: {
|
|
629
|
+
version: '1.0.0',
|
|
630
|
+
},
|
|
631
|
+
},
|
|
632
|
+
],
|
|
633
|
+
});
|
|
634
|
+
await exec('--release-as 100.0.0 --prerelease amazing');
|
|
635
|
+
verifyPackageVersion({
|
|
636
|
+
writeFileSyncSpy,
|
|
637
|
+
expectedVersion: '100.0.0-amazing.0',
|
|
638
|
+
});
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
it('release 100.0.0 with prerelease amazing bumps build', async function () {
|
|
642
|
+
mock({
|
|
643
|
+
bump: 'patch',
|
|
644
|
+
fs: {
|
|
645
|
+
'CHANGELOG.md':
|
|
646
|
+
'legacy header format<a name="100.0.0-amazing.0">\n',
|
|
647
|
+
},
|
|
648
|
+
testFiles: [
|
|
649
|
+
{
|
|
650
|
+
path: 'package.json',
|
|
651
|
+
value: {
|
|
652
|
+
version: '100.0.0-amazing.0',
|
|
653
|
+
},
|
|
654
|
+
},
|
|
655
|
+
],
|
|
656
|
+
});
|
|
657
|
+
await exec('--release-as 100.0.0 --prerelease amazing');
|
|
658
|
+
verifyPackageVersion({
|
|
659
|
+
writeFileSyncSpy,
|
|
660
|
+
expectedVersion: '100.0.0-amazing.1',
|
|
661
|
+
});
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
it('release 100.0.0-amazing.0 with prerelease amazing bumps build', async function () {
|
|
665
|
+
mock({
|
|
666
|
+
bump: 'patch',
|
|
667
|
+
fs: {
|
|
668
|
+
'CHANGELOG.md':
|
|
669
|
+
'legacy header format<a name="100.0.0-amazing.0">\n',
|
|
670
|
+
},
|
|
671
|
+
testFiles: [
|
|
672
|
+
{
|
|
673
|
+
path: 'package.json',
|
|
674
|
+
value: {
|
|
675
|
+
version: '100.0.0-amazing.1',
|
|
676
|
+
},
|
|
677
|
+
},
|
|
678
|
+
],
|
|
679
|
+
});
|
|
680
|
+
await exec('--release-as 100.0.0-amazing.0 --prerelease amazing');
|
|
681
|
+
verifyPackageVersion({
|
|
682
|
+
writeFileSyncSpy,
|
|
683
|
+
expectedVersion: '100.0.0-amazing.2',
|
|
684
|
+
});
|
|
685
|
+
});
|
|
686
|
+
|
|
687
|
+
it('release 100.0.0 with prerelease amazing correctly sets version', async function () {
|
|
688
|
+
mock({
|
|
689
|
+
bump: 'patch',
|
|
690
|
+
fs: {
|
|
691
|
+
'CHANGELOG.md':
|
|
692
|
+
'legacy header format<a name="100.0.0-amazing.0">\n',
|
|
693
|
+
},
|
|
694
|
+
testFiles: [
|
|
695
|
+
{
|
|
696
|
+
path: 'package.json',
|
|
697
|
+
value: {
|
|
698
|
+
version: '99.0.0-amazing.0',
|
|
699
|
+
},
|
|
700
|
+
},
|
|
701
|
+
],
|
|
702
|
+
});
|
|
703
|
+
await exec('--release-as 100.0.0 --prerelease amazing');
|
|
704
|
+
verifyPackageVersion({
|
|
705
|
+
writeFileSyncSpy,
|
|
706
|
+
expectedVersion: '100.0.0-amazing.0',
|
|
707
|
+
});
|
|
708
|
+
});
|
|
709
|
+
|
|
710
|
+
it('release 100.0.0-amazing.0 with prerelease amazing correctly sets version', async function () {
|
|
711
|
+
mock({
|
|
712
|
+
bump: 'patch',
|
|
713
|
+
fs: {
|
|
714
|
+
'CHANGELOG.md':
|
|
715
|
+
'legacy header format<a name="100.0.0-amazing.0">\n',
|
|
716
|
+
},
|
|
717
|
+
testFiles: [
|
|
718
|
+
{
|
|
719
|
+
path: 'package.json',
|
|
720
|
+
value: {
|
|
721
|
+
version: '99.0.0-amazing.0',
|
|
722
|
+
},
|
|
723
|
+
},
|
|
724
|
+
],
|
|
725
|
+
});
|
|
726
|
+
await exec('--release-as 100.0.0-amazing.0 --prerelease amazing');
|
|
727
|
+
verifyPackageVersion({
|
|
728
|
+
writeFileSyncSpy,
|
|
729
|
+
expectedVersion: '100.0.0-amazing.0',
|
|
730
|
+
});
|
|
731
|
+
});
|
|
732
|
+
|
|
733
|
+
it('release 100.0.0-amazing.0 with prerelease amazing retains build metadata', async function () {
|
|
352
734
|
mock({
|
|
353
735
|
bump: 'patch',
|
|
354
|
-
fs: {
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
736
|
+
fs: {
|
|
737
|
+
'CHANGELOG.md':
|
|
738
|
+
'legacy header format<a name="100.0.0-amazing.0">\n',
|
|
739
|
+
},
|
|
740
|
+
testFiles: [
|
|
741
|
+
{
|
|
742
|
+
path: 'package.json',
|
|
743
|
+
value: {
|
|
744
|
+
version: '100.0.0-amazing.0',
|
|
745
|
+
},
|
|
746
|
+
},
|
|
747
|
+
],
|
|
748
|
+
});
|
|
749
|
+
await exec(
|
|
750
|
+
'--release-as 100.0.0-amazing.0+build.1234 --prerelease amazing',
|
|
751
|
+
);
|
|
752
|
+
verifyPackageVersion({
|
|
753
|
+
writeFileSyncSpy,
|
|
754
|
+
expectedVersion: '100.0.0-amazing.1+build.1234',
|
|
755
|
+
});
|
|
756
|
+
});
|
|
757
|
+
|
|
758
|
+
it('release 100.0.0-amazing.3 with prerelease amazing correctly sets prerelease version', async function () {
|
|
364
759
|
mock({
|
|
365
760
|
bump: 'patch',
|
|
366
|
-
fs: {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
761
|
+
fs: {
|
|
762
|
+
'CHANGELOG.md':
|
|
763
|
+
'legacy header format<a name="100.0.0-amazing.0">\n',
|
|
764
|
+
},
|
|
765
|
+
testFiles: [
|
|
766
|
+
{
|
|
767
|
+
path: 'package.json',
|
|
768
|
+
value: {
|
|
769
|
+
version: '100.0.0-amazing.0',
|
|
770
|
+
},
|
|
771
|
+
},
|
|
772
|
+
],
|
|
773
|
+
});
|
|
774
|
+
await exec('--release-as 100.0.0-amazing.3 --prerelease amazing');
|
|
775
|
+
verifyPackageVersion({
|
|
776
|
+
writeFileSyncSpy,
|
|
777
|
+
expectedVersion: '100.0.0-amazing.3',
|
|
778
|
+
});
|
|
779
|
+
});
|
|
780
|
+
});
|
|
781
|
+
|
|
782
|
+
it('creates a prerelease with a new minor version after two prerelease patches', async function () {
|
|
783
|
+
let releaseType = 'patch';
|
|
784
|
+
mock({
|
|
785
|
+
bump: (_, __, cb) => cb(null, { releaseType }),
|
|
786
|
+
existingChangelog: 'legacy header format<a name="1.0.0">\n',
|
|
787
|
+
});
|
|
788
|
+
|
|
789
|
+
let version = '1.0.1-dev.0';
|
|
790
|
+
await exec('--release-as patch --prerelease dev');
|
|
791
|
+
verifyPackageVersion({ writeFileSyncSpy, expectedVersion: version });
|
|
792
|
+
|
|
793
|
+
unmock();
|
|
382
794
|
mock({
|
|
383
|
-
bump:
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
795
|
+
bump: (_, __, cb) => cb(null, { releaseType }),
|
|
796
|
+
existingChangelog: 'legacy header format<a name="1.0.0">\n',
|
|
797
|
+
testFiles: [{ path: 'package.json', value: { version } }],
|
|
798
|
+
});
|
|
799
|
+
|
|
800
|
+
version = '1.0.1-dev.1';
|
|
801
|
+
await exec('--prerelease dev');
|
|
802
|
+
verifyPackageVersion({ writeFileSyncSpy, expectedVersion: version });
|
|
803
|
+
|
|
804
|
+
releaseType = 'minor';
|
|
805
|
+
unmock();
|
|
391
806
|
mock({
|
|
392
|
-
bump:
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
807
|
+
bump: (_, __, cb) => cb(null, { releaseType }),
|
|
808
|
+
existingChangelog: 'legacy header format<a name="1.0.0">\n',
|
|
809
|
+
testFiles: [{ path: 'package.json', value: { version } }],
|
|
810
|
+
});
|
|
811
|
+
|
|
812
|
+
version = '1.1.0-dev.0';
|
|
813
|
+
await exec('--release-as minor --prerelease dev');
|
|
814
|
+
verifyPackageVersion({ writeFileSyncSpy, expectedVersion: version });
|
|
815
|
+
|
|
816
|
+
unmock();
|
|
400
817
|
mock({
|
|
401
|
-
bump:
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
await exec('--release-as
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
it('release 100.0.0 with prerelease amazing bumps build', async function () {
|
|
818
|
+
bump: (_, __, cb) => cb(null, { releaseType }),
|
|
819
|
+
existingChangelog: 'legacy header format<a name="1.0.0">\n',
|
|
820
|
+
testFiles: [{ path: 'package.json', value: { version } }],
|
|
821
|
+
});
|
|
822
|
+
|
|
823
|
+
version = '1.1.0-dev.1';
|
|
824
|
+
await exec('--release-as minor --prerelease dev');
|
|
825
|
+
verifyPackageVersion({ writeFileSyncSpy, expectedVersion: version });
|
|
826
|
+
|
|
827
|
+
unmock();
|
|
412
828
|
mock({
|
|
413
|
-
bump:
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
await exec('--
|
|
420
|
-
|
|
421
|
-
})
|
|
422
|
-
|
|
423
|
-
it('
|
|
829
|
+
bump: (_, __, cb) => cb(null, { releaseType }),
|
|
830
|
+
existingChangelog: 'legacy header format<a name="1.0.0">\n',
|
|
831
|
+
testFiles: [{ path: 'package.json', value: { version } }],
|
|
832
|
+
});
|
|
833
|
+
|
|
834
|
+
version = '1.1.0-dev.2';
|
|
835
|
+
await exec('--prerelease dev');
|
|
836
|
+
verifyPackageVersion({ writeFileSyncSpy, expectedVersion: version });
|
|
837
|
+
});
|
|
838
|
+
|
|
839
|
+
it('exits with error if an invalid release version is provided', async function () {
|
|
840
|
+
mock({ bump: 'minor', existingChangelog: '' });
|
|
841
|
+
|
|
842
|
+
await expect(exec('--release-as 10.2')).rejects.toThrow(
|
|
843
|
+
/releaseAs must be one of/,
|
|
844
|
+
);
|
|
845
|
+
});
|
|
846
|
+
|
|
847
|
+
it('exits with error if release version conflicts with prerelease', async function () {
|
|
848
|
+
mock({ bump: 'minor', existingChangelog: '' });
|
|
849
|
+
|
|
850
|
+
await expect(
|
|
851
|
+
exec('--release-as 1.2.3-amazing.2 --prerelease awesome'),
|
|
852
|
+
).rejects.toThrow(
|
|
853
|
+
/releaseAs and prerelease have conflicting prerelease identifiers/,
|
|
854
|
+
);
|
|
855
|
+
});
|
|
856
|
+
});
|
|
857
|
+
|
|
858
|
+
it('appends line feed at end of package.json', async function () {
|
|
859
|
+
mock({ bump: 'patch' });
|
|
860
|
+
await exec();
|
|
861
|
+
verifyFileContentEquals({
|
|
862
|
+
writeFileSyncSpy,
|
|
863
|
+
content: '{\n "version": "1.0.1"\n}\n',
|
|
864
|
+
});
|
|
865
|
+
});
|
|
866
|
+
|
|
867
|
+
it('preserves indentation of tabs in package.json', async function () {
|
|
868
|
+
mock({
|
|
869
|
+
bump: 'patch',
|
|
870
|
+
testFiles: [
|
|
871
|
+
{ path: 'package.json', value: '{\n\t"version": "1.0.0"\n}\n' },
|
|
872
|
+
],
|
|
873
|
+
});
|
|
874
|
+
await exec();
|
|
875
|
+
// TODO: a) not bumping to 1.0.1, b) need to check how jest might handle tabbing etc
|
|
876
|
+
verifyFileContentEquals({
|
|
877
|
+
writeFileSyncSpy,
|
|
878
|
+
content: '{\n\t"version": "1.0.1"\n}\n',
|
|
879
|
+
});
|
|
880
|
+
});
|
|
881
|
+
|
|
882
|
+
it('preserves indentation of spaces in package.json', async function () {
|
|
883
|
+
mock({
|
|
884
|
+
bump: 'patch',
|
|
885
|
+
testFiles: [
|
|
886
|
+
{ path: 'package.json', value: '{\n "version": "1.0.0"\n}\n' },
|
|
887
|
+
],
|
|
888
|
+
});
|
|
889
|
+
await exec();
|
|
890
|
+
verifyFileContentEquals({
|
|
891
|
+
writeFileSyncSpy,
|
|
892
|
+
content: '{\n "version": "1.0.1"\n}\n',
|
|
893
|
+
});
|
|
894
|
+
});
|
|
895
|
+
|
|
896
|
+
it('preserves carriage return + line feed in package.json', async function () {
|
|
897
|
+
mock({
|
|
898
|
+
bump: 'patch',
|
|
899
|
+
testFiles: [
|
|
900
|
+
{ path: 'package.json', value: '{\r\n "version": "1.0.0"\r\n}\r\n' },
|
|
901
|
+
],
|
|
902
|
+
});
|
|
903
|
+
await exec();
|
|
904
|
+
verifyFileContentEquals({
|
|
905
|
+
writeFileSyncSpy,
|
|
906
|
+
content: '{\r\n "version": "1.0.1"\r\n}\r\n',
|
|
907
|
+
});
|
|
908
|
+
});
|
|
909
|
+
|
|
910
|
+
it('does not print output when the --silent flag is passed', async function () {
|
|
911
|
+
mock();
|
|
912
|
+
await exec('--silent');
|
|
913
|
+
expect(consoleErrorSpy).not.toHaveBeenCalled();
|
|
914
|
+
expect(consoleInfoSpy).not.toHaveBeenCalled();
|
|
915
|
+
});
|
|
916
|
+
});
|
|
917
|
+
|
|
918
|
+
describe('commit-and-tag-version', function () {
|
|
919
|
+
afterEach(unmock);
|
|
920
|
+
|
|
921
|
+
it('should exit on bump error', async function () {
|
|
922
|
+
mock({ bump: new Error('bump err') });
|
|
923
|
+
|
|
924
|
+
await expect(exec()).rejects.toThrow(/bump err/);
|
|
925
|
+
});
|
|
926
|
+
|
|
927
|
+
it('should exit on changelog error', async function () {
|
|
928
|
+
mock({ bump: 'minor', changelog: new Error('changelog err') });
|
|
929
|
+
|
|
930
|
+
await expect(exec()).rejects.toThrow(/changelog err/);
|
|
931
|
+
});
|
|
932
|
+
|
|
933
|
+
it('should exit with error without a package file to bump', async function () {
|
|
934
|
+
mock({ bump: 'patch', testFiles: null });
|
|
935
|
+
|
|
936
|
+
await expect(exec({ gitTagFallback: false })).rejects.toThrow(
|
|
937
|
+
'no package file found',
|
|
938
|
+
);
|
|
939
|
+
});
|
|
940
|
+
|
|
941
|
+
it('bumps version # in bower.json', async function () {
|
|
942
|
+
mock({
|
|
943
|
+
bump: 'minor',
|
|
944
|
+
testFiles: [{ path: 'bower.json', value: { version: '1.0.0' } }],
|
|
945
|
+
tags: ['v1.0.0'],
|
|
946
|
+
});
|
|
947
|
+
await exec();
|
|
948
|
+
|
|
949
|
+
verifyPackageVersion({
|
|
950
|
+
writeFileSyncSpy,
|
|
951
|
+
expectedVersion: '1.1.0',
|
|
952
|
+
filename: 'bower.json',
|
|
953
|
+
});
|
|
954
|
+
verifyPackageVersion({ writeFileSyncSpy, expectedVersion: '1.1.0' });
|
|
955
|
+
});
|
|
956
|
+
|
|
957
|
+
it('bumps version # in manifest.json', async function () {
|
|
958
|
+
mock({
|
|
959
|
+
bump: 'minor',
|
|
960
|
+
testFiles: [{ path: 'manifest.json', value: { version: '1.0.0' } }],
|
|
961
|
+
tags: ['v1.0.0'],
|
|
962
|
+
});
|
|
963
|
+
await exec();
|
|
964
|
+
|
|
965
|
+
verifyPackageVersion({
|
|
966
|
+
writeFileSyncSpy,
|
|
967
|
+
expectedVersion: '1.1.0',
|
|
968
|
+
filename: 'manifest.json',
|
|
969
|
+
});
|
|
970
|
+
verifyPackageVersion({ writeFileSyncSpy, expectedVersion: '1.1.0' });
|
|
971
|
+
});
|
|
972
|
+
|
|
973
|
+
describe('custom `bumpFiles` support', function () {
|
|
974
|
+
afterEach(unmock);
|
|
975
|
+
|
|
976
|
+
it('mix.exs + version.txt', async function () {
|
|
424
977
|
mock({
|
|
425
|
-
bump: '
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
version: '
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
978
|
+
bump: 'minor',
|
|
979
|
+
realTestFiles: [
|
|
980
|
+
{ filename: 'mix.exs', path: './test/mocks/mix.exs' },
|
|
981
|
+
{ filename: 'version.txt', path: './test/mocks/version.txt' },
|
|
982
|
+
],
|
|
983
|
+
tags: ['v1.0.0'],
|
|
984
|
+
});
|
|
985
|
+
|
|
986
|
+
await exec({
|
|
987
|
+
bumpFiles: [
|
|
988
|
+
'version.txt',
|
|
989
|
+
{
|
|
990
|
+
filename: 'mix.exs',
|
|
991
|
+
updater: './test/mocks/updater/customer-updater',
|
|
992
|
+
},
|
|
993
|
+
],
|
|
994
|
+
});
|
|
995
|
+
|
|
996
|
+
verifyPackageVersion({
|
|
997
|
+
writeFileSyncSpy,
|
|
998
|
+
expectedVersion: '1.1.0',
|
|
999
|
+
filename: 'mix.exs',
|
|
1000
|
+
asString: true,
|
|
1001
|
+
});
|
|
1002
|
+
|
|
1003
|
+
verifyPackageVersion({
|
|
1004
|
+
writeFileSyncSpy,
|
|
1005
|
+
expectedVersion: '1.1.0',
|
|
1006
|
+
filename: 'version.txt',
|
|
1007
|
+
asString: true,
|
|
1008
|
+
});
|
|
1009
|
+
});
|
|
1010
|
+
|
|
1011
|
+
it('bumps a custom `plain-text` file', async function () {
|
|
436
1012
|
mock({
|
|
437
|
-
bump: '
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
1013
|
+
bump: 'minor',
|
|
1014
|
+
realTestFiles: [
|
|
1015
|
+
{
|
|
1016
|
+
filename: 'VERSION_TRACKER.txt',
|
|
1017
|
+
path: './test/mocks/VERSION-1.0.0.txt',
|
|
1018
|
+
},
|
|
1019
|
+
],
|
|
1020
|
+
});
|
|
1021
|
+
await exec({
|
|
1022
|
+
bumpFiles: [{ filename: 'VERSION_TRACKER.txt', type: 'plain-text' }],
|
|
1023
|
+
});
|
|
1024
|
+
verifyPackageVersion({
|
|
1025
|
+
writeFileSyncSpy,
|
|
1026
|
+
expectedVersion: '1.1.0',
|
|
1027
|
+
filename: 'VERSION_TRACKER.txt',
|
|
1028
|
+
asString: true,
|
|
1029
|
+
});
|
|
1030
|
+
});
|
|
1031
|
+
|
|
1032
|
+
it('displays the new version from custom bumper with --dry-run', async function () {
|
|
448
1033
|
mock({
|
|
449
|
-
bump: '
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
1034
|
+
bump: 'minor',
|
|
1035
|
+
realTestFiles: [
|
|
1036
|
+
{
|
|
1037
|
+
filename: 'increment-version.txt',
|
|
1038
|
+
path: './test/mocks/increment-version.txt',
|
|
1039
|
+
},
|
|
1040
|
+
],
|
|
1041
|
+
});
|
|
1042
|
+
|
|
1043
|
+
const origInfo = console.info;
|
|
1044
|
+
const capturedOutput = [];
|
|
1045
|
+
console.info = (...args) => {
|
|
1046
|
+
capturedOutput.push(...args);
|
|
1047
|
+
origInfo(...args);
|
|
1048
|
+
};
|
|
1049
|
+
|
|
1050
|
+
try {
|
|
1051
|
+
await exec({
|
|
1052
|
+
bumpFiles: [
|
|
1053
|
+
{
|
|
1054
|
+
filename: 'increment-version.txt',
|
|
1055
|
+
updater: './test/mocks/updater/increment-updater',
|
|
1056
|
+
},
|
|
1057
|
+
],
|
|
1058
|
+
dryRun: true,
|
|
1059
|
+
});
|
|
1060
|
+
|
|
1061
|
+
const logOutput = capturedOutput.join(' ');
|
|
1062
|
+
expect(stripAnsi(logOutput)).toContain(
|
|
1063
|
+
'bumping version in increment-version.txt from 1 to 2',
|
|
1064
|
+
);
|
|
1065
|
+
} finally {
|
|
1066
|
+
console.info = origInfo;
|
|
1067
|
+
}
|
|
1068
|
+
});
|
|
1069
|
+
});
|
|
1070
|
+
|
|
1071
|
+
describe('custom `packageFiles` support', function () {
|
|
1072
|
+
afterEach(unmock);
|
|
1073
|
+
|
|
1074
|
+
it('reads and writes to a custom `plain-text` file', async function () {
|
|
460
1075
|
mock({
|
|
461
|
-
bump: '
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
1076
|
+
bump: 'minor',
|
|
1077
|
+
realTestFiles: [
|
|
1078
|
+
{
|
|
1079
|
+
filename: 'VERSION_TRACKER.txt',
|
|
1080
|
+
path: './test/mocks/VERSION-6.3.1.txt',
|
|
1081
|
+
},
|
|
1082
|
+
],
|
|
1083
|
+
});
|
|
1084
|
+
|
|
1085
|
+
await exec({
|
|
1086
|
+
packageFiles: [
|
|
1087
|
+
{ filename: 'VERSION_TRACKER.txt', type: 'plain-text' },
|
|
1088
|
+
],
|
|
1089
|
+
bumpFiles: [{ filename: 'VERSION_TRACKER.txt', type: 'plain-text' }],
|
|
1090
|
+
});
|
|
1091
|
+
|
|
1092
|
+
verifyPackageVersion({
|
|
1093
|
+
writeFileSyncSpy,
|
|
1094
|
+
expectedVersion: '6.4.0',
|
|
1095
|
+
filename: 'VERSION_TRACKER.txt',
|
|
1096
|
+
asString: true,
|
|
1097
|
+
});
|
|
1098
|
+
});
|
|
1099
|
+
|
|
1100
|
+
it('allows same object to be used in packageFiles and bumpFiles', async function () {
|
|
472
1101
|
mock({
|
|
473
|
-
bump: '
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
})
|
|
508
|
-
|
|
509
|
-
it('exits with error if an invalid release version is provided', async function () {
|
|
510
|
-
mock({ bump: 'minor', fs: { 'CHANGELOG.md': '' } })
|
|
511
|
-
|
|
512
|
-
expect(exec('--release-as 10.2')).to.be.rejectedWith(/releaseAs must be one of/)
|
|
513
|
-
})
|
|
514
|
-
|
|
515
|
-
it('exits with error if release version conflicts with prerelease', async function () {
|
|
516
|
-
mock({ bump: 'minor', fs: { 'CHANGELOG.md': '' } })
|
|
517
|
-
|
|
518
|
-
expect(exec('--release-as 1.2.3-amazing.2 --prerelease awesome')).to.be
|
|
519
|
-
.rejectedWith(/releaseAs and prerelease have conflicting prerelease identifiers/)
|
|
520
|
-
})
|
|
521
|
-
})
|
|
522
|
-
|
|
523
|
-
it('appends line feed at end of package.json', async function () {
|
|
524
|
-
mock({ bump: 'patch' })
|
|
525
|
-
await exec()
|
|
526
|
-
const pkgJson = fs.readFileSync('package.json', 'utf-8')
|
|
527
|
-
pkgJson.should.equal('{\n "version": "1.0.1"\n}\n')
|
|
528
|
-
})
|
|
529
|
-
|
|
530
|
-
it('preserves indentation of tabs in package.json', async function () {
|
|
531
|
-
mock({
|
|
532
|
-
bump: 'patch',
|
|
533
|
-
fs: { 'package.json': '{\n\t"version": "1.0.0"\n}\n' }
|
|
534
|
-
})
|
|
535
|
-
await exec()
|
|
536
|
-
const pkgJson = fs.readFileSync('package.json', 'utf-8')
|
|
537
|
-
pkgJson.should.equal('{\n\t"version": "1.0.1"\n}\n')
|
|
538
|
-
})
|
|
539
|
-
|
|
540
|
-
it('preserves indentation of spaces in package.json', async function () {
|
|
541
|
-
mock({
|
|
542
|
-
bump: 'patch',
|
|
543
|
-
fs: { 'package.json': '{\n "version": "1.0.0"\n}\n' }
|
|
544
|
-
})
|
|
545
|
-
await exec()
|
|
546
|
-
const pkgJson = fs.readFileSync('package.json', 'utf-8')
|
|
547
|
-
pkgJson.should.equal('{\n "version": "1.0.1"\n}\n')
|
|
548
|
-
})
|
|
549
|
-
|
|
550
|
-
it('preserves carriage return + line feed in package.json', async function () {
|
|
551
|
-
mock({
|
|
552
|
-
bump: 'patch',
|
|
553
|
-
fs: { 'package.json': '{\r\n "version": "1.0.0"\r\n}\r\n' }
|
|
554
|
-
})
|
|
555
|
-
await exec()
|
|
556
|
-
const pkgJson = fs.readFileSync('package.json', 'utf-8')
|
|
557
|
-
pkgJson.should.equal('{\r\n "version": "1.0.1"\r\n}\r\n')
|
|
558
|
-
})
|
|
559
|
-
|
|
560
|
-
it('does not print output when the --silent flag is passed', async function () {
|
|
561
|
-
const flush = mock()
|
|
562
|
-
await exec('--silent')
|
|
563
|
-
flush().should.eql({ stdout: [], stderr: [] })
|
|
564
|
-
})
|
|
565
|
-
})
|
|
566
|
-
|
|
567
|
-
describe('commit-and-tag-version', function () {
|
|
568
|
-
afterEach(unmock)
|
|
569
|
-
|
|
570
|
-
it('should exit on bump error', async function () {
|
|
571
|
-
mock({ bump: new Error('bump err') })
|
|
572
|
-
|
|
573
|
-
expect(exec()).to.be.rejectedWith(/bump err/)
|
|
574
|
-
})
|
|
575
|
-
|
|
576
|
-
it('should exit on changelog error', async function () {
|
|
577
|
-
mock({ bump: 'minor', changelog: new Error('changelog err') })
|
|
578
|
-
|
|
579
|
-
expect(exec()).to.be.rejectedWith(/changelog err/)
|
|
580
|
-
})
|
|
581
|
-
|
|
582
|
-
it('should exit with error without a package file to bump', async function () {
|
|
583
|
-
mock({ bump: 'patch', pkg: false })
|
|
584
|
-
|
|
585
|
-
expect(exec({ gitTagFallback: false })).to.be.rejectedWith('no package file found')
|
|
586
|
-
})
|
|
587
|
-
|
|
588
|
-
it('bumps version # in bower.json', async function () {
|
|
589
|
-
mock({
|
|
590
|
-
bump: 'minor',
|
|
591
|
-
fs: { 'bower.json': JSON.stringify({ version: '1.0.0' }) },
|
|
592
|
-
tags: ['v1.0.0']
|
|
593
|
-
})
|
|
594
|
-
await exec()
|
|
595
|
-
JSON.parse(fs.readFileSync('bower.json', 'utf-8')).version.should.equal(
|
|
596
|
-
'1.1.0'
|
|
597
|
-
)
|
|
598
|
-
getPackageVersion().should.equal('1.1.0')
|
|
599
|
-
})
|
|
600
|
-
|
|
601
|
-
it('bumps version # in manifest.json', async function () {
|
|
602
|
-
mock({
|
|
603
|
-
bump: 'minor',
|
|
604
|
-
fs: { 'manifest.json': JSON.stringify({ version: '1.0.0' }) },
|
|
605
|
-
tags: ['v1.0.0']
|
|
606
|
-
})
|
|
607
|
-
await exec()
|
|
608
|
-
JSON.parse(fs.readFileSync('manifest.json', 'utf-8')).version.should.equal(
|
|
609
|
-
'1.1.0'
|
|
610
|
-
)
|
|
611
|
-
getPackageVersion().should.equal('1.1.0')
|
|
612
|
-
})
|
|
613
|
-
|
|
614
|
-
describe('custom `bumpFiles` support', function () {
|
|
615
|
-
it('mix.exs + version.txt', async function () {
|
|
616
|
-
const updater = 'custom-updater.js'
|
|
617
|
-
const updaterModule = require('./mocks/updater/customer-updater')
|
|
1102
|
+
bump: 'minor',
|
|
1103
|
+
realTestFiles: [
|
|
1104
|
+
{
|
|
1105
|
+
filename: 'VERSION_TRACKER.txt',
|
|
1106
|
+
path: './test/mocks/VERSION-6.3.1.txt',
|
|
1107
|
+
},
|
|
1108
|
+
],
|
|
1109
|
+
});
|
|
1110
|
+
const origWarn = console.warn;
|
|
1111
|
+
|
|
1112
|
+
console.warn = () => {
|
|
1113
|
+
throw new Error('console.warn should not be called');
|
|
1114
|
+
};
|
|
1115
|
+
|
|
1116
|
+
const filedesc = {
|
|
1117
|
+
filename: 'VERSION_TRACKER.txt',
|
|
1118
|
+
type: 'plain-text',
|
|
1119
|
+
};
|
|
1120
|
+
|
|
1121
|
+
try {
|
|
1122
|
+
await exec({ packageFiles: [filedesc], bumpFiles: [filedesc] });
|
|
1123
|
+
verifyPackageVersion({
|
|
1124
|
+
writeFileSyncSpy,
|
|
1125
|
+
expectedVersion: '6.4.0',
|
|
1126
|
+
filename: 'VERSION_TRACKER.txt',
|
|
1127
|
+
asString: true,
|
|
1128
|
+
});
|
|
1129
|
+
} finally {
|
|
1130
|
+
console.warn = origWarn;
|
|
1131
|
+
}
|
|
1132
|
+
});
|
|
1133
|
+
});
|
|
1134
|
+
|
|
1135
|
+
it('`packageFiles` are bumped along with `bumpFiles` defaults [commit-and-tag-version#533]', async function () {
|
|
618
1136
|
mock({
|
|
619
1137
|
bump: 'minor',
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
1138
|
+
testFiles: [
|
|
1139
|
+
{
|
|
1140
|
+
path: '.gitignore',
|
|
1141
|
+
value: '',
|
|
1142
|
+
},
|
|
1143
|
+
{
|
|
1144
|
+
path: 'package-lock.json',
|
|
1145
|
+
value: { version: '1.0.0' },
|
|
1146
|
+
},
|
|
1147
|
+
],
|
|
1148
|
+
realTestFiles: [
|
|
1149
|
+
{
|
|
1150
|
+
filename: 'manifest.json',
|
|
1151
|
+
path: './test/mocks/manifest-6.3.1.json',
|
|
1152
|
+
},
|
|
1153
|
+
],
|
|
1154
|
+
tags: ['v1.0.0'],
|
|
1155
|
+
});
|
|
627
1156
|
|
|
628
1157
|
await exec({
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
1158
|
+
packageFiles: [
|
|
1159
|
+
{
|
|
1160
|
+
filename: 'manifest.json',
|
|
1161
|
+
type: 'json',
|
|
1162
|
+
},
|
|
1163
|
+
],
|
|
1164
|
+
});
|
|
1165
|
+
|
|
1166
|
+
verifyPackageVersion({
|
|
1167
|
+
writeFileSyncSpy,
|
|
1168
|
+
expectedVersion: '6.4.0',
|
|
1169
|
+
filename: 'package.json',
|
|
1170
|
+
});
|
|
1171
|
+
verifyPackageVersion({
|
|
1172
|
+
writeFileSyncSpy,
|
|
1173
|
+
expectedVersion: '6.4.0',
|
|
1174
|
+
filename: 'package-lock.json',
|
|
1175
|
+
});
|
|
1176
|
+
verifyPackageVersion({
|
|
1177
|
+
writeFileSyncSpy,
|
|
1178
|
+
expectedVersion: '6.4.0',
|
|
1179
|
+
filename: 'manifest.json',
|
|
1180
|
+
});
|
|
1181
|
+
});
|
|
1182
|
+
|
|
1183
|
+
it('bumps version in Gradle `build.gradle.kts` file', async function () {
|
|
1184
|
+
const expected = fs.readFileSync(
|
|
1185
|
+
'./test/mocks/build-6.4.0.gradle.kts',
|
|
1186
|
+
'utf-8',
|
|
1187
|
+
);
|
|
1188
|
+
|
|
639
1189
|
mock({
|
|
640
1190
|
bump: 'minor',
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
'
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
1191
|
+
realTestFiles: [
|
|
1192
|
+
{
|
|
1193
|
+
filename: 'build.gradle.kts',
|
|
1194
|
+
path: './test/mocks/build-6.3.1.gradle.kts',
|
|
1195
|
+
},
|
|
1196
|
+
],
|
|
1197
|
+
});
|
|
1198
|
+
|
|
647
1199
|
await exec({
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
const
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
)
|
|
662
|
-
}
|
|
663
|
-
})
|
|
664
|
-
mockery.registerMock(resolve(process.cwd(), updater), updaterModule)
|
|
665
|
-
|
|
666
|
-
const origInfo = console.info
|
|
667
|
-
const capturedOutput = []
|
|
668
|
-
console.info = (...args) => {
|
|
669
|
-
capturedOutput.push(...args)
|
|
670
|
-
origInfo(...args)
|
|
1200
|
+
packageFiles: [{ filename: 'build.gradle.kts', type: 'gradle' }],
|
|
1201
|
+
bumpFiles: [{ filename: 'build.gradle.kts', type: 'gradle' }],
|
|
1202
|
+
});
|
|
1203
|
+
|
|
1204
|
+
// filePath is the first arg passed to writeFileSync
|
|
1205
|
+
const filename = 'build.gradle.kts';
|
|
1206
|
+
const packageJsonWriteFileSynchCall = findWriteFileCallForPath({
|
|
1207
|
+
writeFileSyncSpy,
|
|
1208
|
+
filename,
|
|
1209
|
+
});
|
|
1210
|
+
|
|
1211
|
+
if (!packageJsonWriteFileSynchCall) {
|
|
1212
|
+
throw new Error(`writeFileSynch not invoked with path ${filename}`);
|
|
671
1213
|
}
|
|
672
|
-
try {
|
|
673
|
-
await exec({
|
|
674
|
-
bumpFiles: [{ filename: 'increment-version.txt', updater: 'increment-updater.js' }],
|
|
675
|
-
dryRun: true
|
|
676
|
-
})
|
|
677
|
-
const logOutput = capturedOutput.join(' ')
|
|
678
|
-
stripAnsi(logOutput).should.include('bumping version in increment-version.txt from 1 to 2')
|
|
679
|
-
} finally {
|
|
680
|
-
console.info = origInfo
|
|
681
|
-
}
|
|
682
|
-
})
|
|
683
|
-
})
|
|
684
1214
|
|
|
685
|
-
|
|
686
|
-
|
|
1215
|
+
const calledWithContentStr = packageJsonWriteFileSynchCall[1];
|
|
1216
|
+
expect(calledWithContentStr).toEqual(expected);
|
|
1217
|
+
});
|
|
1218
|
+
|
|
1219
|
+
it('bumps version in .NET `Project.csproj` file', async function () {
|
|
1220
|
+
const expected = fs.readFileSync(
|
|
1221
|
+
'./test/mocks/Project-6.4.0.csproj',
|
|
1222
|
+
'utf-8',
|
|
1223
|
+
);
|
|
1224
|
+
const filename = 'Project.csproj';
|
|
687
1225
|
mock({
|
|
688
1226
|
bump: 'minor',
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
1227
|
+
realTestFiles: [
|
|
1228
|
+
{
|
|
1229
|
+
filename,
|
|
1230
|
+
path: './test/mocks/Project-6.3.1.csproj',
|
|
1231
|
+
},
|
|
1232
|
+
],
|
|
1233
|
+
});
|
|
695
1234
|
await exec({
|
|
696
|
-
packageFiles: [{ filename
|
|
697
|
-
bumpFiles: [{ filename
|
|
698
|
-
})
|
|
699
|
-
|
|
700
|
-
|
|
1235
|
+
packageFiles: [{ filename, type: 'csproj' }],
|
|
1236
|
+
bumpFiles: [{ filename, type: 'csproj' }],
|
|
1237
|
+
});
|
|
1238
|
+
|
|
1239
|
+
// filePath is the first arg passed to writeFileSync
|
|
1240
|
+
const packageJsonWriteFileSynchCall = findWriteFileCallForPath({
|
|
1241
|
+
writeFileSyncSpy,
|
|
1242
|
+
filename,
|
|
1243
|
+
});
|
|
1244
|
+
|
|
1245
|
+
if (!packageJsonWriteFileSynchCall) {
|
|
1246
|
+
throw new Error(`writeFileSynch not invoked with path ${filename}`);
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
const calledWithContentStr = packageJsonWriteFileSynchCall[1];
|
|
1250
|
+
expect(calledWithContentStr).toEqual(expected);
|
|
1251
|
+
});
|
|
701
1252
|
|
|
702
|
-
it('
|
|
1253
|
+
it('bumps version # in npm-shrinkwrap.json', async function () {
|
|
703
1254
|
mock({
|
|
704
1255
|
bump: 'minor',
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
'
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
}
|
|
722
|
-
})
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
it('`packageFiles` are bumped along with `bumpFiles` defaults [commit-and-tag-version#533]', async function () {
|
|
726
|
-
mock({
|
|
727
|
-
bump: 'minor',
|
|
728
|
-
fs: {
|
|
729
|
-
'.gitignore': '',
|
|
730
|
-
'package-lock.json': JSON.stringify({ version: '1.0.0' }),
|
|
731
|
-
'manifest.json': fs.readFileSync('./test/mocks/manifest-6.3.1.json')
|
|
732
|
-
},
|
|
733
|
-
tags: ['v1.0.0']
|
|
734
|
-
})
|
|
735
|
-
|
|
736
|
-
await exec({
|
|
737
|
-
silent: true,
|
|
738
|
-
packageFiles: [
|
|
739
|
-
{
|
|
740
|
-
filename: 'manifest.json',
|
|
741
|
-
type: 'json'
|
|
742
|
-
}
|
|
743
|
-
]
|
|
744
|
-
})
|
|
745
|
-
|
|
746
|
-
JSON.parse(fs.readFileSync('manifest.json', 'utf-8')).version.should.equal(
|
|
747
|
-
'6.4.0'
|
|
748
|
-
)
|
|
749
|
-
JSON.parse(fs.readFileSync('package.json', 'utf-8')).version.should.equal(
|
|
750
|
-
'6.4.0'
|
|
751
|
-
)
|
|
752
|
-
JSON.parse(
|
|
753
|
-
fs.readFileSync('package-lock.json', 'utf-8')
|
|
754
|
-
).version.should.equal('6.4.0')
|
|
755
|
-
})
|
|
756
|
-
|
|
757
|
-
it('bumps version in Gradle `build.gradle.kts` file', async function () {
|
|
758
|
-
const expected = fs.readFileSync('./test/mocks/build-6.4.0.gradle.kts', 'utf-8')
|
|
759
|
-
mock({
|
|
760
|
-
bump: 'minor',
|
|
761
|
-
fs: {
|
|
762
|
-
'build.gradle.kts': fs.readFileSync('./test/mocks/build-6.3.1.gradle.kts')
|
|
763
|
-
}
|
|
764
|
-
})
|
|
765
|
-
await exec({
|
|
766
|
-
packageFiles: [{ filename: 'build.gradle.kts', type: 'gradle' }],
|
|
767
|
-
bumpFiles: [{ filename: 'build.gradle.kts', type: 'gradle' }]
|
|
768
|
-
})
|
|
769
|
-
fs.readFileSync('build.gradle.kts', 'utf-8').should.equal(expected)
|
|
770
|
-
})
|
|
771
|
-
|
|
772
|
-
it('bumps version in .NET `Project.csproj` file', async function () {
|
|
773
|
-
const expected = fs.readFileSync('./test/mocks/Project-6.4.0.csproj', 'utf-8')
|
|
774
|
-
const filename = 'Project.csproj'
|
|
775
|
-
mock({
|
|
776
|
-
bump: 'minor',
|
|
777
|
-
fs: {
|
|
778
|
-
[filename]: fs.readFileSync('./test/mocks/Project-6.3.1.csproj')
|
|
779
|
-
}
|
|
780
|
-
})
|
|
781
|
-
await exec({
|
|
782
|
-
packageFiles: [{ filename, type: 'csproj' }],
|
|
783
|
-
bumpFiles: [{ filename, type: 'csproj' }]
|
|
784
|
-
})
|
|
785
|
-
fs.readFileSync(filename, 'utf-8').should.equal(expected)
|
|
786
|
-
})
|
|
787
|
-
|
|
788
|
-
it('bumps version # in npm-shrinkwrap.json', async function () {
|
|
789
|
-
mock({
|
|
790
|
-
bump: 'minor',
|
|
791
|
-
fs: {
|
|
792
|
-
'npm-shrinkwrap.json': JSON.stringify({ version: '1.0.0' })
|
|
793
|
-
},
|
|
794
|
-
tags: ['v1.0.0']
|
|
795
|
-
})
|
|
796
|
-
await exec()
|
|
797
|
-
JSON.parse(
|
|
798
|
-
fs.readFileSync('npm-shrinkwrap.json', 'utf-8')
|
|
799
|
-
).version.should.equal('1.1.0')
|
|
800
|
-
getPackageVersion().should.equal('1.1.0')
|
|
801
|
-
})
|
|
802
|
-
|
|
803
|
-
it('bumps version # in package-lock.json', async function () {
|
|
804
|
-
mock({
|
|
805
|
-
bump: 'minor',
|
|
806
|
-
fs: {
|
|
807
|
-
'.gitignore': '',
|
|
808
|
-
'package-lock.json': JSON.stringify({ version: '1.0.0' })
|
|
809
|
-
},
|
|
810
|
-
tags: ['v1.0.0']
|
|
811
|
-
})
|
|
812
|
-
await exec()
|
|
813
|
-
JSON.parse(
|
|
814
|
-
fs.readFileSync('package-lock.json', 'utf-8')
|
|
815
|
-
).version.should.equal('1.1.0')
|
|
816
|
-
getPackageVersion().should.equal('1.1.0')
|
|
817
|
-
})
|
|
818
|
-
|
|
819
|
-
describe('skip', () => {
|
|
820
|
-
it('allows bump and changelog generation to be skipped', async function () {
|
|
821
|
-
const changelogContent = 'legacy header format<a name="1.0.0">\n'
|
|
1256
|
+
testFiles: [
|
|
1257
|
+
{
|
|
1258
|
+
path: 'npm-shrinkwrap.json',
|
|
1259
|
+
value: { version: '1.0.0' },
|
|
1260
|
+
},
|
|
1261
|
+
],
|
|
1262
|
+
tags: ['v1.0.0'],
|
|
1263
|
+
});
|
|
1264
|
+
|
|
1265
|
+
await exec();
|
|
1266
|
+
|
|
1267
|
+
verifyPackageVersion({
|
|
1268
|
+
writeFileSyncSpy,
|
|
1269
|
+
expectedVersion: '1.1.0',
|
|
1270
|
+
filename: 'npm-shrinkwrap.json',
|
|
1271
|
+
});
|
|
1272
|
+
verifyPackageVersion({ writeFileSyncSpy, expectedVersion: '1.1.0' });
|
|
1273
|
+
});
|
|
1274
|
+
|
|
1275
|
+
it('bumps version # in package-lock.json', async function () {
|
|
822
1276
|
mock({
|
|
823
1277
|
bump: 'minor',
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
it('
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
})
|
|
879
|
-
})
|
|
880
|
-
|
|
881
|
-
describe('pre-major', () => {
|
|
882
|
-
it('bumps the minor rather than major, if version < 1.0.0', async function () {
|
|
1278
|
+
testFiles: [
|
|
1279
|
+
{
|
|
1280
|
+
path: '.gitignore',
|
|
1281
|
+
value: '',
|
|
1282
|
+
},
|
|
1283
|
+
{
|
|
1284
|
+
path: 'package-lock.json',
|
|
1285
|
+
value: { version: '1.0.0' },
|
|
1286
|
+
},
|
|
1287
|
+
],
|
|
1288
|
+
tags: ['v1.0.0'],
|
|
1289
|
+
});
|
|
1290
|
+
await exec();
|
|
1291
|
+
|
|
1292
|
+
verifyPackageVersion({
|
|
1293
|
+
writeFileSyncSpy,
|
|
1294
|
+
expectedVersion: '1.1.0',
|
|
1295
|
+
filename: 'package-lock.json',
|
|
1296
|
+
});
|
|
1297
|
+
verifyPackageVersion({ writeFileSyncSpy, expectedVersion: '1.1.0' });
|
|
1298
|
+
});
|
|
1299
|
+
|
|
1300
|
+
describe('skip', function () {
|
|
1301
|
+
it('allows bump and changelog generation to be skipped', async function () {
|
|
1302
|
+
const changelogContent = 'legacy header format<a name="1.0.0">\n';
|
|
1303
|
+
mock({
|
|
1304
|
+
bump: 'minor',
|
|
1305
|
+
changelog: 'foo\n',
|
|
1306
|
+
existingChangelog: changelogContent,
|
|
1307
|
+
});
|
|
1308
|
+
|
|
1309
|
+
await exec('--skip.bump true --skip.changelog true');
|
|
1310
|
+
|
|
1311
|
+
expect(writeFileSyncSpy).not.toHaveBeenCalledWith('package.json');
|
|
1312
|
+
expect(writeFileSyncSpy).not.toHaveBeenCalledWith('CHANGELOG.md');
|
|
1313
|
+
});
|
|
1314
|
+
});
|
|
1315
|
+
|
|
1316
|
+
it('does not update files present in .gitignore', async function () {
|
|
1317
|
+
const DotGitIgnore = require('dotgitignore');
|
|
1318
|
+
jest.mock('dotgitignore');
|
|
1319
|
+
|
|
1320
|
+
DotGitIgnore.mockImplementation(() => {
|
|
1321
|
+
return {
|
|
1322
|
+
ignore: (filename) => {
|
|
1323
|
+
if (filename === 'package-lock.json' || filename === 'bower.json') {
|
|
1324
|
+
return true;
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
return false;
|
|
1328
|
+
},
|
|
1329
|
+
};
|
|
1330
|
+
});
|
|
1331
|
+
|
|
883
1332
|
mock({
|
|
884
1333
|
bump: 'minor',
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
1334
|
+
testFiles: [
|
|
1335
|
+
{
|
|
1336
|
+
path: 'bower.json',
|
|
1337
|
+
value: { version: '1.0.0' },
|
|
1338
|
+
},
|
|
1339
|
+
{
|
|
1340
|
+
path: 'package-lock.json',
|
|
1341
|
+
value: {
|
|
1342
|
+
name: '@org/package',
|
|
1343
|
+
version: '1.0.0',
|
|
1344
|
+
lockfileVersion: 1,
|
|
1345
|
+
},
|
|
1346
|
+
},
|
|
1347
|
+
],
|
|
1348
|
+
tags: ['v1.0.0'],
|
|
1349
|
+
});
|
|
1350
|
+
await exec();
|
|
1351
|
+
|
|
1352
|
+
// does not bump these as in .gitignore
|
|
1353
|
+
expect(writeFileSyncSpy).not.toHaveBeenCalledWith('package-lock.json');
|
|
1354
|
+
expect(writeFileSyncSpy).not.toHaveBeenCalledWith('bower.json');
|
|
1355
|
+
|
|
1356
|
+
// should still bump version in package.json
|
|
1357
|
+
verifyPackageVersion({ writeFileSyncSpy, expectedVersion: '1.1.0' });
|
|
1358
|
+
|
|
1359
|
+
DotGitIgnore.mockRestore();
|
|
1360
|
+
});
|
|
1361
|
+
|
|
1362
|
+
describe('configuration', function () {
|
|
1363
|
+
it('--header', async function () {
|
|
1364
|
+
mock({ bump: 'minor', existingChangelog: '' });
|
|
1365
|
+
await exec('--header="# Welcome to our CHANGELOG.md"');
|
|
1366
|
+
|
|
1367
|
+
verifyNewChangelogContentMatches({
|
|
1368
|
+
writeFileSyncSpy,
|
|
1369
|
+
expectedContent: /# Welcome to our CHANGELOG.md/,
|
|
1370
|
+
});
|
|
1371
|
+
});
|
|
1372
|
+
|
|
1373
|
+
it('--issuePrefixes and --issueUrlFormat', async function () {
|
|
1374
|
+
const format = 'http://www.foo.com/{{prefix}}{{id}}';
|
|
1375
|
+
const prefix = 'ABC-';
|
|
1376
|
+
const changelog = ({ preset }) =>
|
|
1377
|
+
preset.issueUrlFormat + ':' + preset.issuePrefixes;
|
|
1378
|
+
mock({ bump: 'minor', changelog });
|
|
1379
|
+
await exec(`--issuePrefixes="${prefix}" --issueUrlFormat="${format}"`);
|
|
1380
|
+
|
|
1381
|
+
verifyNewChangelogContentMatches({
|
|
1382
|
+
writeFileSyncSpy,
|
|
1383
|
+
expectedContent: `${format}:${prefix}`,
|
|
1384
|
+
});
|
|
1385
|
+
});
|
|
1386
|
+
});
|
|
1387
|
+
|
|
1388
|
+
describe('pre-major', function () {
|
|
1389
|
+
it('bumps the minor rather than major, if version < 1.0.0', async function () {
|
|
1390
|
+
mock({
|
|
1391
|
+
bump: 'minor',
|
|
1392
|
+
testFiles: [
|
|
1393
|
+
{
|
|
1394
|
+
path: 'package.json',
|
|
1395
|
+
value: {
|
|
1396
|
+
version: '0.5.0',
|
|
1397
|
+
repository: { url: 'https://github.com/yargs/yargs.git' },
|
|
1398
|
+
},
|
|
1399
|
+
},
|
|
1400
|
+
],
|
|
1401
|
+
});
|
|
1402
|
+
await exec();
|
|
1403
|
+
verifyPackageVersion({ writeFileSyncSpy, expectedVersion: '0.6.0' });
|
|
1404
|
+
});
|
|
1405
|
+
|
|
1406
|
+
it('bumps major if --release-as=major specified, if version < 1.0.0', async function () {
|
|
1407
|
+
mock({
|
|
1408
|
+
bump: 'major',
|
|
1409
|
+
testFiles: [
|
|
1410
|
+
{
|
|
1411
|
+
path: 'package.json',
|
|
1412
|
+
value: {
|
|
1413
|
+
version: '0.5.0',
|
|
1414
|
+
repository: { url: 'https://github.com/yargs/yargs.git' },
|
|
1415
|
+
},
|
|
1416
|
+
},
|
|
1417
|
+
],
|
|
1418
|
+
});
|
|
1419
|
+
await exec('-r major');
|
|
1420
|
+
verifyPackageVersion({ writeFileSyncSpy, expectedVersion: '1.0.0' });
|
|
1421
|
+
});
|
|
1422
|
+
});
|
|
1423
|
+
});
|
|
1424
|
+
|
|
1425
|
+
describe('GHSL-2020-111', function () {
|
|
1426
|
+
afterEach(unmock);
|
|
1427
|
+
|
|
1428
|
+
it('does not allow command injection via basic configuration', async function () {
|
|
1429
|
+
mock({ bump: 'patch' });
|
|
1430
|
+
await exec({
|
|
1431
|
+
noVerify: true,
|
|
1432
|
+
releaseCommitMessageFormat: 'bla `touch exploit`',
|
|
1433
|
+
});
|
|
1434
|
+
const stat = shell.test('-f', './exploit');
|
|
1435
|
+
expect(stat).toEqual(false);
|
|
1436
|
+
});
|
|
1437
|
+
});
|
|
1438
|
+
|
|
1439
|
+
describe('with mocked git', function () {
|
|
1440
|
+
afterEach(unmock);
|
|
1441
|
+
|
|
1442
|
+
it('--sign signs the commit and tag', async function () {
|
|
1443
|
+
const gitArgs = [
|
|
1444
|
+
['add', 'CHANGELOG.md', 'package.json', 'package-lock.json'],
|
|
1445
|
+
[
|
|
1446
|
+
'commit',
|
|
1447
|
+
'-S',
|
|
1448
|
+
'CHANGELOG.md',
|
|
1449
|
+
'package.json',
|
|
1450
|
+
'package-lock.json',
|
|
1451
|
+
'-m',
|
|
1452
|
+
'chore(release): 1.0.1',
|
|
1453
|
+
],
|
|
1454
|
+
['tag', '-s', 'v1.0.1', '-m', 'chore(release): 1.0.1'],
|
|
1455
|
+
['rev-parse', '--abbrev-ref', 'HEAD'],
|
|
1456
|
+
];
|
|
1457
|
+
|
|
1458
|
+
runExecFile.mockImplementation((_args, cmd, cmdArgs) => {
|
|
1459
|
+
expect(cmd).toEqual('git');
|
|
1460
|
+
|
|
1461
|
+
const expected = gitArgs.shift();
|
|
1462
|
+
expect(cmdArgs).toEqual(expected);
|
|
1463
|
+
|
|
1464
|
+
if (expected[0] === 'rev-parse') return Promise.resolve('master');
|
|
1465
|
+
|
|
1466
|
+
return Promise.resolve('');
|
|
1467
|
+
});
|
|
1468
|
+
|
|
1469
|
+
mock({
|
|
1470
|
+
bump: 'patch',
|
|
1471
|
+
changelog: 'foo\n',
|
|
1472
|
+
});
|
|
1473
|
+
|
|
1474
|
+
await exec('--sign', true);
|
|
1475
|
+
expect(gitArgs).toHaveLength(0);
|
|
1476
|
+
});
|
|
1477
|
+
|
|
1478
|
+
it('--signedoff adds signed-off-by to the commit message', async function () {
|
|
1479
|
+
const gitArgs = [
|
|
1480
|
+
['add', 'CHANGELOG.md', 'package.json', 'package-lock.json'],
|
|
1481
|
+
[
|
|
1482
|
+
'commit',
|
|
1483
|
+
'--signoff',
|
|
1484
|
+
'CHANGELOG.md',
|
|
1485
|
+
'package.json',
|
|
1486
|
+
'package-lock.json',
|
|
1487
|
+
'-m',
|
|
1488
|
+
'chore(release): 1.0.1',
|
|
1489
|
+
],
|
|
1490
|
+
['tag', '-a', 'v1.0.1', '-m', 'chore(release): 1.0.1'],
|
|
1491
|
+
['rev-parse', '--abbrev-ref', 'HEAD'],
|
|
1492
|
+
];
|
|
1493
|
+
|
|
1494
|
+
runExecFile.mockImplementation((_args, cmd, cmdArgs) => {
|
|
1495
|
+
expect(cmd).toEqual('git');
|
|
1496
|
+
|
|
1497
|
+
const expected = gitArgs.shift();
|
|
1498
|
+
expect(cmdArgs).toEqual(expected);
|
|
1499
|
+
|
|
1500
|
+
if (expected[0] === 'rev-parse') return Promise.resolve('master');
|
|
1501
|
+
|
|
1502
|
+
return Promise.resolve('');
|
|
1503
|
+
});
|
|
893
1504
|
|
|
894
|
-
it('bumps major if --release-as=major specified, if version < 1.0.0', async function () {
|
|
895
1505
|
mock({
|
|
896
|
-
bump: '
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
1506
|
+
bump: 'patch',
|
|
1507
|
+
changelog: 'foo\n',
|
|
1508
|
+
});
|
|
1509
|
+
|
|
1510
|
+
await exec('--signoff', true);
|
|
1511
|
+
expect(gitArgs).toHaveLength(0);
|
|
1512
|
+
});
|
|
1513
|
+
|
|
1514
|
+
it('--tag-force forces tag replacement', async function () {
|
|
1515
|
+
const gitArgs = [
|
|
1516
|
+
['add', 'CHANGELOG.md', 'package.json', 'package-lock.json'],
|
|
1517
|
+
[
|
|
1518
|
+
'commit',
|
|
1519
|
+
'CHANGELOG.md',
|
|
1520
|
+
'package.json',
|
|
1521
|
+
'package-lock.json',
|
|
1522
|
+
'-m',
|
|
1523
|
+
'chore(release): 1.0.1',
|
|
1524
|
+
],
|
|
1525
|
+
['tag', '-a', '-f', 'v1.0.1', '-m', 'chore(release): 1.0.1'],
|
|
1526
|
+
['rev-parse', '--abbrev-ref', 'HEAD'],
|
|
1527
|
+
];
|
|
1528
|
+
|
|
1529
|
+
runExecFile.mockImplementation((_args, cmd, cmdArgs) => {
|
|
1530
|
+
expect(cmd).toEqual('git');
|
|
1531
|
+
|
|
1532
|
+
const expected = gitArgs.shift();
|
|
1533
|
+
expect(cmdArgs).toEqual(expected);
|
|
1534
|
+
|
|
1535
|
+
if (expected[0] === 'rev-parse') return Promise.resolve('master');
|
|
1536
|
+
|
|
1537
|
+
return Promise.resolve('');
|
|
1538
|
+
});
|
|
1539
|
+
|
|
1540
|
+
mock({ bump: 'patch', changelog: 'foo\n' });
|
|
1541
|
+
|
|
1542
|
+
await exec('--tag-force', true);
|
|
1543
|
+
expect(gitArgs).toHaveLength(0);
|
|
1544
|
+
});
|
|
1545
|
+
|
|
1546
|
+
it('fails if git add fails', async function () {
|
|
1547
|
+
const gitArgs = [
|
|
1548
|
+
['add', 'CHANGELOG.md', 'package.json', 'package-lock.json'],
|
|
1549
|
+
];
|
|
1550
|
+
const gitError = new Error('Command failed: git\nfailed add');
|
|
1551
|
+
|
|
1552
|
+
runExecFile.mockImplementation((_args, cmd, cmdArgs) => {
|
|
1553
|
+
expect(cmd).toEqual('git');
|
|
1554
|
+
|
|
1555
|
+
const expected = gitArgs.shift();
|
|
1556
|
+
expect(cmdArgs).toEqual(expected);
|
|
1557
|
+
|
|
1558
|
+
if (expected[0] === 'add') {
|
|
1559
|
+
return Promise.reject(gitError);
|
|
900
1560
|
}
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
})
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
1561
|
+
return Promise.resolve('');
|
|
1562
|
+
});
|
|
1563
|
+
|
|
1564
|
+
mock({ bump: 'patch', changelog: 'foo\n' });
|
|
1565
|
+
|
|
1566
|
+
await expect(exec({}, true)).rejects.toThrow(gitError);
|
|
1567
|
+
});
|
|
1568
|
+
|
|
1569
|
+
it('fails if git commit fails', async function () {
|
|
1570
|
+
const gitArgs = [
|
|
1571
|
+
['add', 'CHANGELOG.md', 'package.json', 'package-lock.json'],
|
|
1572
|
+
[
|
|
1573
|
+
'commit',
|
|
1574
|
+
'CHANGELOG.md',
|
|
1575
|
+
'package.json',
|
|
1576
|
+
'package-lock.json',
|
|
1577
|
+
'-m',
|
|
1578
|
+
'chore(release): 1.0.1',
|
|
1579
|
+
],
|
|
1580
|
+
];
|
|
1581
|
+
const gitError = new Error('Command failed: git\nfailed commit');
|
|
1582
|
+
|
|
1583
|
+
runExecFile.mockImplementation((_args, cmd, cmdArgs) => {
|
|
1584
|
+
expect(cmd).toEqual('git');
|
|
1585
|
+
|
|
1586
|
+
const expected = gitArgs.shift();
|
|
1587
|
+
expect(cmdArgs).toEqual(expected);
|
|
1588
|
+
|
|
1589
|
+
if (expected[0] === 'commit') {
|
|
1590
|
+
return Promise.reject(gitError);
|
|
1591
|
+
}
|
|
1592
|
+
return Promise.resolve('');
|
|
1593
|
+
});
|
|
1594
|
+
|
|
1595
|
+
mock({ bump: 'patch', changelog: 'foo\n' });
|
|
1596
|
+
|
|
1597
|
+
await expect(exec({}, true)).rejects.toThrow(gitError);
|
|
1598
|
+
});
|
|
1599
|
+
|
|
1600
|
+
it('fails if git tag fails', async function () {
|
|
1601
|
+
const gitArgs = [
|
|
1602
|
+
['add', 'CHANGELOG.md', 'package.json', 'package-lock.json'],
|
|
1603
|
+
[
|
|
1604
|
+
'commit',
|
|
1605
|
+
'CHANGELOG.md',
|
|
1606
|
+
'package.json',
|
|
1607
|
+
'package-lock.json',
|
|
1608
|
+
'-m',
|
|
1609
|
+
'chore(release): 1.0.1',
|
|
1610
|
+
],
|
|
1611
|
+
['tag', '-a', 'v1.0.1', '-m', 'chore(release): 1.0.1'],
|
|
1612
|
+
];
|
|
1613
|
+
const gitError = new Error('Command failed: git\nfailed tag');
|
|
1614
|
+
|
|
1615
|
+
runExecFile.mockImplementation((_args, cmd, cmdArgs) => {
|
|
1616
|
+
expect(cmd).toEqual('git');
|
|
1617
|
+
|
|
1618
|
+
const expected = gitArgs.shift();
|
|
1619
|
+
expect(cmdArgs).toEqual(expected);
|
|
1620
|
+
|
|
1621
|
+
if (expected[0] === 'tag') {
|
|
1622
|
+
return Promise.reject(gitError);
|
|
1623
|
+
}
|
|
1624
|
+
return Promise.resolve('');
|
|
1625
|
+
});
|
|
1626
|
+
|
|
1627
|
+
mock({ bump: 'patch', changelog: 'foo\n' });
|
|
1628
|
+
|
|
1629
|
+
await expect(exec({}, true)).rejects.toThrow(gitError);
|
|
1630
|
+
});
|
|
1631
|
+
});
|
|
1632
|
+
|
|
1633
|
+
// ------- Verifiers ------
|
|
1634
|
+
function findWriteFileCallForPath({ writeFileSyncSpy, filename }) {
|
|
1635
|
+
// filePath is the first arg passed to writeFileSync
|
|
1636
|
+
return writeFileSyncSpy.mock.calls.find((args) =>
|
|
1637
|
+
args[0].includes(filename),
|
|
1638
|
+
);
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
function verifyPackageVersion({
|
|
1642
|
+
writeFileSyncSpy,
|
|
1643
|
+
expectedVersion,
|
|
1644
|
+
filename = 'package.json',
|
|
1645
|
+
asString = false,
|
|
1646
|
+
}) {
|
|
1647
|
+
// filePath is the first arg passed to writeFileSync
|
|
1648
|
+
const packageJsonWriteFileSynchCall = findWriteFileCallForPath({
|
|
1649
|
+
writeFileSyncSpy,
|
|
1650
|
+
filename,
|
|
1651
|
+
});
|
|
1652
|
+
|
|
1653
|
+
if (!packageJsonWriteFileSynchCall) {
|
|
1654
|
+
throw new Error(`writeFileSynch not invoked with path ${filename}`);
|
|
966
1655
|
}
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
if (expected[0] === 'add') {
|
|
982
|
-
return Promise.reject(gitError)
|
|
1656
|
+
|
|
1657
|
+
const calledWithContentStr = packageJsonWriteFileSynchCall[1];
|
|
1658
|
+
if (!asString) {
|
|
1659
|
+
// parse to JSON and verify has property
|
|
1660
|
+
const calledWithContent = JSON.parse(calledWithContentStr);
|
|
1661
|
+
|
|
1662
|
+
expect(calledWithContent).toHaveProperty('version');
|
|
1663
|
+
expect(calledWithContent.version).toEqual(expectedVersion);
|
|
1664
|
+
} else {
|
|
1665
|
+
// for non-JSON files i.e. .exs and .txt just verify version exists
|
|
1666
|
+
if (filename.includes('.exs')) {
|
|
1667
|
+
expect(calledWithContentStr).toMatch(`version: "${expectedVersion}"`);
|
|
1668
|
+
} else {
|
|
1669
|
+
expect(calledWithContentStr).toMatch(expectedVersion);
|
|
983
1670
|
}
|
|
984
|
-
return Promise.resolve('')
|
|
985
1671
|
}
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
if (expected[0] === 'commit') {
|
|
1002
|
-
return Promise.reject(gitError)
|
|
1003
|
-
}
|
|
1004
|
-
return Promise.resolve('')
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
function verifyFileContentEquals({
|
|
1675
|
+
writeFileSyncSpy,
|
|
1676
|
+
content,
|
|
1677
|
+
filename = 'package.json',
|
|
1678
|
+
}) {
|
|
1679
|
+
// filePath is the first arg passed to writeFileSync
|
|
1680
|
+
const packageJsonWriteFileSynchCall = findWriteFileCallForPath({
|
|
1681
|
+
writeFileSyncSpy,
|
|
1682
|
+
filename,
|
|
1683
|
+
});
|
|
1684
|
+
|
|
1685
|
+
if (!packageJsonWriteFileSynchCall) {
|
|
1686
|
+
throw new Error('writeFileSynch not invoked with path package.json');
|
|
1005
1687
|
}
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1688
|
+
|
|
1689
|
+
const calledWithContentStr = packageJsonWriteFileSynchCall[1];
|
|
1690
|
+
|
|
1691
|
+
expect(calledWithContentStr).toEqual(content);
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
function verifyNewChangelogContentMatches({
|
|
1695
|
+
writeFileSyncSpy,
|
|
1696
|
+
expectedContent,
|
|
1697
|
+
}) {
|
|
1698
|
+
const changelogWriteFileSynchCall = findWriteFileCallForPath({
|
|
1699
|
+
writeFileSyncSpy,
|
|
1700
|
+
filename: 'CHANGELOG.md',
|
|
1701
|
+
});
|
|
1702
|
+
|
|
1703
|
+
if (!changelogWriteFileSynchCall) {
|
|
1704
|
+
throw new Error('writeFileSynch not invoked with path CHANGELOG.md');
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
const calledWithContent = changelogWriteFileSynchCall[1];
|
|
1708
|
+
expect(calledWithContent).toMatch(expectedContent);
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
function verifyNewChangelogContentEquals({
|
|
1712
|
+
writeFileSyncSpy,
|
|
1713
|
+
expectedContent,
|
|
1714
|
+
}) {
|
|
1715
|
+
const changelogWriteFileSynchCall = findWriteFileCallForPath({
|
|
1716
|
+
writeFileSyncSpy,
|
|
1717
|
+
filename: 'CHANGELOG.md',
|
|
1718
|
+
});
|
|
1719
|
+
|
|
1720
|
+
if (!changelogWriteFileSynchCall) {
|
|
1721
|
+
throw new Error('writeFileSynch not invoked with path CHANGELOG.md');
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
const calledWithContent = changelogWriteFileSynchCall[1];
|
|
1725
|
+
expect(calledWithContent).toEqual(expectedContent);
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
function verifyNewChangelogContentDoesNotMatch({
|
|
1729
|
+
writeFileSyncSpy,
|
|
1730
|
+
expectedContent,
|
|
1731
|
+
}) {
|
|
1732
|
+
const changelogWriteFileSynchCall = findWriteFileCallForPath({
|
|
1733
|
+
writeFileSyncSpy,
|
|
1734
|
+
filename: 'CHANGELOG.md',
|
|
1735
|
+
});
|
|
1736
|
+
|
|
1737
|
+
if (!changelogWriteFileSynchCall) {
|
|
1738
|
+
throw new Error('writeFileSynch not invoked with path CHANGELOG.md');
|
|
1026
1739
|
}
|
|
1027
|
-
mock({ bump: 'patch', changelog: 'foo\n', execFile })
|
|
1028
1740
|
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
}
|
|
1741
|
+
const calledWithContent = changelogWriteFileSynchCall[1];
|
|
1742
|
+
expect(calledWithContent).not.toMatch(expectedContent);
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
function verifyLogPrinted({ consoleInfoSpy, expectedLog }) {
|
|
1746
|
+
const consoleInfoLogs = consoleInfoSpy.mock.calls.map((args) => args[0]);
|
|
1747
|
+
const desiredLog = consoleInfoLogs.find((log) => log.includes(expectedLog));
|
|
1748
|
+
expect(desiredLog).not.toBeUndefined();
|
|
1749
|
+
expect(desiredLog).toMatch(expectedLog);
|
|
1750
|
+
}
|
|
1751
|
+
});
|