release-it 15.1.4 → 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 +3 -2
- 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-plugins/lerna-changelog](https://github.com
|
|
306
|
-
| [@release-it-plugins/workspaces](https://github.com
|
|
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,6 +38,7 @@
|
|
|
38
38
|
"type": "module",
|
|
39
39
|
"exports": {
|
|
40
40
|
".": "./lib/index.js",
|
|
41
|
+
"./package.json": "./package.json",
|
|
41
42
|
"./test/util/index.js": "./test/util/index.js"
|
|
42
43
|
},
|
|
43
44
|
"files": [
|
|
@@ -67,7 +68,7 @@
|
|
|
67
68
|
"form-data": "4.0.0",
|
|
68
69
|
"git-url-parse": "12.0.0",
|
|
69
70
|
"globby": "13.1.2",
|
|
70
|
-
"got": "12.
|
|
71
|
+
"got": "12.2.0",
|
|
71
72
|
"inquirer": "9.0.2",
|
|
72
73
|
"is-ci": "3.0.1",
|
|
73
74
|
"lodash": "4.17.21",
|
|
@@ -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'));
|