release-it 18.1.1 → 19.0.0-next.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/lib/plugin/git/Git.js +1 -2
- package/lib/plugin/github/GitHub.js +3 -3
- package/lib/plugin/gitlab/GitLab.js +3 -3
- package/lib/plugin/npm/npm.js +1 -3
- package/lib/shell.js +5 -6
- package/lib/util.js +41 -3
- package/package.json +19 -20
- package/test/git.init.js +56 -53
- package/test/git.js +106 -80
- package/test/npm.js +1 -0
- package/test/plugins.js +44 -39
- package/test/shell.js +2 -3
- package/test/tasks.interactive.js +10 -8
- package/test/tasks.js +39 -31
- package/test/util/helpers.js +10 -8
- package/test/util/index.js +1 -0
- package/test/util/setup.js +0 -2
- package/test/util/sh.js +18 -0
package/lib/plugin/git/Git.js
CHANGED
|
@@ -2,14 +2,13 @@ import { EOL } from 'node:os';
|
|
|
2
2
|
import _ from 'lodash';
|
|
3
3
|
import { execa } from 'execa';
|
|
4
4
|
import matcher from 'wildcard-match';
|
|
5
|
-
import { format, e } from '../../util.js';
|
|
5
|
+
import { format, e, fixArgs } from '../../util.js';
|
|
6
6
|
import GitBase from '../GitBase.js';
|
|
7
7
|
import prompts from './prompts.js';
|
|
8
8
|
|
|
9
9
|
const noop = Promise.resolve();
|
|
10
10
|
const invalidPushRepoRe = /^\S+@/;
|
|
11
11
|
const options = { write: false };
|
|
12
|
-
const fixArgs = args => (args ? (typeof args === 'string' ? args.split(' ') : args) : []);
|
|
13
12
|
|
|
14
13
|
const docs = 'https://git.io/release-it-git';
|
|
15
14
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createReadStream, statSync } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import open from 'open';
|
|
4
4
|
import { Octokit } from '@octokit/rest';
|
|
@@ -301,13 +301,13 @@ class GitHub extends Release {
|
|
|
301
301
|
const url = this.getContext('upload_url');
|
|
302
302
|
const name = path.basename(filePath);
|
|
303
303
|
const contentType = mime.contentType(name) || 'application/octet-stream';
|
|
304
|
-
const contentLength =
|
|
304
|
+
const contentLength = statSync(filePath).size;
|
|
305
305
|
|
|
306
306
|
return this.retry(async bail => {
|
|
307
307
|
try {
|
|
308
308
|
const options = {
|
|
309
309
|
url,
|
|
310
|
-
data:
|
|
310
|
+
data: createReadStream(filePath),
|
|
311
311
|
name,
|
|
312
312
|
headers: {
|
|
313
313
|
'content-type': contentType,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
1
|
import path from 'node:path';
|
|
2
|
+
import fs, { promises } from 'node:fs'; // import fs here so it can be stubbed in tests
|
|
3
3
|
import { globby } from 'globby';
|
|
4
4
|
import _ from 'lodash';
|
|
5
5
|
import { Agent } from 'undici';
|
|
@@ -268,7 +268,7 @@ class GitLab extends Release {
|
|
|
268
268
|
if (useGenericPackageRepositoryForAssets) {
|
|
269
269
|
const options = {
|
|
270
270
|
method: 'PUT',
|
|
271
|
-
body: await
|
|
271
|
+
body: await promises.readFile(filePath)
|
|
272
272
|
};
|
|
273
273
|
try {
|
|
274
274
|
const body = await this.request(endpoint, options);
|
|
@@ -286,7 +286,7 @@ class GitLab extends Release {
|
|
|
286
286
|
}
|
|
287
287
|
} else {
|
|
288
288
|
const body = new FormData();
|
|
289
|
-
const rawData = await
|
|
289
|
+
const rawData = await promises.readFile(filePath);
|
|
290
290
|
body.set('file', new Blob([rawData]), name);
|
|
291
291
|
const options = { body };
|
|
292
292
|
|
package/lib/plugin/npm/npm.js
CHANGED
|
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
|
2
2
|
import semver from 'semver';
|
|
3
3
|
import urlJoin from 'url-join';
|
|
4
4
|
import Plugin from '../Plugin.js';
|
|
5
|
-
import { hasAccess, rejectAfter, parseVersion, readJSON, e } from '../../util.js';
|
|
5
|
+
import { hasAccess, rejectAfter, parseVersion, readJSON, e, fixArgs } from '../../util.js';
|
|
6
6
|
import prompts from './prompts.js';
|
|
7
7
|
|
|
8
8
|
const docs = 'https://git.io/release-it-npm';
|
|
@@ -15,8 +15,6 @@ const DEFAULT_TAG_PRERELEASE = 'next';
|
|
|
15
15
|
const NPM_BASE_URL = 'https://www.npmjs.com';
|
|
16
16
|
const NPM_PUBLIC_PATH = '/package';
|
|
17
17
|
|
|
18
|
-
const fixArgs = args => (args ? (typeof args === 'string' ? args.split(' ') : args) : []);
|
|
19
|
-
|
|
20
18
|
class npm extends Plugin {
|
|
21
19
|
static isEnabled(options) {
|
|
22
20
|
return hasAccess(MANIFEST_PATH) && options !== false;
|
package/lib/shell.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import util from 'node:util';
|
|
2
|
-
import
|
|
2
|
+
import childProcess from 'node:child_process';
|
|
3
3
|
import { execa } from 'execa';
|
|
4
4
|
import { format } from './util.js';
|
|
5
5
|
|
|
6
6
|
const debug = util.debug('release-it:shell');
|
|
7
7
|
|
|
8
|
-
sh.config.silent = !debug.enabled;
|
|
9
|
-
|
|
10
8
|
const noop = Promise.resolve();
|
|
11
9
|
|
|
12
10
|
class Shell {
|
|
@@ -55,8 +53,9 @@ class Shell {
|
|
|
55
53
|
|
|
56
54
|
execStringCommand(command, options, { isExternal }) {
|
|
57
55
|
return new Promise((resolve, reject) => {
|
|
58
|
-
const
|
|
56
|
+
const proc = childProcess.exec(command, (err, stdout, stderr) => {
|
|
59
57
|
stdout = stdout.toString().trimEnd();
|
|
58
|
+
const code = !err ? 0 : err === 'undefined' ? 1 : err.code;
|
|
60
59
|
debug({ command, options, code, stdout, stderr });
|
|
61
60
|
if (code === 0) {
|
|
62
61
|
resolve(stdout);
|
|
@@ -64,8 +63,8 @@ class Shell {
|
|
|
64
63
|
reject(new Error(stderr || stdout));
|
|
65
64
|
}
|
|
66
65
|
});
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
proc.stdout.on('data', stdout => this.log.verbose(stdout.toString().trimEnd(), { isExternal }));
|
|
67
|
+
proc.stderr.on('data', stderr => this.log.verbose(stderr.toString().trimEnd(), { isExternal }));
|
|
69
68
|
});
|
|
70
69
|
}
|
|
71
70
|
|
package/lib/util.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
1
|
+
import fs, { close, openSync, statSync, utimesSync, accessSync } from 'node:fs'; // need import fs here due to test stubbing
|
|
2
|
+
import util from 'node:util';
|
|
2
3
|
import { EOL } from 'node:os';
|
|
3
4
|
import _ from 'lodash';
|
|
4
5
|
import gitUrlParse from 'git-url-parse';
|
|
@@ -6,6 +7,12 @@ import semver from 'semver';
|
|
|
6
7
|
import osName from 'os-name';
|
|
7
8
|
import Log from './log.js';
|
|
8
9
|
|
|
10
|
+
export const execOpts = {
|
|
11
|
+
stdio: process.env.NODE_DEBUG && process.env.NODE_DEBUG.indexOf('release-it') === 0 ? 'pipe' : []
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const debug = util.debug('release-it:shell');
|
|
15
|
+
|
|
9
16
|
const readJSON = file => JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
10
17
|
|
|
11
18
|
const pkg = readJSON(new URL('../package.json', import.meta.url));
|
|
@@ -68,7 +75,7 @@ const reduceUntil = async (collection, fn) => {
|
|
|
68
75
|
|
|
69
76
|
const hasAccess = path => {
|
|
70
77
|
try {
|
|
71
|
-
|
|
78
|
+
accessSync(path);
|
|
72
79
|
return true;
|
|
73
80
|
} catch (err) {
|
|
74
81
|
return false;
|
|
@@ -96,6 +103,35 @@ const e = (message, docs, fail = true) => {
|
|
|
96
103
|
return error;
|
|
97
104
|
};
|
|
98
105
|
|
|
106
|
+
const touch = (path, callback) => {
|
|
107
|
+
const stat = tryStatFile(path);
|
|
108
|
+
if (stat && stat.isDirectory()) {
|
|
109
|
+
// don't error just exit
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const fd = openSync(path, 'a');
|
|
114
|
+
close(fd);
|
|
115
|
+
const now = new Date();
|
|
116
|
+
const mtime = now;
|
|
117
|
+
const atime = now;
|
|
118
|
+
utimesSync(path, atime, mtime);
|
|
119
|
+
if (callback) {
|
|
120
|
+
callback();
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const tryStatFile = filePath => {
|
|
125
|
+
try {
|
|
126
|
+
return statSync(filePath);
|
|
127
|
+
} catch (e) {
|
|
128
|
+
debug(e);
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const fixArgs = args => (args ? (typeof args === 'string' ? args.split(' ') : args) : []);
|
|
134
|
+
|
|
99
135
|
export {
|
|
100
136
|
getSystemInfo,
|
|
101
137
|
format,
|
|
@@ -106,5 +142,7 @@ export {
|
|
|
106
142
|
hasAccess,
|
|
107
143
|
parseVersion,
|
|
108
144
|
readJSON,
|
|
109
|
-
|
|
145
|
+
fixArgs,
|
|
146
|
+
e,
|
|
147
|
+
touch
|
|
110
148
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "release-it",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "19.0.0-next.0",
|
|
4
4
|
"description": "Generic CLI tool to automate versioning and package publishing-related tasks.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"build",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"lint": "eslint lib test",
|
|
70
70
|
"format": "prettier --write eslint.config.mjs \"{lib,test}/**/*.js\"",
|
|
71
71
|
"docs": "remark README.md 'docs/**/*.md' '.github/*.md' -o",
|
|
72
|
-
"test": "ava --no-worker-threads && installed-check --ignore ava",
|
|
72
|
+
"test": "ava --no-worker-threads && installed-check --ignore ava --ignore nock",
|
|
73
73
|
"release": "./bin/release-it.js"
|
|
74
74
|
},
|
|
75
75
|
"author": {
|
|
@@ -79,56 +79,55 @@
|
|
|
79
79
|
"license": "MIT",
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@iarna/toml": "2.2.5",
|
|
82
|
-
"@octokit/rest": "21.0
|
|
82
|
+
"@octokit/rest": "21.1.0",
|
|
83
83
|
"async-retry": "1.3.3",
|
|
84
84
|
"chalk": "5.4.1",
|
|
85
85
|
"ci-info": "^4.1.0",
|
|
86
86
|
"cosmiconfig": "9.0.0",
|
|
87
87
|
"execa": "9.5.2",
|
|
88
88
|
"git-url-parse": "16.0.0",
|
|
89
|
-
"globby": "14.0
|
|
90
|
-
"inquirer": "12.
|
|
89
|
+
"globby": "14.1.0",
|
|
90
|
+
"inquirer": "12.4.1",
|
|
91
91
|
"issue-parser": "7.0.1",
|
|
92
92
|
"lodash": "4.17.21",
|
|
93
93
|
"mime-types": "2.1.35",
|
|
94
94
|
"new-github-release-url": "2.0.0",
|
|
95
95
|
"open": "10.1.0",
|
|
96
|
-
"ora": "8.
|
|
96
|
+
"ora": "8.2.0",
|
|
97
97
|
"os-name": "6.0.0",
|
|
98
98
|
"proxy-agent": "6.5.0",
|
|
99
|
-
"semver": "7.
|
|
100
|
-
"
|
|
101
|
-
"undici": "6.21.0",
|
|
99
|
+
"semver": "7.7.1",
|
|
100
|
+
"undici": "6.21.1",
|
|
102
101
|
"update-notifier": "7.3.1",
|
|
103
102
|
"url-join": "5.0.0",
|
|
104
103
|
"wildcard-match": "5.1.4",
|
|
105
104
|
"yargs-parser": "21.1.1"
|
|
106
105
|
},
|
|
107
106
|
"devDependencies": {
|
|
108
|
-
"@eslint/compat": "1.2.
|
|
107
|
+
"@eslint/compat": "1.2.6",
|
|
109
108
|
"@eslint/eslintrc": "3.2.0",
|
|
110
|
-
"@eslint/js": "9.
|
|
109
|
+
"@eslint/js": "9.20.0",
|
|
111
110
|
"@octokit/request-error": "6.1.6",
|
|
112
|
-
"@types/node": "20.17.
|
|
111
|
+
"@types/node": "20.17.17",
|
|
113
112
|
"ava": "6.2.0",
|
|
114
|
-
"eslint": "9.
|
|
115
|
-
"eslint-config-prettier": "
|
|
113
|
+
"eslint": "9.20.1",
|
|
114
|
+
"eslint-config-prettier": "10.0.1",
|
|
116
115
|
"eslint-plugin-ava": "15.0.1",
|
|
117
116
|
"eslint-plugin-import-x": "4.6.1",
|
|
118
|
-
"eslint-plugin-prettier": "5.2.
|
|
117
|
+
"eslint-plugin-prettier": "5.2.3",
|
|
119
118
|
"fs-monkey": "1.0.6",
|
|
120
119
|
"globals": "15.14.0",
|
|
121
120
|
"installed-check": "9.3.0",
|
|
122
|
-
"knip": "5.
|
|
123
|
-
"memfs": "4.
|
|
121
|
+
"knip": "5.44.0",
|
|
122
|
+
"memfs": "4.17.0",
|
|
124
123
|
"mock-stdio": "1.0.3",
|
|
125
|
-
"nock": "14.0.
|
|
126
|
-
"prettier": "3.
|
|
124
|
+
"nock": "14.0.1",
|
|
125
|
+
"prettier": "3.5.0",
|
|
127
126
|
"remark-cli": "12.0.1",
|
|
128
127
|
"remark-preset-webpro": "1.1.1",
|
|
129
128
|
"sinon": "19.0.2",
|
|
130
129
|
"strip-ansi": "7.1.0",
|
|
131
|
-
"typescript": "5.7.
|
|
130
|
+
"typescript": "5.7.3"
|
|
132
131
|
},
|
|
133
132
|
"overrides": {
|
|
134
133
|
"pac-resolver": "7.0.1",
|
package/test/git.init.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import childProcess from 'node:child_process';
|
|
2
|
+
import { mkdirSync } from 'node:fs';
|
|
1
3
|
import test from 'ava';
|
|
2
|
-
import sh from 'shelljs';
|
|
3
4
|
import Shell from '../lib/shell.js';
|
|
4
5
|
import Git from '../lib/plugin/git/Git.js';
|
|
5
|
-
import { readJSON } from '../lib/util.js';
|
|
6
|
+
import { execOpts, readJSON } from '../lib/util.js';
|
|
7
|
+
import sh from './util/sh.js';
|
|
6
8
|
import { factory } from './util/index.js';
|
|
7
9
|
import { mkTmpDir, gitAdd } from './util/helpers.js';
|
|
8
10
|
|
|
@@ -11,10 +13,10 @@ const { git } = readJSON(new URL('../config/release-it.json', import.meta.url));
|
|
|
11
13
|
test.serial.beforeEach(t => {
|
|
12
14
|
const bare = mkTmpDir();
|
|
13
15
|
const target = mkTmpDir();
|
|
14
|
-
|
|
15
|
-
sh.exec(`git init --bare
|
|
16
|
-
sh.exec(`git clone ${bare} ${target}
|
|
17
|
-
|
|
16
|
+
process.chdir(bare);
|
|
17
|
+
sh.exec(`git init --bare .`, execOpts);
|
|
18
|
+
sh.exec(`git clone ${bare} ${target}`, execOpts);
|
|
19
|
+
process.chdir(target);
|
|
18
20
|
gitAdd('line', 'file', 'Add file');
|
|
19
21
|
t.context = { bare, target };
|
|
20
22
|
});
|
|
@@ -22,14 +24,14 @@ test.serial.beforeEach(t => {
|
|
|
22
24
|
test.serial('should throw if on wrong branch', async t => {
|
|
23
25
|
const options = { git: { requireBranch: 'dev' } };
|
|
24
26
|
const gitClient = factory(Git, { options });
|
|
25
|
-
|
|
27
|
+
childProcess.execSync('git remote remove origin', execOpts);
|
|
26
28
|
await t.throwsAsync(gitClient.init(), { message: /^Must be on branch dev/ });
|
|
27
29
|
});
|
|
28
30
|
|
|
29
31
|
test.serial('should throw if on negated branch', async t => {
|
|
30
32
|
const options = { git: { requireBranch: '!main' } };
|
|
31
33
|
const gitClient = factory(Git, { options });
|
|
32
|
-
sh.exec('git checkout -b main');
|
|
34
|
+
sh.exec('git checkout -b main', execOpts);
|
|
33
35
|
await t.throwsAsync(gitClient.init(), { message: /^Must be on branch !main/ });
|
|
34
36
|
});
|
|
35
37
|
|
|
@@ -42,39 +44,39 @@ test.serial('should not throw if required branch matches', async t => {
|
|
|
42
44
|
test.serial('should not throw if one of required branch matches', async t => {
|
|
43
45
|
const options = { git: { requireBranch: ['release/*', 'hotfix/*'] } };
|
|
44
46
|
const gitClient = factory(Git, { options });
|
|
45
|
-
|
|
47
|
+
childProcess.execSync('git checkout -b release/v1', execOpts);
|
|
46
48
|
await t.notThrowsAsync(gitClient.init());
|
|
47
49
|
});
|
|
48
50
|
|
|
49
51
|
test.serial('should throw if there is no remote Git url', async t => {
|
|
50
52
|
const gitClient = factory(Git, { options: { git } });
|
|
51
|
-
|
|
53
|
+
childProcess.execSync('git remote remove origin', execOpts);
|
|
52
54
|
await t.throwsAsync(gitClient.init(), { message: /^Could not get remote Git url/ });
|
|
53
55
|
});
|
|
54
56
|
|
|
55
57
|
test.serial('should throw if working dir is not clean', async t => {
|
|
56
58
|
const gitClient = factory(Git, { options: { git } });
|
|
57
|
-
|
|
59
|
+
childProcess.execSync('rm file', execOpts);
|
|
58
60
|
await t.throwsAsync(gitClient.init(), { message: /^Working dir must be clean/ });
|
|
59
61
|
});
|
|
60
62
|
|
|
61
63
|
test.serial('should throw if no upstream is configured', async t => {
|
|
62
64
|
const gitClient = factory(Git, { options: { git } });
|
|
63
|
-
|
|
65
|
+
childProcess.execSync('git checkout -b foo', execOpts);
|
|
64
66
|
await t.throwsAsync(gitClient.init(), { message: /^No upstream configured for current branch/ });
|
|
65
67
|
});
|
|
66
68
|
|
|
67
69
|
test.serial('should throw if there are no commits', async t => {
|
|
68
70
|
const options = { git: { requireCommits: true } };
|
|
69
71
|
const gitClient = factory(Git, { options });
|
|
70
|
-
|
|
72
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
71
73
|
await t.throwsAsync(gitClient.init(), { message: /^There are no commits since the latest tag/ });
|
|
72
74
|
});
|
|
73
75
|
|
|
74
76
|
test.serial('should not throw if there are commits', async t => {
|
|
75
77
|
const options = { git: { requireCommits: true } };
|
|
76
78
|
const gitClient = factory(Git, { options });
|
|
77
|
-
|
|
79
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
78
80
|
gitAdd('line', 'file', 'Add file');
|
|
79
81
|
await t.notThrowsAsync(gitClient.init(), 'There are no commits since the latest tag');
|
|
80
82
|
});
|
|
@@ -82,29 +84,29 @@ test.serial('should not throw if there are commits', async t => {
|
|
|
82
84
|
test.serial('should fail (exit code 1) if there are no commits', async t => {
|
|
83
85
|
const options = { git: { requireCommits: true } };
|
|
84
86
|
const gitClient = factory(Git, { options });
|
|
85
|
-
|
|
87
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
86
88
|
await t.throwsAsync(gitClient.init(), { code: 1 });
|
|
87
89
|
});
|
|
88
90
|
|
|
89
91
|
test.serial('should not fail (exit code 0) if there are no commits', async t => {
|
|
90
92
|
const options = { git: { requireCommits: true, requireCommitsFail: false } };
|
|
91
93
|
const gitClient = factory(Git, { options });
|
|
92
|
-
|
|
94
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
93
95
|
await t.throwsAsync(gitClient.init(), { code: 0 });
|
|
94
96
|
});
|
|
95
97
|
|
|
96
98
|
test.serial('should throw if there are no commits in specified path', async t => {
|
|
97
99
|
const options = { git: { requireCommits: true, commitsPath: 'dir' } };
|
|
98
100
|
const gitClient = factory(Git, { options });
|
|
99
|
-
|
|
100
|
-
sh.exec('git tag 1.0.0');
|
|
101
|
+
mkdirSync('dir', { recursive: true });
|
|
102
|
+
sh.exec('git tag 1.0.0', execOpts);
|
|
101
103
|
await t.throwsAsync(gitClient.init(), { message: /^There are no commits since the latest tag/ });
|
|
102
104
|
});
|
|
103
105
|
|
|
104
106
|
test.serial('should not throw if there are commits in specified path', async t => {
|
|
105
107
|
const options = { git: { requireCommits: true, commitsPath: 'dir' } };
|
|
106
108
|
const gitClient = factory(Git, { options });
|
|
107
|
-
sh.exec('git tag 1.0.0');
|
|
109
|
+
sh.exec('git tag 1.0.0', execOpts);
|
|
108
110
|
gitAdd('line', 'dir/file', 'Add file');
|
|
109
111
|
await t.notThrowsAsync(gitClient.init());
|
|
110
112
|
});
|
|
@@ -117,14 +119,14 @@ test.serial('should not throw if there are no tags', async t => {
|
|
|
117
119
|
});
|
|
118
120
|
|
|
119
121
|
test.serial('should not throw if origin remote is renamed', async t => {
|
|
120
|
-
|
|
122
|
+
childProcess.execSync('git remote rename origin upstream', execOpts);
|
|
121
123
|
const gitClient = factory(Git);
|
|
122
124
|
await t.notThrowsAsync(gitClient.init());
|
|
123
125
|
});
|
|
124
126
|
|
|
125
127
|
test.serial('should detect and include version prefix ("v")', async t => {
|
|
126
128
|
const gitClient = factory(Git, { options: { git } });
|
|
127
|
-
|
|
129
|
+
childProcess.execSync('git tag v1.0.0', execOpts);
|
|
128
130
|
await gitClient.init();
|
|
129
131
|
await gitClient.bump('1.0.1');
|
|
130
132
|
t.is(gitClient.config.getContext('tagName'), 'v1.0.1');
|
|
@@ -132,7 +134,7 @@ test.serial('should detect and include version prefix ("v")', async t => {
|
|
|
132
134
|
|
|
133
135
|
test.serial('should detect and exclude version prefix', async t => {
|
|
134
136
|
const gitClient = factory(Git, { options: { git } });
|
|
135
|
-
|
|
137
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
136
138
|
await gitClient.init();
|
|
137
139
|
await gitClient.bump('1.0.1');
|
|
138
140
|
t.is(gitClient.config.getContext('tagName'), '1.0.1');
|
|
@@ -140,7 +142,7 @@ test.serial('should detect and exclude version prefix', async t => {
|
|
|
140
142
|
|
|
141
143
|
test.serial('should detect and exclude version prefix (configured)', async t => {
|
|
142
144
|
const gitClient = factory(Git, { options: { git: { tagName: 'v${version}' } } });
|
|
143
|
-
|
|
145
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
144
146
|
await gitClient.init();
|
|
145
147
|
await gitClient.bump('1.0.1');
|
|
146
148
|
t.is(gitClient.config.getContext('tagName'), 'v1.0.1');
|
|
@@ -148,7 +150,7 @@ test.serial('should detect and exclude version prefix (configured)', async t =>
|
|
|
148
150
|
|
|
149
151
|
test.serial('should honor custom tagName configuration', async t => {
|
|
150
152
|
const gitClient = factory(Git, { options: { git: { tagName: 'TAGNAME-${repo.project}-v${version}' } } });
|
|
151
|
-
|
|
153
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
152
154
|
await gitClient.init();
|
|
153
155
|
await gitClient.bump('1.0.1');
|
|
154
156
|
const { project } = gitClient.getContext('repo');
|
|
@@ -160,12 +162,13 @@ test.serial('should get the latest tag after fetch', async t => {
|
|
|
160
162
|
const gitClient = factory(Git, { container: { shell } });
|
|
161
163
|
const { bare, target } = t.context;
|
|
162
164
|
const other = mkTmpDir();
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
165
|
+
childProcess.execSync('git push', execOpts);
|
|
166
|
+
childProcess.execSync(`git clone ${bare} ${other}`, execOpts);
|
|
167
|
+
|
|
168
|
+
process.chdir(other);
|
|
169
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
170
|
+
childProcess.execSync('git push --tags', execOpts);
|
|
171
|
+
process.chdir(target);
|
|
169
172
|
await gitClient.init();
|
|
170
173
|
t.is(gitClient.config.getContext('latestTag'), '1.0.0');
|
|
171
174
|
});
|
|
@@ -178,14 +181,14 @@ test.serial('should get the latest custom tag after fetch when tagName is config
|
|
|
178
181
|
});
|
|
179
182
|
const { bare, target } = t.context;
|
|
180
183
|
const other = mkTmpDir();
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
184
|
+
childProcess.execSync('git push', execOpts);
|
|
185
|
+
childProcess.execSync(`git clone ${bare} ${other}`, execOpts);
|
|
186
|
+
process.chdir(other);
|
|
187
|
+
childProcess.execSync('git tag TAGNAME-OTHER-v2.0.0', execOpts);
|
|
188
|
+
childProcess.execSync('git tag TAGNAME-v1.0.0', execOpts);
|
|
189
|
+
childProcess.execSync('git tag TAGNAME-OTHER-v2.0.2', execOpts);
|
|
190
|
+
childProcess.execSync('git push --tags', execOpts);
|
|
191
|
+
process.chdir(target);
|
|
189
192
|
await gitClient.init();
|
|
190
193
|
t.is(gitClient.config.getContext('latestTag'), 'TAGNAME-v1.0.0');
|
|
191
194
|
});
|
|
@@ -196,10 +199,10 @@ test.serial('should get the latest tag based on tagMatch', async t => {
|
|
|
196
199
|
options: { git: { tagMatch: '[0-9][0-9]\\.[0-1][0-9]\\.[0-9]*' } },
|
|
197
200
|
container: { shell }
|
|
198
201
|
});
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
202
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
203
|
+
childProcess.execSync('git tag 21.04.3', execOpts);
|
|
204
|
+
childProcess.execSync('git tag 1.0.1', execOpts);
|
|
205
|
+
childProcess.execSync('git push --tags', execOpts);
|
|
203
206
|
await gitClient.init();
|
|
204
207
|
t.is(gitClient.config.getContext('latestTag'), '21.04.3');
|
|
205
208
|
});
|
|
@@ -210,20 +213,20 @@ test.serial('should get the latest tag based on tagExclude', async t => {
|
|
|
210
213
|
options: { git: { tagExclude: '*[-]*' } },
|
|
211
214
|
container: { shell }
|
|
212
215
|
});
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
216
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
217
|
+
childProcess.execSync('git commit --allow-empty -m "commit 1"', execOpts);
|
|
218
|
+
childProcess.execSync('git tag 1.0.1-rc.0', execOpts);
|
|
219
|
+
childProcess.execSync('git tag 1.0.1', execOpts);
|
|
220
|
+
childProcess.execSync('git commit --allow-empty -m "commit 2"', execOpts);
|
|
221
|
+
childProcess.execSync('git tag 1.1.0-rc.0', execOpts);
|
|
222
|
+
childProcess.execSync('git push --tags', execOpts);
|
|
220
223
|
await gitClient.init();
|
|
221
224
|
t.is(gitClient.config.getContext('latestTag'), '1.0.1');
|
|
222
225
|
});
|
|
223
226
|
|
|
224
227
|
test.serial('should generate correct changelog', async t => {
|
|
225
228
|
const gitClient = factory(Git, { options: { git } });
|
|
226
|
-
|
|
229
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
227
230
|
gitAdd('line', 'file', 'Add file');
|
|
228
231
|
gitAdd('line', 'file', 'Add file');
|
|
229
232
|
await gitClient.init();
|
|
@@ -237,11 +240,11 @@ test.serial('should get the full changelog since latest major tag', async t => {
|
|
|
237
240
|
options: { git: { tagMatch: '[0-9]\\.[0-9]\\.[0-9]', changelog: git.changelog } },
|
|
238
241
|
container: { shell }
|
|
239
242
|
});
|
|
240
|
-
|
|
243
|
+
childProcess.execSync('git tag 1.0.0', execOpts);
|
|
241
244
|
gitAdd('line', 'file', 'Add file');
|
|
242
|
-
|
|
245
|
+
childProcess.execSync('git tag 2.0.0-rc.0', execOpts);
|
|
243
246
|
gitAdd('line', 'file', 'Add file');
|
|
244
|
-
|
|
247
|
+
childProcess.execSync('git tag 2.0.0-rc.1', execOpts);
|
|
245
248
|
gitAdd('line', 'file', 'Add file');
|
|
246
249
|
await gitClient.init();
|
|
247
250
|
t.is(gitClient.config.getContext('latestTag'), '1.0.0');
|