release-it 0.0.0-pl.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/LICENSE +21 -0
- package/README.md +421 -0
- package/bin/release-it.js +42 -0
- package/config/release-it.json +70 -0
- package/lib/cli.js +44 -0
- package/lib/config.js +139 -0
- package/lib/index.js +152 -0
- package/lib/log.js +69 -0
- package/lib/plugin/GitBase.js +125 -0
- package/lib/plugin/GitRelease.js +58 -0
- package/lib/plugin/Plugin.js +73 -0
- package/lib/plugin/factory.js +89 -0
- package/lib/plugin/git/Git.js +220 -0
- package/lib/plugin/git/prompts.js +19 -0
- package/lib/plugin/github/GitHub.js +403 -0
- package/lib/plugin/github/prompts.js +16 -0
- package/lib/plugin/github/util.js +39 -0
- package/lib/plugin/gitlab/GitLab.js +277 -0
- package/lib/plugin/gitlab/prompts.js +9 -0
- package/lib/plugin/npm/npm.js +281 -0
- package/lib/plugin/npm/prompts.js +12 -0
- package/lib/plugin/version/Version.js +129 -0
- package/lib/prompt.js +33 -0
- package/lib/shell.js +91 -0
- package/lib/spinner.js +29 -0
- package/lib/util.js +109 -0
- package/package.json +122 -0
- package/test/cli.js +20 -0
- package/test/config.js +144 -0
- package/test/git.init.js +250 -0
- package/test/git.js +358 -0
- package/test/github.js +487 -0
- package/test/gitlab.js +252 -0
- package/test/log.js +143 -0
- package/test/npm.js +417 -0
- package/test/plugin-name.js +9 -0
- package/test/plugins.js +238 -0
- package/test/prompt.js +97 -0
- package/test/resources/file-v2.0.1.txt +1 -0
- package/test/resources/file-v2.0.2.txt +1 -0
- package/test/resources/file1 +1 -0
- package/test/shell.js +74 -0
- package/test/spinner.js +58 -0
- package/test/stub/config/default/.release-it.json +5 -0
- package/test/stub/config/invalid-config-rc +1 -0
- package/test/stub/config/invalid-config-txt +2 -0
- package/test/stub/config/merge/.release-it.json +5 -0
- package/test/stub/config/merge/package.json +7 -0
- package/test/stub/config/toml/.release-it.toml +2 -0
- package/test/stub/config/yaml/.release-it.yaml +2 -0
- package/test/stub/config/yml/.release-it.yml +2 -0
- package/test/stub/github.js +130 -0
- package/test/stub/gitlab.js +44 -0
- package/test/stub/plugin-context.js +36 -0
- package/test/stub/plugin-replace.js +9 -0
- package/test/stub/plugin.js +39 -0
- package/test/stub/shell.js +24 -0
- package/test/tasks.interactive.js +208 -0
- package/test/tasks.js +585 -0
- package/test/util/helpers.js +32 -0
- package/test/util/index.js +78 -0
- package/test/util/setup.js +5 -0
- package/test/utils.js +97 -0
- package/test/version.js +173 -0
package/test/utils.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { EOL } from 'node:os';
|
|
2
|
+
import test from 'ava';
|
|
3
|
+
import mockStdIo from 'mock-stdio';
|
|
4
|
+
import stripAnsi from 'strip-ansi';
|
|
5
|
+
import { format, truncateLines, parseGitUrl, parseVersion } from '../lib/util.js';
|
|
6
|
+
|
|
7
|
+
test('format', t => {
|
|
8
|
+
t.is(format('release v${version}', { version: '1.0.0' }), 'release v1.0.0');
|
|
9
|
+
t.is(format('release v${version} (${name})', { version: '1.0.0', name: 'foo' }), 'release v1.0.0 (foo)');
|
|
10
|
+
t.is(format('release v${version} (${name})', { version: '1.0.0', name: 'foo' }), 'release v1.0.0 (foo)');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('format (throw)', t => {
|
|
14
|
+
mockStdIo.start();
|
|
15
|
+
t.throws(() => format('release v${foo}', { version: '1.0.0' }), { message: /foo is not defined/ });
|
|
16
|
+
const { stdout, stderr } = mockStdIo.end();
|
|
17
|
+
t.is(stdout, '');
|
|
18
|
+
t.regex(
|
|
19
|
+
stripAnsi(stderr),
|
|
20
|
+
/ERROR Unable to render template with context:\s+release v\${foo}\s+{"version":"1\.0\.0"}\s+ERROR ReferenceError: foo is not defined/
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('truncateLines', t => {
|
|
25
|
+
const input = `1${EOL}2${EOL}3${EOL}4${EOL}5${EOL}6`;
|
|
26
|
+
t.is(truncateLines(input), input);
|
|
27
|
+
t.is(truncateLines(input, 3), `1${EOL}2${EOL}3${EOL}...and 3 more`);
|
|
28
|
+
t.is(truncateLines(input, 1, '...'), `1...`);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('parseGitUrl', t => {
|
|
32
|
+
t.deepEqual(parseGitUrl('https://github.com/webpro/release-it.git'), {
|
|
33
|
+
host: 'github.com',
|
|
34
|
+
owner: 'webpro',
|
|
35
|
+
project: 'release-it',
|
|
36
|
+
protocol: 'https',
|
|
37
|
+
remote: 'https://github.com/webpro/release-it.git',
|
|
38
|
+
repository: 'webpro/release-it'
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
t.deepEqual(parseGitUrl('git@gitlab.com:org/sub-group/repo-in-sub-group.git'), {
|
|
42
|
+
host: 'gitlab.com',
|
|
43
|
+
owner: 'org/sub-group',
|
|
44
|
+
project: 'repo-in-sub-group',
|
|
45
|
+
protocol: 'ssh',
|
|
46
|
+
remote: 'git@gitlab.com:org/sub-group/repo-in-sub-group.git',
|
|
47
|
+
repository: 'org/sub-group/repo-in-sub-group'
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
t.deepEqual(parseGitUrl('git@github.com:org/example.com.git'), {
|
|
51
|
+
host: 'github.com',
|
|
52
|
+
owner: 'org',
|
|
53
|
+
project: 'example.com',
|
|
54
|
+
protocol: 'ssh',
|
|
55
|
+
remote: 'git@github.com:org/example.com.git',
|
|
56
|
+
repository: 'org/example.com'
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
t.deepEqual(parseGitUrl('file://Users/john/doe/owner/project'), {
|
|
60
|
+
host: 'users',
|
|
61
|
+
owner: 'owner',
|
|
62
|
+
project: 'project',
|
|
63
|
+
protocol: 'file',
|
|
64
|
+
remote: 'file://users/john/doe/owner/project',
|
|
65
|
+
repository: 'owner/project'
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
t.deepEqual(parseGitUrl('/Users/john/doe/owner/project'), {
|
|
69
|
+
host: 'users',
|
|
70
|
+
owner: 'owner',
|
|
71
|
+
project: 'project',
|
|
72
|
+
protocol: 'file',
|
|
73
|
+
remote: 'file://users/john/doe/owner/project',
|
|
74
|
+
repository: 'owner/project'
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
t.deepEqual(parseGitUrl('C:\\\\Users\\john\\doe\\owner\\project'), {
|
|
78
|
+
host: 'users',
|
|
79
|
+
owner: 'owner',
|
|
80
|
+
project: 'project',
|
|
81
|
+
protocol: 'file',
|
|
82
|
+
remote: 'file://users/john/doe/owner/project',
|
|
83
|
+
repository: 'owner/project'
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('parseVersion', t => {
|
|
88
|
+
t.deepEqual(parseVersion(), { version: undefined, isPreRelease: false, preReleaseId: null });
|
|
89
|
+
t.deepEqual(parseVersion(0), { version: '0.0.0', isPreRelease: false, preReleaseId: null });
|
|
90
|
+
t.deepEqual(parseVersion(1), { version: '1.0.0', isPreRelease: false, preReleaseId: null });
|
|
91
|
+
t.deepEqual(parseVersion('1'), { version: '1.0.0', isPreRelease: false, preReleaseId: null });
|
|
92
|
+
t.deepEqual(parseVersion('1.0'), { version: '1.0.0', isPreRelease: false, preReleaseId: null });
|
|
93
|
+
t.deepEqual(parseVersion('1.0.0'), { version: '1.0.0', isPreRelease: false, preReleaseId: null });
|
|
94
|
+
t.deepEqual(parseVersion('1.0.0-0'), { version: '1.0.0-0', isPreRelease: true, preReleaseId: null });
|
|
95
|
+
t.deepEqual(parseVersion('1.0.0-next.1'), { version: '1.0.0-next.1', isPreRelease: true, preReleaseId: 'next' });
|
|
96
|
+
t.deepEqual(parseVersion('21.04.1'), { version: '21.04.1', isPreRelease: false, preReleaseId: null });
|
|
97
|
+
});
|
package/test/version.js
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import sinon from 'sinon';
|
|
3
|
+
import Version from '../lib/plugin/version/Version.js';
|
|
4
|
+
import { factory, runTasks } from './util/index.js';
|
|
5
|
+
|
|
6
|
+
test('isValidVersion', t => {
|
|
7
|
+
const v = factory(Version);
|
|
8
|
+
t.is(v.isValid('1.0.0'), true);
|
|
9
|
+
t.is(v.isValid(1.0), false);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('isPreRelease', t => {
|
|
13
|
+
const v = factory(Version);
|
|
14
|
+
t.is(v.isPreRelease('1.0.0-beta.0'), true);
|
|
15
|
+
t.is(v.isPreRelease('1.0.0'), false);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('should return the same version in both interactive and ci mode', async t => {
|
|
19
|
+
const v = factory(Version);
|
|
20
|
+
const options = { latestVersion: '2.0.0-beta.1', increment: null, preReleaseId: 'rc', isPreRelease: true };
|
|
21
|
+
const resultInteractiveMode = await v.getIncrementedVersion(options);
|
|
22
|
+
t.is(resultInteractiveMode, '2.0.0-rc.0');
|
|
23
|
+
const resultCiMode = v.getIncrementedVersionCI(options);
|
|
24
|
+
t.is(resultInteractiveMode, resultCiMode);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('should increment latest version', t => {
|
|
28
|
+
const v = factory(Version);
|
|
29
|
+
const latestVersion = '1.0.0';
|
|
30
|
+
t.is(v.incrementVersion({ latestVersion, increment: false }), '1.0.0');
|
|
31
|
+
t.is(v.incrementVersion({ latestVersion, increment: 'foo' }), undefined);
|
|
32
|
+
t.is(v.incrementVersion({ latestVersion, increment: 'patsj' }), undefined);
|
|
33
|
+
t.is(v.incrementVersion({ latestVersion, increment: 'a.b.c' }), undefined);
|
|
34
|
+
t.is(v.incrementVersion({ latestVersion, increment: '0.9.0' }), undefined);
|
|
35
|
+
t.is(v.incrementVersion({ latestVersion, increment: '1.1.0' }), '1.1.0');
|
|
36
|
+
t.is(v.incrementVersion({ latestVersion, increment: 'major' }), '2.0.0');
|
|
37
|
+
t.is(v.incrementVersion({ latestVersion, increment: '2.0.0-beta.1' }), '2.0.0-beta.1');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('should not increment latest version in interactive mode', t => {
|
|
41
|
+
const v = factory(Version, { options: { ci: false } });
|
|
42
|
+
const latestVersion = '1.0.0';
|
|
43
|
+
t.is(v.incrementVersion({ latestVersion, increment: null }), undefined);
|
|
44
|
+
t.is(v.incrementVersion({ latestVersion, increment: false }), '1.0.0');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('should always set increment version in CI mode', t => {
|
|
48
|
+
const v = factory(Version, { options: { ci: true } });
|
|
49
|
+
const latestVersion = '1.0.0';
|
|
50
|
+
t.is(v.getIncrementedVersionCI({ latestVersion, increment: false }), '1.0.0');
|
|
51
|
+
t.is(v.getIncrementedVersionCI({ latestVersion, increment: null }), '1.0.1');
|
|
52
|
+
t.is(v.getIncrementedVersionCI({ latestVersion, increment: '1.1.0' }), '1.1.0');
|
|
53
|
+
t.is(v.getIncrementedVersionCI({ latestVersion, increment: 'major' }), '2.0.0');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('should increment latest version (coerce)', t => {
|
|
57
|
+
const v = factory(Version);
|
|
58
|
+
t.is(v.incrementVersion({ increment: '1.2' }), '1.2.0');
|
|
59
|
+
t.is(v.incrementVersion({ increment: '1' }), '1.0.0');
|
|
60
|
+
t.is(v.incrementVersion({ increment: 'v1.2.0.0' }), '1.2.0');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('should increment version (pre-release continuation)', t => {
|
|
64
|
+
const v = factory(Version);
|
|
65
|
+
t.is(v.incrementVersion({ latestVersion: '1.2.3-alpha.0', increment: 'prepatch' }), '1.2.4-0');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('should increment version (prepatch)', t => {
|
|
69
|
+
const v = factory(Version);
|
|
70
|
+
t.is(v.incrementVersion({ latestVersion: '1.2.3', increment: 'prepatch', preReleaseId: 'alpha' }), '1.2.4-alpha.0');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('should increment version (normalized)', t => {
|
|
74
|
+
const v = factory(Version);
|
|
75
|
+
t.is(
|
|
76
|
+
v.incrementVersion({ latestVersion: '1.2.3', increment: 'patch', preReleaseId: 'alpha', isPreRelease: true }),
|
|
77
|
+
'1.2.4-alpha.0'
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test('should increment version (prepatch on prerelease version)', t => {
|
|
82
|
+
const v = factory(Version);
|
|
83
|
+
t.is(
|
|
84
|
+
v.incrementVersion({ latestVersion: '1.2.3-alpha.5', increment: 'prepatch', preReleaseId: 'next' }),
|
|
85
|
+
'1.2.4-next.0'
|
|
86
|
+
);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('should increment version (normalized on prerelease version)', t => {
|
|
90
|
+
const v = factory(Version);
|
|
91
|
+
t.is(
|
|
92
|
+
v.incrementVersion({
|
|
93
|
+
latestVersion: '1.2.3-alpha.5',
|
|
94
|
+
increment: 'patch',
|
|
95
|
+
preReleaseId: 'next',
|
|
96
|
+
isPreRelease: true
|
|
97
|
+
}),
|
|
98
|
+
'1.2.4-next.0'
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('should increment version (prerelease)', t => {
|
|
103
|
+
const v = factory(Version);
|
|
104
|
+
t.is(v.incrementVersion({ latestVersion: '1.2.3', increment: 'prerelease', preReleaseId: 'alpha' }), '1.2.4-alpha.0');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('should increment version (prerelease cont.)', t => {
|
|
108
|
+
const v = factory(Version);
|
|
109
|
+
t.is(v.incrementVersion({ latestVersion: '1.2.3-alpha.0', increment: 'prerelease' }), '1.2.3-alpha.1');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test('should increment version (preReleaseId continuation)', t => {
|
|
113
|
+
const v = factory(Version);
|
|
114
|
+
t.is(
|
|
115
|
+
v.incrementVersion({ latestVersion: '1.2.3-alpha.0', increment: 'prerelease', preReleaseId: 'alpha' }),
|
|
116
|
+
'1.2.3-alpha.1'
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('should increment version (prepatch/preReleaseId continuation)', t => {
|
|
121
|
+
const v = factory(Version);
|
|
122
|
+
const options = { latestVersion: '1.2.3-beta.0', increment: 'prerelease', preReleaseId: 'beta', isPreRelease: true };
|
|
123
|
+
t.is(v.incrementVersion(options), '1.2.3-beta.1');
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test('should increment version (preReleaseId w/o preRelease)', t => {
|
|
127
|
+
const v = factory(Version);
|
|
128
|
+
t.is(v.incrementVersion({ latestVersion: '1.2.3-alpha.0', increment: 'patch', preReleaseId: 'alpha' }), '1.2.3');
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('should increment version (non-numeric prepatch continuation)', t => {
|
|
132
|
+
const v = factory(Version);
|
|
133
|
+
t.is(v.incrementVersion({ latestVersion: '1.2.3-alpha', increment: 'prerelease' }), '1.2.3-alpha.0');
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test('should increment version (patch release after pre-release)', t => {
|
|
137
|
+
const v = factory(Version);
|
|
138
|
+
t.is(v.incrementVersion({ latestVersion: '1.2.3-alpha.1', increment: 'patch' }), '1.2.3');
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test('should run tasks without errors', async t => {
|
|
142
|
+
const options = { version: { increment: 'minor' } };
|
|
143
|
+
const v = factory(Version, { options });
|
|
144
|
+
const getIncrement = sinon.spy(v, 'getIncrement');
|
|
145
|
+
const getIncrementedVersionCI = sinon.spy(v, 'getIncrementedVersionCI');
|
|
146
|
+
const incrementVersion = sinon.spy(v, 'incrementVersion');
|
|
147
|
+
|
|
148
|
+
await runTasks(v);
|
|
149
|
+
|
|
150
|
+
t.is(getIncrement.callCount, 1);
|
|
151
|
+
t.deepEqual(getIncrement.firstCall.args[0], { increment: 'minor' });
|
|
152
|
+
t.is(getIncrementedVersionCI.callCount, 1);
|
|
153
|
+
t.deepEqual(getIncrementedVersionCI.firstCall.args[0], {
|
|
154
|
+
latestVersion: '1.0.0',
|
|
155
|
+
increment: 'minor',
|
|
156
|
+
isPreRelease: false,
|
|
157
|
+
preReleaseId: null
|
|
158
|
+
});
|
|
159
|
+
t.is(await incrementVersion.firstCall.returnValue, '1.1.0');
|
|
160
|
+
t.is(incrementVersion.callCount, 1);
|
|
161
|
+
t.deepEqual(incrementVersion.firstCall.args[0], {
|
|
162
|
+
latestVersion: '1.0.0',
|
|
163
|
+
increment: 'minor',
|
|
164
|
+
isPreRelease: false,
|
|
165
|
+
preReleaseId: null
|
|
166
|
+
});
|
|
167
|
+
t.is(incrementVersion.firstCall.returnValue, '1.1.0');
|
|
168
|
+
const { latestVersion, version, isPreRelease, preReleaseId } = v.config.getContext();
|
|
169
|
+
t.is(latestVersion, '1.0.0');
|
|
170
|
+
t.is(version, '1.1.0');
|
|
171
|
+
t.is(isPreRelease, false);
|
|
172
|
+
t.is(preReleaseId, null);
|
|
173
|
+
});
|