release-it 14.11.8 → 15.0.0-esm.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/release-it.js +6 -4
- package/lib/cli.js +18 -4
- package/lib/config.js +12 -14
- package/lib/deprecated.js +6 -4
- package/lib/index.js +139 -13
- package/lib/log.js +6 -4
- package/lib/metrics.js +11 -8
- package/lib/plugin/GitBase.js +4 -4
- package/lib/plugin/GitRelease.js +6 -4
- package/lib/plugin/Plugin.js +3 -3
- package/lib/plugin/factory.js +26 -14
- package/lib/plugin/git/Git.js +7 -7
- package/lib/plugin/git/prompts.js +2 -2
- package/lib/plugin/github/GitHub.js +20 -15
- package/lib/plugin/github/prompts.js +2 -2
- package/lib/plugin/gitlab/GitLab.js +10 -10
- package/lib/plugin/gitlab/prompts.js +2 -2
- package/lib/plugin/npm/npm.js +8 -8
- package/lib/plugin/npm/prompts.js +1 -1
- package/lib/plugin/version/Version.js +4 -4
- package/lib/prompt.js +2 -2
- package/lib/shell.js +7 -5
- package/lib/spinner.js +5 -5
- package/lib/util.js +13 -9
- package/package.json +19 -17
- package/test/cli.js +6 -4
- package/test/config.js +7 -5
- package/test/deprecated.js +4 -4
- package/test/git.init.js +9 -7
- package/test/git.js +7 -7
- package/test/github.js +57 -15
- package/test/gitlab.js +7 -7
- package/test/log.js +5 -5
- package/test/metrics.js +3 -3
- package/test/npm.js +7 -9
- package/test/plugins.js +92 -117
- package/test/prompt.js +9 -9
- package/test/shell.js +6 -6
- package/test/spinner.js +11 -13
- package/test/stub/github.js +2 -2
- package/test/stub/gitlab.js +7 -9
- 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 +5 -3
- package/test/tasks.interactive.js +14 -14
- package/test/tasks.js +35 -34
- package/test/util/helpers.js +5 -10
- package/test/util/index.js +12 -12
- package/test/util/setup.js +2 -14
- package/test/utils.js +5 -5
- package/test/version.js +4 -4
- package/lib/tasks.js +0 -139
package/test/plugins.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import sh from 'shelljs';
|
|
3
|
+
import sinon from 'sinon';
|
|
4
|
+
import Log from '../lib/log.js';
|
|
5
|
+
import Spinner from '../lib/spinner.js';
|
|
6
|
+
import Config from '../lib/config.js';
|
|
7
|
+
import { parseGitUrl } from '../lib/util.js';
|
|
8
|
+
import runTasks from '../lib/index.js';
|
|
9
|
+
import MyPlugin from './stub/plugin.js';
|
|
10
|
+
import ReplacePlugin from './stub/plugin-replace.js';
|
|
11
|
+
import ContextPlugin from './stub/plugin-context.js';
|
|
12
|
+
import { mkTmpDir } from './util/helpers.js';
|
|
13
|
+
import ShellStub from './stub/shell.js';
|
|
14
|
+
|
|
15
|
+
const rootDir = new URL('..', import.meta.url);
|
|
12
16
|
|
|
13
17
|
const noop = Promise.resolve();
|
|
14
18
|
|
|
@@ -36,45 +40,40 @@ const getContainer = options => {
|
|
|
36
40
|
};
|
|
37
41
|
|
|
38
42
|
test.serial.beforeEach(t => {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
sh.exec(`git init --bare .`);
|
|
43
|
-
sh.exec(`git clone ${bare} ${target}`);
|
|
44
|
-
sh.pushd('-q', target);
|
|
45
|
-
gitAdd('line', 'file', 'Add file');
|
|
46
|
-
t.context = { bare, target };
|
|
43
|
+
const dir = mkTmpDir();
|
|
44
|
+
sh.pushd('-q', dir);
|
|
45
|
+
t.context = { dir };
|
|
47
46
|
});
|
|
48
47
|
|
|
49
48
|
test.serial.afterEach(() => {
|
|
50
49
|
sandbox.resetHistory();
|
|
51
50
|
});
|
|
52
51
|
|
|
53
|
-
const myPlugin = sandbox.createStubInstance(Plugin);
|
|
54
|
-
myPlugin.namespace = 'my-plugin';
|
|
55
|
-
const MyPlugin = sandbox.stub().callsFake(() => myPlugin);
|
|
56
|
-
const myLocalPlugin = sandbox.createStubInstance(Plugin);
|
|
57
|
-
const MyLocalPlugin = sandbox.stub().callsFake(() => myLocalPlugin);
|
|
58
|
-
const replacePlugin = sandbox.createStubInstance(Plugin);
|
|
59
|
-
const ReplacePlugin = sandbox.stub().callsFake(() => replacePlugin);
|
|
60
|
-
|
|
61
|
-
const staticMembers = { isEnabled: () => true, disablePlugin: () => null };
|
|
62
|
-
const options = { '@global': true, '@noCallThru': true };
|
|
63
|
-
const runTasks = proxyquire('../lib/tasks', {
|
|
64
|
-
'my-plugin': Object.assign(MyPlugin, staticMembers, options),
|
|
65
|
-
'/my/plugin': Object.assign(MyLocalPlugin, staticMembers, options),
|
|
66
|
-
'replace-plugin': Object.assign(ReplacePlugin, staticMembers, options, {
|
|
67
|
-
disablePlugin: () => ['version', 'git']
|
|
68
|
-
})
|
|
69
|
-
});
|
|
70
|
-
|
|
71
52
|
test.serial('should instantiate plugins and execute all release-cycle methods', async t => {
|
|
53
|
+
sh.ShellString(JSON.stringify({ name: 'project', version: '1.0.0', type: 'module' })).toEnd('package.json');
|
|
54
|
+
sh.exec(`npm install ${rootDir}`);
|
|
55
|
+
|
|
56
|
+
const pluginDir = mkTmpDir();
|
|
57
|
+
sh.pushd('-q', pluginDir);
|
|
58
|
+
sh.ShellString(JSON.stringify({ name: 'my-plugin', version: '1.0.0', type: 'module' })).toEnd('package.json');
|
|
59
|
+
sh.exec(`npm install ${rootDir}`);
|
|
60
|
+
const content = "import { Plugin } from 'release-it'; " + MyPlugin.toString() + '; export default MyPlugin;';
|
|
61
|
+
sh.ShellString(content).toEnd('index.js');
|
|
62
|
+
sh.popd();
|
|
63
|
+
|
|
64
|
+
sh.mkdir('-p', 'my/plugin');
|
|
65
|
+
sh.pushd('-q', 'my/plugin');
|
|
66
|
+
sh.ShellString(content).toEnd('index.js');
|
|
67
|
+
sh.popd();
|
|
68
|
+
|
|
69
|
+
sh.exec(`npm install ${pluginDir}`);
|
|
70
|
+
|
|
72
71
|
const config = {
|
|
73
72
|
plugins: {
|
|
74
73
|
'my-plugin': {
|
|
75
74
|
name: 'foo'
|
|
76
75
|
},
|
|
77
|
-
'
|
|
76
|
+
'./my/plugin/index.js': [
|
|
78
77
|
'named-plugin',
|
|
79
78
|
{
|
|
80
79
|
name: 'bar'
|
|
@@ -84,41 +83,45 @@ test.serial('should instantiate plugins and execute all release-cycle methods',
|
|
|
84
83
|
};
|
|
85
84
|
const container = getContainer(config);
|
|
86
85
|
|
|
87
|
-
await runTasks({}, container);
|
|
86
|
+
const result = await runTasks({}, container);
|
|
88
87
|
|
|
89
|
-
t.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
'
|
|
96
|
-
'
|
|
97
|
-
'
|
|
98
|
-
'
|
|
99
|
-
'
|
|
100
|
-
'
|
|
101
|
-
'
|
|
102
|
-
'beforeRelease',
|
|
103
|
-
'release',
|
|
104
|
-
'
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
});
|
|
88
|
+
t.deepEqual(container.log.info.args, [
|
|
89
|
+
['my-plugin:foo:init'],
|
|
90
|
+
['named-plugin:bar:init'],
|
|
91
|
+
['my-plugin:foo:getName'],
|
|
92
|
+
['my-plugin:foo:getLatestVersion'],
|
|
93
|
+
['my-plugin:foo:getIncrement'],
|
|
94
|
+
['my-plugin:foo:getIncrementedVersionCI'],
|
|
95
|
+
['named-plugin:bar:getIncrementedVersionCI'],
|
|
96
|
+
['my-plugin:foo:beforeBump'],
|
|
97
|
+
['named-plugin:bar:beforeBump'],
|
|
98
|
+
['my-plugin:foo:bump:1.3.0'],
|
|
99
|
+
['named-plugin:bar:bump:1.3.0'],
|
|
100
|
+
['my-plugin:foo:beforeRelease'],
|
|
101
|
+
['named-plugin:bar:beforeRelease'],
|
|
102
|
+
['my-plugin:foo:release'],
|
|
103
|
+
['named-plugin:bar:release'],
|
|
104
|
+
['my-plugin:foo:afterRelease'],
|
|
105
|
+
['named-plugin:bar:afterRelease']
|
|
106
|
+
]);
|
|
109
107
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
108
|
+
t.deepEqual(result, {
|
|
109
|
+
changelog: undefined,
|
|
110
|
+
name: 'new-project-name',
|
|
111
|
+
latestVersion: '1.2.3',
|
|
112
|
+
version: '1.3.0'
|
|
113
|
+
});
|
|
116
114
|
});
|
|
117
115
|
|
|
118
116
|
test.serial('should disable core plugins', async t => {
|
|
117
|
+
sh.ShellString(JSON.stringify({ name: 'project', version: '1.0.0' })).toEnd('package.json');
|
|
118
|
+
sh.exec(`npm install release-it@^14`);
|
|
119
|
+
const content = "const { Plugin } = require('release-it'); module.exports = " + ReplacePlugin.toString();
|
|
120
|
+
sh.ShellString(content).toEnd('replace-plugin.js');
|
|
121
|
+
|
|
119
122
|
const config = {
|
|
120
123
|
plugins: {
|
|
121
|
-
'replace-plugin': {}
|
|
124
|
+
'./replace-plugin.js': {}
|
|
122
125
|
}
|
|
123
126
|
};
|
|
124
127
|
const container = getContainer(config);
|
|
@@ -134,55 +137,21 @@ test.serial('should disable core plugins', async t => {
|
|
|
134
137
|
});
|
|
135
138
|
|
|
136
139
|
test.serial('should expose context to execute commands', async t => {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
class MyPlugin extends Plugin {
|
|
145
|
-
init() {
|
|
146
|
-
this.exec('echo ${version.isPreRelease}');
|
|
147
|
-
}
|
|
148
|
-
beforeBump() {
|
|
149
|
-
const context = this.config.getContext();
|
|
150
|
-
t.is(context.name, pkgName);
|
|
151
|
-
this.exec('echo ${name} ${repo.owner} ${repo.project} ${latestVersion} ${version}');
|
|
152
|
-
}
|
|
153
|
-
bump() {
|
|
154
|
-
const repo = this.config.getContext('repo');
|
|
155
|
-
t.is(repo.owner, owner);
|
|
156
|
-
t.is(repo.project, project);
|
|
157
|
-
t.is(repo.repository, `${owner}/${project}`);
|
|
158
|
-
this.exec('echo ${name} ${repo.owner} ${repo.project} ${latestVersion} ${version}');
|
|
159
|
-
}
|
|
160
|
-
beforeRelease() {
|
|
161
|
-
const context = this.config.getContext();
|
|
162
|
-
t.is(context.name, pkgName);
|
|
163
|
-
this.exec('echo ${name} ${repo.owner} ${repo.project} ${latestVersion} ${version} ${tagName}');
|
|
164
|
-
}
|
|
165
|
-
release() {
|
|
166
|
-
const context = this.config.getContext();
|
|
167
|
-
t.is(context.latestVersion, latestVersion);
|
|
168
|
-
t.is(context.version, '1.0.1');
|
|
169
|
-
this.exec('echo ${name} ${repo.owner} ${repo.project} ${latestVersion} ${version} ${tagName}');
|
|
170
|
-
}
|
|
171
|
-
afterRelease() {
|
|
172
|
-
const context = this.config.getContext();
|
|
173
|
-
t.is(context.tagName, '1.0.1');
|
|
174
|
-
this.exec('echo ${name} ${repo.owner} ${repo.project} ${latestVersion} ${version} ${tagName}');
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
const statics = { isEnabled: () => true, disablePlugin: () => null };
|
|
178
|
-
const options = { '@global': true, '@noCallThru': true };
|
|
179
|
-
const runTasks = proxyquire('../lib/tasks', {
|
|
180
|
-
'my-plugin': Object.assign(MyPlugin, statics, options)
|
|
181
|
-
});
|
|
140
|
+
sh.ShellString(JSON.stringify({ name: 'pkg-name', version: '1.0.0', type: 'module' })).toEnd('package.json');
|
|
141
|
+
sh.exec(`npm install ${rootDir}`);
|
|
142
|
+
|
|
143
|
+
const content =
|
|
144
|
+
"import { Plugin } from 'release-it'; " + ContextPlugin.toString() + '; export default ContextPlugin;';
|
|
145
|
+
sh.ShellString(content).toEnd('context-plugin.js');
|
|
182
146
|
|
|
183
|
-
const
|
|
147
|
+
const repo = parseGitUrl('https://github.com/user/pkg');
|
|
148
|
+
|
|
149
|
+
const container = getContainer({ plugins: { './context-plugin.js': {} } });
|
|
184
150
|
const exec = sinon.spy(container.shell, 'execFormattedCommand');
|
|
185
151
|
|
|
152
|
+
container.config.setContext({ repo });
|
|
153
|
+
container.config.setContext({ tagName: '1.0.1' });
|
|
154
|
+
|
|
186
155
|
await runTasks({}, container);
|
|
187
156
|
|
|
188
157
|
const pluginExecArgs = exec.args
|
|
@@ -191,10 +160,16 @@ test.serial('should expose context to execute commands', async t => {
|
|
|
191
160
|
|
|
192
161
|
t.deepEqual(pluginExecArgs, [
|
|
193
162
|
'echo false',
|
|
194
|
-
|
|
195
|
-
`echo
|
|
196
|
-
`echo
|
|
197
|
-
`echo
|
|
198
|
-
`echo
|
|
163
|
+
'echo false',
|
|
164
|
+
`echo pkg-name user 1.0.0 1.0.1`,
|
|
165
|
+
`echo pkg-name user 1.0.0 1.0.1`,
|
|
166
|
+
`echo user pkg user/pkg 1.0.1`,
|
|
167
|
+
`echo user pkg user/pkg 1.0.1`,
|
|
168
|
+
`echo user pkg user/pkg 1.0.1`,
|
|
169
|
+
`echo user pkg user/pkg 1.0.1`,
|
|
170
|
+
`echo pkg 1.0.0 1.0.1 1.0.1`,
|
|
171
|
+
`echo pkg 1.0.0 1.0.1 1.0.1`,
|
|
172
|
+
`echo pkg 1.0.0 1.0.1 1.0.1`,
|
|
173
|
+
`echo pkg 1.0.0 1.0.1 1.0.1`
|
|
199
174
|
]);
|
|
200
175
|
});
|
package/test/prompt.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import sinon from 'sinon';
|
|
3
|
+
import Prompt from '../lib/prompt.js';
|
|
4
|
+
import Config from '../lib/config.js';
|
|
5
|
+
import git from '../lib/plugin/git/prompts.js';
|
|
6
|
+
import github from '../lib/plugin/github/prompts.js';
|
|
7
|
+
import gitlab from '../lib/plugin/gitlab/prompts.js';
|
|
8
|
+
import npm from '../lib/plugin/npm/prompts.js';
|
|
9
|
+
import { factory } from './util/index.js';
|
|
10
10
|
|
|
11
11
|
const prompts = { git, github, gitlab, npm };
|
|
12
12
|
|
package/test/shell.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import sh from 'shelljs';
|
|
3
|
+
import sinon from 'sinon';
|
|
4
|
+
import Shell from '../lib/shell.js';
|
|
5
|
+
import Log from '../lib/log.js';
|
|
6
|
+
import { factory } from './util/index.js';
|
|
7
7
|
|
|
8
8
|
const { stdout } = sh.exec('pwd');
|
|
9
9
|
const cwd = stdout.trim();
|
package/test/spinner.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import sinon from 'sinon';
|
|
3
|
+
import Spinner from '../lib/spinner.js';
|
|
4
|
+
import Config from '../lib/config.js';
|
|
5
5
|
|
|
6
6
|
test.beforeEach(t => {
|
|
7
|
-
t.context.ora =
|
|
8
|
-
promise: sinon.spy()
|
|
9
|
-
};
|
|
7
|
+
t.context.ora = sinon.spy();
|
|
10
8
|
});
|
|
11
9
|
|
|
12
10
|
const getConfig = options => {
|
|
@@ -24,7 +22,7 @@ test('should not show spinner and not execute task if disabled', async t => {
|
|
|
24
22
|
const spinner = new Spinner({ container: { ora } });
|
|
25
23
|
await spinner.show({ enabled: false, task });
|
|
26
24
|
t.is(task.callCount, 0);
|
|
27
|
-
t.is(ora.
|
|
25
|
+
t.is(ora.callCount, 0);
|
|
28
26
|
});
|
|
29
27
|
|
|
30
28
|
test('should show spinner and run task by default', async t => {
|
|
@@ -35,9 +33,9 @@ test('should show spinner and run task by default', async t => {
|
|
|
35
33
|
const spinner = new Spinner({ container: { ora, config } });
|
|
36
34
|
await spinner.show({ task, label });
|
|
37
35
|
t.is(task.callCount, 1);
|
|
38
|
-
t.is(ora.
|
|
39
|
-
t.is(ora.
|
|
40
|
-
t.is(ora.
|
|
36
|
+
t.is(ora.callCount, 1);
|
|
37
|
+
t.is(ora.firstCall.args[0], task.firstCall.returnValue);
|
|
38
|
+
t.is(ora.firstCall.args[1], label);
|
|
41
39
|
});
|
|
42
40
|
|
|
43
41
|
test('should run task, but not show spinner if interactive', async t => {
|
|
@@ -47,7 +45,7 @@ test('should run task, but not show spinner if interactive', async t => {
|
|
|
47
45
|
const spinner = new Spinner({ container: { ora, config } });
|
|
48
46
|
await spinner.show({ task });
|
|
49
47
|
t.is(task.callCount, 1);
|
|
50
|
-
t.is(ora.
|
|
48
|
+
t.is(ora.callCount, 0);
|
|
51
49
|
});
|
|
52
50
|
|
|
53
51
|
test('should run task and show spinner if interactive, but external', async t => {
|
|
@@ -57,5 +55,5 @@ test('should run task and show spinner if interactive, but external', async t =>
|
|
|
57
55
|
const spinner = new Spinner({ container: { ora, config } });
|
|
58
56
|
await spinner.show({ task, external: true });
|
|
59
57
|
t.is(task.callCount, 1);
|
|
60
|
-
t.is(ora.
|
|
58
|
+
t.is(ora.callCount, 1);
|
|
61
59
|
});
|
package/test/stub/github.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import nock from 'nock';
|
|
2
2
|
|
|
3
3
|
const interceptAuthentication = ({ api = 'https://api.github.com', username = 'john' } = {}) =>
|
|
4
4
|
nock(api).get('/user').reply(200, {
|
|
@@ -104,7 +104,7 @@ const interceptAsset = ({
|
|
|
104
104
|
};
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
export {
|
|
108
108
|
interceptAuthentication,
|
|
109
109
|
interceptCollaborator,
|
|
110
110
|
interceptListReleases,
|
package/test/stub/gitlab.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import nock from 'nock';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export let interceptUser = ({ host = 'https://gitlab.com', owner = 'user' } = {}, options) =>
|
|
4
4
|
nock(host, options).get('/api/v4/user').reply(200, { id: 1, username: owner });
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
export let interceptCollaborator = (
|
|
7
7
|
{ host = 'https://gitlab.com', owner = 'user', project = 'repo', group, userId = 1 } = {},
|
|
8
8
|
options
|
|
9
9
|
) =>
|
|
@@ -11,7 +11,7 @@ module.exports.interceptCollaborator = (
|
|
|
11
11
|
.get(`/api/v4/projects/${group ? `${group}%2F` : ''}${owner}%2F${project}/members/all/${userId}`)
|
|
12
12
|
.reply(200, { id: userId, username: owner, access_level: 30 });
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
export let interceptCollaboratorFallback = (
|
|
15
15
|
{ host = 'https://gitlab.com', owner = 'user', project = 'repo', group, userId = 1 } = {},
|
|
16
16
|
options
|
|
17
17
|
) =>
|
|
@@ -19,12 +19,10 @@ module.exports.interceptCollaboratorFallback = (
|
|
|
19
19
|
.get(`/api/v4/projects/${group ? `${group}%2F` : ''}${owner}%2F${project}/members/${userId}`)
|
|
20
20
|
.reply(200, { id: userId, username: owner, access_level: 30 });
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
options
|
|
25
|
-
) => nock(host, options).post(`/api/v4/projects/${owner}%2F${project}/releases`, body).reply(200, {});
|
|
22
|
+
export let interceptPublish = ({ host = 'https://gitlab.com', owner = 'user', project = 'repo', body } = {}, options) =>
|
|
23
|
+
nock(host, options).post(`/api/v4/projects/${owner}%2F${project}/releases`, body).reply(200, {});
|
|
26
24
|
|
|
27
|
-
|
|
25
|
+
export let interceptAsset = ({ host = 'https://gitlab.com', owner = 'user', project = 'repo' } = {}) =>
|
|
28
26
|
nock(host)
|
|
29
27
|
.post(`/api/v4/projects/${owner}%2F${project}/uploads`)
|
|
30
28
|
.query(true)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import Plugin from '../../lib/plugin/Plugin.js';
|
|
2
|
+
|
|
3
|
+
class ContextPlugin extends Plugin {
|
|
4
|
+
init() {
|
|
5
|
+
const context = this.config.getContext();
|
|
6
|
+
this.exec(`echo ${context.version.isPreRelease}`);
|
|
7
|
+
this.exec('echo ${version.isPreRelease}');
|
|
8
|
+
}
|
|
9
|
+
beforeBump() {
|
|
10
|
+
const context = this.config.getContext();
|
|
11
|
+
this.exec(`echo ${context.name} ${context.repo.owner} ${context.latestVersion} ${context.version}`);
|
|
12
|
+
this.exec('echo ${name} ${repo.owner} ${latestVersion} ${version}');
|
|
13
|
+
}
|
|
14
|
+
bump(version) {
|
|
15
|
+
const repo = this.config.getContext('repo');
|
|
16
|
+
this.exec(`echo ${repo.owner} ${repo.project} ${repo.repository} ${version}`);
|
|
17
|
+
this.exec('echo ${repo.owner} ${repo.project} ${repo.repository} ${version}');
|
|
18
|
+
}
|
|
19
|
+
beforeRelease() {
|
|
20
|
+
const { repo, tagName } = this.config.getContext();
|
|
21
|
+
this.exec(`echo ${repo.owner} ${repo.project} ${repo.repository} ${tagName}`);
|
|
22
|
+
this.exec('echo ${repo.owner} ${repo.project} ${repo.repository} ${tagName}');
|
|
23
|
+
}
|
|
24
|
+
release() {
|
|
25
|
+
const { repo, latestVersion, version, tagName } = this.config.getContext();
|
|
26
|
+
this.exec(`echo ${repo.project} ${latestVersion} ${version} ${tagName}`);
|
|
27
|
+
this.exec('echo ${repo.project} ${latestVersion} ${version} ${tagName}');
|
|
28
|
+
}
|
|
29
|
+
afterRelease() {
|
|
30
|
+
const { repo, latestVersion, version, tagName } = this.config.getContext();
|
|
31
|
+
this.exec(`echo ${repo.project} ${latestVersion} ${version} ${tagName}`);
|
|
32
|
+
this.exec('echo ${repo.project} ${latestVersion} ${version} ${tagName}');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default ContextPlugin;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import Plugin from '../../lib/plugin/Plugin.js';
|
|
2
|
+
|
|
3
|
+
class MyPlugin extends Plugin {
|
|
4
|
+
init() {
|
|
5
|
+
this.log.info(`${this.namespace}:${this.getContext('name')}:init`);
|
|
6
|
+
}
|
|
7
|
+
getName() {
|
|
8
|
+
this.log.info(`${this.namespace}:${this.getContext('name')}:getName`);
|
|
9
|
+
return 'new-project-name';
|
|
10
|
+
}
|
|
11
|
+
getLatestVersion() {
|
|
12
|
+
this.log.info(`${this.namespace}:${this.getContext('name')}:getLatestVersion`);
|
|
13
|
+
return '1.2.3';
|
|
14
|
+
}
|
|
15
|
+
getIncrement() {
|
|
16
|
+
this.log.info(`${this.namespace}:${this.getContext('name')}:getIncrement`);
|
|
17
|
+
return 'minor';
|
|
18
|
+
}
|
|
19
|
+
getIncrementedVersionCI() {
|
|
20
|
+
this.log.info(`${this.namespace}:${this.getContext('name')}:getIncrementedVersionCI`);
|
|
21
|
+
}
|
|
22
|
+
beforeBump() {
|
|
23
|
+
this.log.info(`${this.namespace}:${this.getContext('name')}:beforeBump`);
|
|
24
|
+
}
|
|
25
|
+
bump(version) {
|
|
26
|
+
this.log.info(`${this.namespace}:${this.getContext('name')}:bump:${version}`);
|
|
27
|
+
}
|
|
28
|
+
beforeRelease() {
|
|
29
|
+
this.log.info(`${this.namespace}:${this.getContext('name')}:beforeRelease`);
|
|
30
|
+
}
|
|
31
|
+
release() {
|
|
32
|
+
this.log.info(`${this.namespace}:${this.getContext('name')}:release`);
|
|
33
|
+
}
|
|
34
|
+
afterRelease() {
|
|
35
|
+
this.log.info(`${this.namespace}:${this.getContext('name')}:afterRelease`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default MyPlugin;
|
package/test/stub/shell.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import _debug from 'debug';
|
|
2
|
+
import Shell from '../../lib/shell.js';
|
|
3
|
+
|
|
4
|
+
const debug = _debug('release-it:shell-stub');
|
|
3
5
|
|
|
4
6
|
class ShellStub extends Shell {
|
|
5
7
|
exec(command) {
|
|
@@ -19,4 +21,4 @@ class ShellStub extends Shell {
|
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
export default ShellStub;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import test from 'ava';
|
|
3
|
+
import sh from 'shelljs';
|
|
4
|
+
import _ from 'lodash';
|
|
5
|
+
import sinon from 'sinon';
|
|
6
|
+
import Log from '../lib/log.js';
|
|
7
|
+
import Spinner from '../lib/spinner.js';
|
|
8
|
+
import Prompt from '../lib/prompt.js';
|
|
9
|
+
import Config from '../lib/config.js';
|
|
10
|
+
import runTasks from '../lib/index.js';
|
|
11
|
+
import { mkTmpDir, gitAdd } from './util/helpers.js';
|
|
12
|
+
import ShellStub from './stub/shell.js';
|
|
13
|
+
import { interceptPublish as interceptGitLabPublish } from './stub/gitlab.js';
|
|
14
|
+
import { interceptCreate as interceptGitHubCreate } from './stub/github.js';
|
|
15
15
|
|
|
16
16
|
const noop = Promise.resolve();
|
|
17
17
|
|
package/test/tasks.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import test from 'ava';
|
|
3
|
+
import sh from 'shelljs';
|
|
4
|
+
import _ from 'lodash';
|
|
5
|
+
import sinon from 'sinon';
|
|
6
|
+
import Log from '../lib/log.js';
|
|
7
|
+
import Spinner from '../lib/spinner.js';
|
|
8
|
+
import Config from '../lib/config.js';
|
|
9
|
+
import runTasks from '../lib/index.js';
|
|
10
|
+
import { mkTmpDir, gitAdd, getArgs } from './util/helpers.js';
|
|
11
|
+
import ShellStub from './stub/shell.js';
|
|
12
|
+
import {
|
|
13
|
+
interceptUser as interceptGitLabUser,
|
|
14
|
+
interceptCollaborator as interceptGitLabCollaborator,
|
|
15
|
+
interceptPublish as interceptGitLabPublish,
|
|
16
|
+
interceptAsset as interceptGitLabAsset
|
|
17
|
+
} from './stub/gitlab.js';
|
|
18
|
+
import {
|
|
19
|
+
interceptAuthentication as interceptGitHubAuthentication,
|
|
20
|
+
interceptCollaborator as interceptGitHubCollaborator,
|
|
21
|
+
interceptCreate as interceptGitHubCreate,
|
|
22
|
+
interceptAsset as interceptGitHubAsset
|
|
23
|
+
} from './stub/github.js';
|
|
24
|
+
|
|
25
|
+
const rootDir = new URL('..', import.meta.url);
|
|
26
26
|
|
|
27
27
|
const noop = Promise.resolve();
|
|
28
28
|
|
|
@@ -439,15 +439,12 @@ test.serial('should use custom changelog command with context', async t => {
|
|
|
439
439
|
});
|
|
440
440
|
|
|
441
441
|
{
|
|
442
|
-
class MyPlugin extends Plugin {}
|
|
443
|
-
const statics = { isEnabled: () => true, disablePlugin: () => null };
|
|
444
|
-
const options = { '@global': true, '@noCallThru': true };
|
|
445
|
-
const runTasks = proxyquire('../lib/tasks', {
|
|
446
|
-
'my-plugin': Object.assign(MyPlugin, statics, options)
|
|
447
|
-
});
|
|
448
|
-
|
|
449
442
|
test.serial('should run all hooks', async t => {
|
|
450
|
-
gitAdd(`{"name":"hooked","version":"1.0.0"}`, 'package.json', 'Add package.json');
|
|
443
|
+
gitAdd(`{"name":"hooked","version":"1.0.0","type":"module"}`, 'package.json', 'Add package.json');
|
|
444
|
+
sh.exec(`npm install ${rootDir}`);
|
|
445
|
+
const plugin = "import { Plugin } from 'release-it'; class MyPlugin extends Plugin {}; export default MyPlugin;";
|
|
446
|
+
sh.ShellString(plugin).toEnd('my-plugin.js');
|
|
447
|
+
|
|
451
448
|
const hooks = {};
|
|
452
449
|
['before', 'after'].forEach(prefix => {
|
|
453
450
|
['version', 'git', 'npm', 'my-plugin'].forEach(ns => {
|
|
@@ -457,7 +454,11 @@ test.serial('should use custom changelog command with context', async t => {
|
|
|
457
454
|
});
|
|
458
455
|
});
|
|
459
456
|
});
|
|
460
|
-
const container = getContainer({
|
|
457
|
+
const container = getContainer({
|
|
458
|
+
plugins: { './my-plugin.js': {} },
|
|
459
|
+
git: { requireCleanWorkingDir: false },
|
|
460
|
+
hooks
|
|
461
|
+
});
|
|
461
462
|
const exec = sinon.spy(container.shell, 'execFormattedCommand');
|
|
462
463
|
|
|
463
464
|
await runTasks({}, container);
|