release-it 15.1.2 → 15.2.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/README.md +10 -10
- package/lib/plugin/factory.js +9 -1
- package/lib/util.js +2 -2
- package/package.json +9 -8
- package/test/github.js +4 -4
- package/test/plugin-name.js +9 -0
- package/test/plugins.js +51 -0
- package/test/tasks.interactive.js +1 -1
package/README.md
CHANGED
|
@@ -297,16 +297,16 @@ Using Inquirer.js inside custom hook scripts might cause issues (since release-i
|
|
|
297
297
|
|
|
298
298
|
Since v11, release-it can be extended in many, many ways. Here are some plugins:
|
|
299
299
|
|
|
300
|
-
| Plugin
|
|
301
|
-
|
|
|
302
|
-
| [@release-it/bumper](https://github.com/release-it/bumper)
|
|
303
|
-
| [@release-it/conventional-changelog](https://github.com/release-it/conventional-changelog)
|
|
304
|
-
| [@release-it/keep-a-changelog](https://github.com/release-it/keep-a-changelog)
|
|
305
|
-
| [release-it-lerna-changelog](https://github.com/
|
|
306
|
-
| [release-it-
|
|
307
|
-
| [release-it-calver-plugin](https://github.com/casmith/release-it-calver-plugin)
|
|
308
|
-
| [@grupoboticario/news-fragments](https://github.com/grupoboticario/news-fragments)
|
|
309
|
-
| [@j-ulrich/release-it-regex-bumper](https://github.com/j-ulrich/release-it-regex-bumper)
|
|
300
|
+
| Plugin | Description |
|
|
301
|
+
| -------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
|
|
302
|
+
| [@release-it/bumper](https://github.com/release-it/bumper) | Read & write the version from/to any file |
|
|
303
|
+
| [@release-it/conventional-changelog](https://github.com/release-it/conventional-changelog) | Provides recommended bump, conventional-changelog, and updates `CHANGELOG.md` |
|
|
304
|
+
| [@release-it/keep-a-changelog](https://github.com/release-it/keep-a-changelog) | Maintain CHANGELOG.md using the Keep a Changelog standards |
|
|
305
|
+
| [@release-it-plugins/lerna-changelog](https://github.com/release-it-plugins/lerna-changelog) | Integrates lerna-changelog into the release-it pipeline |
|
|
306
|
+
| [@release-it-plugins/workspaces](https://github.com/release-it-plugins/workspaces) | Releases each of your projects configured workspaces |
|
|
307
|
+
| [release-it-calver-plugin](https://github.com/casmith/release-it-calver-plugin) | Enables Calendar Versioning (calver) with release-it |
|
|
308
|
+
| [@grupoboticario/news-fragments](https://github.com/grupoboticario/news-fragments) | An easy way to generate your changelog file |
|
|
309
|
+
| [@j-ulrich/release-it-regex-bumper](https://github.com/j-ulrich/release-it-regex-bumper) | Regular expression based version read/write plugin for release-it |
|
|
310
310
|
|
|
311
311
|
Internally, release-it uses its own plugin architecture (for Git, GitHub, GitLab, npm).
|
|
312
312
|
|
package/lib/plugin/factory.js
CHANGED
|
@@ -37,7 +37,15 @@ const load = async pluginName => {
|
|
|
37
37
|
plugin = module.default;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
return [
|
|
40
|
+
return [getPluginName(pluginName), plugin];
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const getPluginName = pluginName => {
|
|
44
|
+
if (pluginName.startsWith('.')) {
|
|
45
|
+
return path.parse(pluginName).name;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return pluginName;
|
|
41
49
|
};
|
|
42
50
|
|
|
43
51
|
export let getPlugins = async (config, container) => {
|
package/lib/util.js
CHANGED
|
@@ -48,10 +48,10 @@ const rejectAfter = (ms, error) =>
|
|
|
48
48
|
|
|
49
49
|
const parseGitUrl = remoteUrl => {
|
|
50
50
|
if (!remoteUrl) return { host: null, owner: null, project: null, protocol: null, remote: null, repository: null };
|
|
51
|
-
const normalizedUrl = (remoteUrl || '').replace(/\\/g, '/');
|
|
51
|
+
const normalizedUrl = (remoteUrl || '').replace(/^[A-Z]:/, '').replace(/\\/g, '/'); // Hacky workaround for file protocol in Windows
|
|
52
52
|
const parsedUrl = gitUrlParse(normalizedUrl);
|
|
53
53
|
const { resource: host, name: project, protocol, href: remote } = parsedUrl;
|
|
54
|
-
const owner = protocol === 'file' ? _.last(parsedUrl.owner.split('/')) : parsedUrl.owner;
|
|
54
|
+
const owner = protocol === 'file' ? _.last(parsedUrl.owner.split('/')) : parsedUrl.owner; // Fix owner for file protocol
|
|
55
55
|
const repository = `${owner}/${project}`;
|
|
56
56
|
return { host, owner, project, protocol, remote, repository };
|
|
57
57
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "release-it",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.2.0",
|
|
4
4
|
"description": "Generic CLI tool to automate versioning and package publishing related tasks.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"build",
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"type": "module",
|
|
39
39
|
"exports": {
|
|
40
40
|
".": "./lib/index.js",
|
|
41
|
-
"./
|
|
41
|
+
"./package.json": "./package.json",
|
|
42
|
+
"./test/util/index.js": "./test/util/index.js"
|
|
42
43
|
},
|
|
43
44
|
"files": [
|
|
44
45
|
"bin",
|
|
@@ -65,15 +66,15 @@
|
|
|
65
66
|
"cosmiconfig": "7.0.1",
|
|
66
67
|
"execa": "6.1.0",
|
|
67
68
|
"form-data": "4.0.0",
|
|
68
|
-
"git-url-parse": "
|
|
69
|
+
"git-url-parse": "12.0.0",
|
|
69
70
|
"globby": "13.1.2",
|
|
70
|
-
"got": "12.
|
|
71
|
-
"inquirer": "9.0.
|
|
71
|
+
"got": "12.2.0",
|
|
72
|
+
"inquirer": "9.0.2",
|
|
72
73
|
"is-ci": "3.0.1",
|
|
73
74
|
"lodash": "4.17.21",
|
|
74
75
|
"mime-types": "2.1.35",
|
|
75
76
|
"new-github-release-url": "2.0.0",
|
|
76
|
-
"node-fetch": "3.2.
|
|
77
|
+
"node-fetch": "3.2.9",
|
|
77
78
|
"open": "8.4.0",
|
|
78
79
|
"ora": "6.1.2",
|
|
79
80
|
"os-name": "5.0.1",
|
|
@@ -89,14 +90,14 @@
|
|
|
89
90
|
"devDependencies": {
|
|
90
91
|
"@octokit/request-error": "3.0.0",
|
|
91
92
|
"ava": "4.3.1",
|
|
92
|
-
"eslint": "8.
|
|
93
|
+
"eslint": "8.20.0",
|
|
93
94
|
"eslint-config-prettier": "8.5.0",
|
|
94
95
|
"eslint-plugin-ava": "13.2.0",
|
|
95
96
|
"eslint-plugin-import": "2.26.0",
|
|
96
97
|
"eslint-plugin-prettier": "4.2.1",
|
|
97
98
|
"mock-fs": "5.1.2",
|
|
98
99
|
"mock-stdio": "1.0.3",
|
|
99
|
-
"nock": "13.2.
|
|
100
|
+
"nock": "13.2.9",
|
|
100
101
|
"nyc": "15.1.0",
|
|
101
102
|
"prettier": "2.7.1",
|
|
102
103
|
"sinon": "14.0.0",
|
package/test/github.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from './stub/github.js';
|
|
14
14
|
|
|
15
15
|
const tokenRef = 'GITHUB_TOKEN';
|
|
16
|
-
const pushRepo = 'git://github.com
|
|
16
|
+
const pushRepo = 'git://github.com/user/repo';
|
|
17
17
|
const host = 'github.com';
|
|
18
18
|
const git = { changelog: '' };
|
|
19
19
|
const requestErrorOptions = { request: { url: '', headers: {} }, response: { headers: {} } };
|
|
@@ -198,7 +198,7 @@ test('should create new release for unreleased tag', async t => {
|
|
|
198
198
|
});
|
|
199
199
|
|
|
200
200
|
test('should release to enterprise host', async t => {
|
|
201
|
-
const options = { git, github: { tokenRef, pushRepo: 'git://github.example.org
|
|
201
|
+
const options = { git, github: { tokenRef, pushRepo: 'git://github.example.org/user/repo' } };
|
|
202
202
|
const github = factory(GitHub, { options });
|
|
203
203
|
const exec = sinon.stub(github.shell, 'exec').callThrough();
|
|
204
204
|
exec.withArgs('git remote get-url origin').resolves(`https://github.example.org/user/repo`);
|
|
@@ -227,7 +227,7 @@ test('should release to alternative host and proxy', async t => {
|
|
|
227
227
|
git,
|
|
228
228
|
github: {
|
|
229
229
|
tokenRef,
|
|
230
|
-
pushRepo: `git://custom.example.org
|
|
230
|
+
pushRepo: `git://custom.example.org/user/repo`,
|
|
231
231
|
host: 'custom.example.org',
|
|
232
232
|
proxy: 'http://proxy:8080'
|
|
233
233
|
}
|
|
@@ -402,7 +402,7 @@ test('should generate GitHub web release url for enterprise host', async t => {
|
|
|
402
402
|
const options = {
|
|
403
403
|
git,
|
|
404
404
|
github: {
|
|
405
|
-
pushRepo: 'git
|
|
405
|
+
pushRepo: 'git@custom.example.org:user/repo',
|
|
406
406
|
release: true,
|
|
407
407
|
web: true,
|
|
408
408
|
host: 'custom.example.org',
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import { getPluginName } from '../lib/plugin/factory.js';
|
|
3
|
+
|
|
4
|
+
test('pluginName can return correct name for variants', t => {
|
|
5
|
+
t.is(getPluginName('plain-plugin'), 'plain-plugin');
|
|
6
|
+
t.is(getPluginName('@some/scoped-plugin'), '@some/scoped-plugin');
|
|
7
|
+
t.is(getPluginName('@some/nested/scoped-plugin'), '@some/nested/scoped-plugin');
|
|
8
|
+
t.is(getPluginName('./relative-plugin.cjs'), 'relative-plugin');
|
|
9
|
+
});
|
package/test/plugins.js
CHANGED
|
@@ -121,6 +121,57 @@ test.serial('should instantiate plugins and execute all release-cycle methods',
|
|
|
121
121
|
});
|
|
122
122
|
});
|
|
123
123
|
|
|
124
|
+
test.serial('should instantiate plugins and execute all release-cycle methods for scoped plugins', async t => {
|
|
125
|
+
const { dir } = t.context;
|
|
126
|
+
|
|
127
|
+
const pluginDir = mkTmpDir();
|
|
128
|
+
sh.pushd('-q', pluginDir);
|
|
129
|
+
sh.ShellString(JSON.stringify({ name: '@scoped/my-plugin', version: '1.0.0', type: 'module' })).toEnd(
|
|
130
|
+
join(pluginDir, 'package.json')
|
|
131
|
+
);
|
|
132
|
+
sh.exec(`npm link release-it`);
|
|
133
|
+
const content = "import { Plugin } from 'release-it'; " + MyPlugin.toString() + '; export default MyPlugin;';
|
|
134
|
+
sh.ShellString(content).toEnd(join(pluginDir, 'index.js'));
|
|
135
|
+
|
|
136
|
+
sh.pushd('-q', dir);
|
|
137
|
+
sh.ShellString(JSON.stringify({ name: 'project', version: '1.0.0', type: 'module' })).toEnd(
|
|
138
|
+
join(dir, 'package.json')
|
|
139
|
+
);
|
|
140
|
+
sh.exec(`npm install ${pluginDir}`);
|
|
141
|
+
sh.exec(`npm link release-it`);
|
|
142
|
+
|
|
143
|
+
const config = {
|
|
144
|
+
plugins: {
|
|
145
|
+
'@scoped/my-plugin': {
|
|
146
|
+
name: 'foo'
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
const container = getContainer(config);
|
|
151
|
+
|
|
152
|
+
const result = await runTasks({}, container);
|
|
153
|
+
|
|
154
|
+
t.deepEqual(container.log.info.args, [
|
|
155
|
+
['@scoped/my-plugin:foo:init'],
|
|
156
|
+
['@scoped/my-plugin:foo:getName'],
|
|
157
|
+
['@scoped/my-plugin:foo:getLatestVersion'],
|
|
158
|
+
['@scoped/my-plugin:foo:getIncrement'],
|
|
159
|
+
['@scoped/my-plugin:foo:getIncrementedVersionCI'],
|
|
160
|
+
['@scoped/my-plugin:foo:beforeBump'],
|
|
161
|
+
['@scoped/my-plugin:foo:bump:1.3.0'],
|
|
162
|
+
['@scoped/my-plugin:foo:beforeRelease'],
|
|
163
|
+
['@scoped/my-plugin:foo:release'],
|
|
164
|
+
['@scoped/my-plugin:foo:afterRelease']
|
|
165
|
+
]);
|
|
166
|
+
|
|
167
|
+
t.deepEqual(result, {
|
|
168
|
+
changelog: undefined,
|
|
169
|
+
name: 'new-project-name',
|
|
170
|
+
latestVersion: '1.2.3',
|
|
171
|
+
version: '1.3.0'
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
|
|
124
175
|
test.serial('should disable core plugins', async t => {
|
|
125
176
|
const { dir } = t.context;
|
|
126
177
|
sh.ShellString(JSON.stringify({ name: 'project', version: '1.0.0' })).toEnd(join(dir, 'package.json'));
|