release-it 15.0.0-esm.4 → 15.0.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 +24 -19
- package/config/release-it.json +2 -0
- package/lib/config.js +7 -15
- package/lib/index.js +27 -33
- package/lib/log.js +1 -1
- package/lib/plugin/GitBase.js +1 -1
- package/lib/plugin/GitRelease.js +1 -1
- package/lib/plugin/Plugin.js +1 -1
- package/lib/plugin/factory.js +5 -5
- package/lib/plugin/git/Git.js +3 -2
- package/lib/plugin/github/GitHub.js +6 -5
- package/lib/plugin/gitlab/GitLab.js +68 -14
- package/lib/plugin/npm/npm.js +3 -2
- package/lib/shell.js +2 -2
- package/lib/util.js +2 -2
- package/package.json +23 -30
- package/test/config.js +19 -26
- package/test/git.init.js +32 -7
- package/test/git.js +5 -2
- package/test/github.js +14 -15
- package/test/gitlab.js +69 -18
- package/test/log.js +1 -1
- package/test/npm.js +12 -3
- package/test/plugins.js +33 -21
- package/test/spinner.js +1 -2
- 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 +2 -2
- package/test/stub/gitlab.js +15 -7
- package/test/stub/shell.js +2 -2
- package/test/tasks.interactive.js +2 -3
- package/test/tasks.js +3 -4
- package/test/util/helpers.js +6 -6
- package/test/util/index.js +2 -1
- package/test/utils.js +1 -1
- package/config/.codecov.yml +0 -5
- package/config/deprecated.json +0 -1
- package/lib/deprecated.js +0 -22
- package/lib/metrics.js +0 -76
- package/test/deprecated.js +0 -11
- package/test/metrics.js +0 -17
package/README.md
CHANGED
|
@@ -19,7 +19,11 @@ system, and hooks to execute any command you need to test, build, and/or publish
|
|
|
19
19
|
|
|
20
20
|
[](https://github.com/release-it/release-it/actions)
|
|
21
21
|
[](https://www.npmjs.com/package/release-it)
|
|
22
|
-
|
|
22
|
+
|
|
23
|
+
## Announcement
|
|
24
|
+
|
|
25
|
+
The latest major version is v15, supporting Node.js 14 and up (as Node.js v12 is EOL). Use release-it v14 for
|
|
26
|
+
environments running Node.js v10 and v12. Also see [CHANGELOG.md](./CHANGELOG.md).
|
|
23
27
|
|
|
24
28
|
## Links
|
|
25
29
|
|
|
@@ -157,7 +161,8 @@ remote.
|
|
|
157
161
|
## GitHub Releases
|
|
158
162
|
|
|
159
163
|
GitHub projects can have releases attached to Git tags, containing release notes and assets. There are two ways to add
|
|
160
|
-
[GitHub releases](https://
|
|
164
|
+
[GitHub releases](https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases) in your
|
|
165
|
+
release-it flow:
|
|
161
166
|
|
|
162
167
|
1. Automated (requires a `GITHUB_TOKEN`)
|
|
163
168
|
2. Manual (using the GitHub web interface with pre-populated fields)
|
|
@@ -256,7 +261,7 @@ will run one after another. Some example release-it configuration:
|
|
|
256
261
|
The variables can be found in the [default configuration](./config/release-it.json). Additionally, the following
|
|
257
262
|
variables are exposed:
|
|
258
263
|
|
|
259
|
-
```
|
|
264
|
+
```text
|
|
260
265
|
version
|
|
261
266
|
latestVersion
|
|
262
267
|
changelog
|
|
@@ -272,6 +277,14 @@ Use `--verbose` to log the output of the commands.
|
|
|
272
277
|
For the sake of verbosity, the full list of hooks is actually: `init`, `beforeBump`, `bump`, `beforeRelease`, `release`
|
|
273
278
|
or `afterRelease`. However, hooks like `before:beforeRelease` look weird and are usually not useful in practice.
|
|
274
279
|
|
|
280
|
+
Note that arguments need to be quoted properly when used from the command line:
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
release-it --'hooks.after:release="echo Successfully released ${name} v${version} to ${repo.repository}."'
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Using Inquirer.js inside custom hook scripts might cause issues (since release-it also uses this itself).
|
|
287
|
+
|
|
275
288
|
## Plugins
|
|
276
289
|
|
|
277
290
|
Since v11, release-it can be extended in many, many ways. Here are some plugins:
|
|
@@ -299,14 +312,13 @@ Deprecated. Please see [distribution repository](./docs/recipes/distribution-rep
|
|
|
299
312
|
|
|
300
313
|
## Metrics
|
|
301
314
|
|
|
302
|
-
|
|
303
|
-
[lib/metrics.js](./lib/metrics.js). Please consider to not opt-out: more data means more support for future development.
|
|
315
|
+
In release-it v15, anonymous metrics have been removed from the codebase and no data is sent or stored anywhere.
|
|
304
316
|
|
|
305
317
|
## Troubleshooting & debugging
|
|
306
318
|
|
|
307
319
|
- With `release-it --verbose` (or `-V`), release-it prints the output of every user-defined [hook](#hooks).
|
|
308
320
|
- With `release-it -VV`, release-it also prints the output of every internal command.
|
|
309
|
-
- Use `
|
|
321
|
+
- Use `NODE_DEBUG=release-it:* release-it [...]` to print configuration and more error details.
|
|
310
322
|
|
|
311
323
|
Use `verbose: 2` in a configuration file to have the equivalent of `-VV` on the command line.
|
|
312
324
|
|
|
@@ -320,29 +332,22 @@ While mostly used as a CLI tool, release-it can be used as a dependency to integ
|
|
|
320
332
|
- [antonmedv/fx](https://github.com/antonmedv/fx)
|
|
321
333
|
- [blockchain/blockchain-wallet-v4-frontend](https://github.com/blockchain/blockchain-wallet-v4-frontend)
|
|
322
334
|
- [callstack/linaria](https://github.com/callstack/linaria)
|
|
335
|
+
- [callstack/react-native-paper](https://github.com/callstack/react-native-paper)
|
|
323
336
|
- [ember-cli/ember-cli](https://github.com/ember-cli/ember-cli)
|
|
324
|
-
- [metalsmith/metalsmith](https://github.com/metalsmith/metalsmith)
|
|
325
|
-
- [react-native-paper](https://github.com/callstack/react-native-paper)
|
|
326
337
|
- [js-cookie/js-cookie](https://github.com/js-cookie/js-cookie)
|
|
327
|
-
- [
|
|
338
|
+
- [metalsmith/metalsmith](https://github.com/metalsmith/metalsmith)
|
|
328
339
|
- [mozilla/readability](https://github.com/mozilla/readability)
|
|
329
340
|
- [redis/node-redis](https://github.com/redis/node-redis)
|
|
341
|
+
- [saleor/saleor](https://github.com/saleor/saleor)
|
|
330
342
|
- [shipshapecode/shepherd](https://github.com/shipshapecode/shepherd)
|
|
343
|
+
- [StevenBlack/hosts](https://github.com/StevenBlack/hosts)
|
|
331
344
|
- [swagger-api/swagger-ui](https://github.com/swagger-api/swagger-ui) +
|
|
332
345
|
[swagger-editor](https://github.com/swagger-api/swagger-editor)
|
|
333
|
-
- [StevenBlack/hosts](https://github.com/StevenBlack/hosts)
|
|
334
346
|
- [tabler/tabler](https://github.com/tabler/tabler) + [tabler-icons](https://github.com/tabler/tabler-icons)
|
|
335
347
|
- [youzan/vant](https://github.com/youzan/vant)
|
|
336
348
|
- [Repositories that depend on release-it](https://github.com/release-it/release-it/network/dependents)
|
|
337
349
|
- GitHub search for [filename:.release-it.json](https://github.com/search?q=filename%3A.release-it.json)
|
|
338
350
|
|
|
339
|
-
##
|
|
351
|
+
## License
|
|
340
352
|
|
|
341
|
-
|
|
342
|
-
- [GitHub Help](https://docs.github.com) (→
|
|
343
|
-
[About Releases](https://docs.github.com/free-pro-team@latest/github/administering-a-repository/about-releases))
|
|
344
|
-
- [npm Blog: Publishing what you mean to publish](https://blog.npmjs.org/post/165769683050/publishing-what-you-mean-to-publish)
|
|
345
|
-
- [npm Documentation: package.json](https://docs.npmjs.com/cli/v6/configuring-npm/package-json)
|
|
346
|
-
- [Prereleases and npm](https://medium.com/@mbostock/prereleases-and-npm-e778fc5e2420)
|
|
347
|
-
- [Glob Primer (node-glob)](https://github.com/isaacs/node-glob#glob-primer) (release-it uses
|
|
348
|
-
[globby](https://github.com/sindresorhus/globby#readme))
|
|
353
|
+
[MIT](./LICENSE)
|
package/config/release-it.json
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"tag": null,
|
|
27
27
|
"otp": null,
|
|
28
28
|
"ignoreVersion": false,
|
|
29
|
+
"allowSameVersion": false,
|
|
29
30
|
"skipChecks": false,
|
|
30
31
|
"timeout": 10
|
|
31
32
|
},
|
|
@@ -48,6 +49,7 @@
|
|
|
48
49
|
"release": false,
|
|
49
50
|
"releaseName": "Release ${version}",
|
|
50
51
|
"releaseNotes": null,
|
|
52
|
+
"milestones": [],
|
|
51
53
|
"tokenRef": "GITLAB_TOKEN",
|
|
52
54
|
"tokenHeader": "Private-Token",
|
|
53
55
|
"certificateAuthorityFile": null,
|
package/lib/config.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
+
import util from 'node:util';
|
|
1
2
|
import { cosmiconfigSync } from 'cosmiconfig';
|
|
2
|
-
import parseJson from 'parse-json';
|
|
3
3
|
import parseToml from '@iarna/toml/parse-string.js';
|
|
4
|
-
import yaml from 'yaml';
|
|
5
4
|
import _ from 'lodash';
|
|
6
5
|
import isCI from 'is-ci';
|
|
7
|
-
import _debug from 'debug';
|
|
8
6
|
import { readJSON, getSystemInfo } from './util.js';
|
|
9
7
|
|
|
10
|
-
const debug =
|
|
8
|
+
const debug = util.debug('release-it:config');
|
|
11
9
|
const defaultConfig = readJSON(new URL('../config/release-it.json', import.meta.url));
|
|
12
10
|
|
|
13
11
|
const searchPlaces = [
|
|
@@ -21,19 +19,17 @@ const searchPlaces = [
|
|
|
21
19
|
];
|
|
22
20
|
|
|
23
21
|
const loaders = {
|
|
24
|
-
'.
|
|
25
|
-
'.toml': (_, content) => parseToml(content),
|
|
26
|
-
'.yaml': (_, content) => yaml.parse(content)
|
|
22
|
+
'.toml': (_, content) => parseToml(content)
|
|
27
23
|
};
|
|
28
24
|
|
|
29
|
-
const getLocalConfig =
|
|
25
|
+
const getLocalConfig = ({ file, dir = process.cwd() }) => {
|
|
30
26
|
let localConfig = {};
|
|
31
|
-
if (
|
|
27
|
+
if (file === false) return localConfig;
|
|
32
28
|
const explorer = cosmiconfigSync('release-it', {
|
|
33
29
|
searchPlaces,
|
|
34
30
|
loaders
|
|
35
31
|
});
|
|
36
|
-
const result =
|
|
32
|
+
const result = file ? explorer.load(file) : explorer.search(dir);
|
|
37
33
|
if (result && typeof result.config === 'string') {
|
|
38
34
|
throw new Error(`Invalid configuration file at ${result.filepath}`);
|
|
39
35
|
}
|
|
@@ -44,7 +40,7 @@ const getLocalConfig = localConfigFile => {
|
|
|
44
40
|
class Config {
|
|
45
41
|
constructor(config = {}) {
|
|
46
42
|
this.constructorConfig = config;
|
|
47
|
-
this.localConfig = getLocalConfig(config.config);
|
|
43
|
+
this.localConfig = getLocalConfig({ file: config.config, dir: config.configDir });
|
|
48
44
|
this.options = this.mergeOptions();
|
|
49
45
|
this.options = this.expandPreReleaseShorthand(this.options);
|
|
50
46
|
this.contextOptions = {};
|
|
@@ -123,10 +119,6 @@ class Config {
|
|
|
123
119
|
get isReleaseVersion() {
|
|
124
120
|
return Boolean(this.options['release-version']);
|
|
125
121
|
}
|
|
126
|
-
|
|
127
|
-
get isCollectMetrics() {
|
|
128
|
-
return !this.options['disable-metrics'];
|
|
129
|
-
}
|
|
130
122
|
}
|
|
131
123
|
|
|
132
124
|
export default Config;
|
package/lib/index.js
CHANGED
|
@@ -5,9 +5,7 @@ import Config from './config.js';
|
|
|
5
5
|
import Shell from './shell.js';
|
|
6
6
|
import Prompt from './prompt.js';
|
|
7
7
|
import Spinner from './spinner.js';
|
|
8
|
-
import Metrics from './metrics.js';
|
|
9
8
|
import { reduceUntil, parseVersion } from './util.js';
|
|
10
|
-
import handleDeprecated from './deprecated.js';
|
|
11
9
|
import Plugin from './plugin/Plugin.js';
|
|
12
10
|
|
|
13
11
|
const runTasks = async (opts, di) => {
|
|
@@ -23,14 +21,11 @@ const runTasks = async (opts, di) => {
|
|
|
23
21
|
container.log = container.log || new Logger({ isCI, isVerbose, verbosityLevel, isDryRun });
|
|
24
22
|
container.spinner = container.spinner || new Spinner({ container, config });
|
|
25
23
|
container.prompt = container.prompt || new Prompt({ container: { config } });
|
|
26
|
-
container.metrics = new Metrics({ isEnabled: config.isCollectMetrics });
|
|
27
24
|
container.shell = container.shell || new Shell({ container });
|
|
28
25
|
|
|
29
|
-
const { log,
|
|
26
|
+
const { log, shell, spinner } = container;
|
|
30
27
|
|
|
31
|
-
const options =
|
|
32
|
-
|
|
33
|
-
metrics.trackEvent('start', options);
|
|
28
|
+
const options = config.getContext();
|
|
34
29
|
|
|
35
30
|
const { hooks } = options;
|
|
36
31
|
|
|
@@ -78,47 +73,49 @@ const runTasks = async (opts, di) => {
|
|
|
78
73
|
version = latestVersion;
|
|
79
74
|
}
|
|
80
75
|
|
|
81
|
-
if (config.isReleaseVersion) {
|
|
82
|
-
log.log(version);
|
|
83
|
-
process.exit(0);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
76
|
config.setContext({ name, latestVersion, version, changelog });
|
|
87
77
|
|
|
88
78
|
const action = config.isIncrement ? 'release' : 'update';
|
|
89
79
|
const suffix = version && config.isIncrement ? `${latestVersion}...${version}` : `currently at ${latestVersion}`;
|
|
90
80
|
|
|
91
|
-
|
|
81
|
+
if (!config.isReleaseVersion) {
|
|
82
|
+
log.obtrusive(`🚀 Let's ${action} ${name} (${suffix})`);
|
|
92
83
|
|
|
93
|
-
|
|
84
|
+
log.preview({ title: 'changelog', text: changelog });
|
|
85
|
+
}
|
|
94
86
|
|
|
95
87
|
if (config.isIncrement) {
|
|
96
88
|
version = version || (await reduceUntil(plugins, plugin => plugin.getIncrementedVersion(incrementBase)));
|
|
97
89
|
}
|
|
98
90
|
|
|
99
|
-
config.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
config.setCI(true);
|
|
91
|
+
if (config.isReleaseVersion) {
|
|
92
|
+
console.log(version);
|
|
93
|
+
process.exit(0);
|
|
103
94
|
}
|
|
104
95
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
96
|
+
if (version) {
|
|
97
|
+
config.setContext(parseVersion(version));
|
|
98
|
+
|
|
99
|
+
if (config.isPromptOnlyVersion) {
|
|
100
|
+
config.setCI(true);
|
|
109
101
|
}
|
|
110
|
-
}
|
|
111
102
|
|
|
112
|
-
|
|
103
|
+
for (const hook of ['beforeBump', 'bump', 'beforeRelease']) {
|
|
104
|
+
for (const plugin of plugins) {
|
|
105
|
+
const args = hook === 'bump' ? [version] : [];
|
|
106
|
+
await runLifeCycleHook(plugin, hook, ...args);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
113
109
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
110
|
+
plugins = [...internal, ...external];
|
|
111
|
+
|
|
112
|
+
for (const hook of ['release', 'afterRelease']) {
|
|
113
|
+
for (const plugin of plugins) {
|
|
114
|
+
await runLifeCycleHook(plugin, hook);
|
|
115
|
+
}
|
|
117
116
|
}
|
|
118
117
|
}
|
|
119
118
|
|
|
120
|
-
await metrics.trackEvent('end');
|
|
121
|
-
|
|
122
119
|
log.log(`🏁 Done (in ${Math.floor(process.uptime())}s.)`);
|
|
123
120
|
|
|
124
121
|
return {
|
|
@@ -128,10 +125,7 @@ const runTasks = async (opts, di) => {
|
|
|
128
125
|
version
|
|
129
126
|
};
|
|
130
127
|
} catch (err) {
|
|
131
|
-
const { log
|
|
132
|
-
if (metrics) {
|
|
133
|
-
await metrics.trackException(err);
|
|
134
|
-
}
|
|
128
|
+
const { log } = container;
|
|
135
129
|
log ? log.error(err.message || err) : console.error(err); // eslint-disable-line no-console
|
|
136
130
|
throw err;
|
|
137
131
|
}
|
package/lib/log.js
CHANGED
package/lib/plugin/GitBase.js
CHANGED
package/lib/plugin/GitRelease.js
CHANGED
|
@@ -12,7 +12,7 @@ class GitRelease extends GitBase {
|
|
|
12
12
|
getInitialOptions(options) {
|
|
13
13
|
const baseOptions = super.getInitialOptions(...arguments);
|
|
14
14
|
const git = options.git || defaultConfig.git;
|
|
15
|
-
const gitOptions = _.pick(git, ['tagName', 'pushRepo', 'changelog']);
|
|
15
|
+
const gitOptions = _.pick(git, ['tagName', 'tagMatch', 'pushRepo', 'changelog']);
|
|
16
16
|
return _.defaults(baseOptions, gitOptions);
|
|
17
17
|
}
|
|
18
18
|
|
package/lib/plugin/Plugin.js
CHANGED
package/lib/plugin/factory.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import url from 'url';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import
|
|
1
|
+
import url from 'node:url';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import util from 'node:util';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
4
5
|
import _ from 'lodash';
|
|
5
|
-
import _debug from 'debug';
|
|
6
6
|
import Version from './version/Version.js';
|
|
7
7
|
import Git from './git/Git.js';
|
|
8
8
|
import GitLab from './gitlab/GitLab.js';
|
|
9
9
|
import GitHub from './github/GitHub.js';
|
|
10
10
|
import npm from './npm/npm.js';
|
|
11
11
|
|
|
12
|
-
const debug =
|
|
12
|
+
const debug = util.debug('release-it:plugins');
|
|
13
13
|
|
|
14
14
|
const pluginNames = ['npm', 'git', 'github', 'gitlab', 'version'];
|
|
15
15
|
|
package/lib/plugin/git/Git.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { EOL } from 'os';
|
|
1
|
+
import { EOL } from 'node:os';
|
|
2
2
|
import _ from 'lodash';
|
|
3
3
|
import { execa } from 'execa';
|
|
4
|
+
import matcher from 'wildcard-match';
|
|
4
5
|
import { format, e } from '../../util.js';
|
|
5
6
|
import GitBase from '../GitBase.js';
|
|
6
7
|
import prompts from './prompts.js';
|
|
@@ -94,7 +95,7 @@ class Git extends GitBase {
|
|
|
94
95
|
async isRequiredBranch() {
|
|
95
96
|
const branch = await this.getBranchName();
|
|
96
97
|
const requiredBranches = _.castArray(this.options.requireBranch);
|
|
97
|
-
return requiredBranches
|
|
98
|
+
return matcher(requiredBranches)(branch);
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
async hasUpstreamBranch() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
3
|
import open from 'open';
|
|
4
4
|
import { Octokit } from '@octokit/rest';
|
|
5
5
|
import { globby } from 'globby';
|
|
@@ -7,6 +7,7 @@ import mime from 'mime-types';
|
|
|
7
7
|
import _ from 'lodash';
|
|
8
8
|
import retry from 'async-retry';
|
|
9
9
|
import newGithubReleaseUrl from 'new-github-release-url';
|
|
10
|
+
import ProxyAgent from 'proxy-agent';
|
|
10
11
|
import { format, parseVersion, readJSON, e } from '../../util.js';
|
|
11
12
|
import Release from '../GitRelease.js';
|
|
12
13
|
import prompts from './prompts.js';
|
|
@@ -168,7 +169,7 @@ class GitHub extends Release {
|
|
|
168
169
|
};
|
|
169
170
|
|
|
170
171
|
if (proxy) {
|
|
171
|
-
options.
|
|
172
|
+
options.request.agent = new ProxyAgent(proxy);
|
|
172
173
|
}
|
|
173
174
|
|
|
174
175
|
const client = new Octokit(options);
|
|
@@ -194,10 +195,10 @@ class GitHub extends Release {
|
|
|
194
195
|
const { owner, project: repo } = this.getContext('repo');
|
|
195
196
|
const { releaseName, draft = false, preRelease = false, autoGenerate = false } = this.options;
|
|
196
197
|
const { tagName } = this.config.getContext();
|
|
197
|
-
const { version, releaseNotes } = this.getContext();
|
|
198
|
+
const { version, releaseNotes, isUpdate } = this.getContext();
|
|
198
199
|
const { isPreRelease } = parseVersion(version);
|
|
199
200
|
const name = format(releaseName, this.config.getContext());
|
|
200
|
-
const body = autoGenerate ? '' : releaseNotes
|
|
201
|
+
const body = autoGenerate ? (isUpdate ? null : '') : releaseNotes;
|
|
201
202
|
|
|
202
203
|
return Object.assign(options, {
|
|
203
204
|
owner,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
3
|
import got from 'got';
|
|
4
4
|
import { globby } from 'globby';
|
|
5
5
|
import FormData from 'form-data';
|
|
6
|
+
import allSettled from 'promise.allsettled';
|
|
6
7
|
import _ from 'lodash';
|
|
7
8
|
import Release from '../GitRelease.js';
|
|
8
9
|
import { format, e } from '../../util.js';
|
|
@@ -91,20 +92,68 @@ class GitLab extends Release {
|
|
|
91
92
|
return access_level && access_level >= 30;
|
|
92
93
|
} catch (err) {
|
|
93
94
|
this.debug(err);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async beforeRelease() {
|
|
100
|
+
await super.beforeRelease();
|
|
101
|
+
await this.checkReleaseMilestones();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async checkReleaseMilestones() {
|
|
105
|
+
if (this.options.skipChecks) return;
|
|
106
|
+
|
|
107
|
+
const releaseMilestones = this.getReleaseMilestones();
|
|
108
|
+
if (releaseMilestones.length < 1) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
this.log.exec(`gitlab releases#checkReleaseMilestones`);
|
|
113
|
+
|
|
114
|
+
const { id } = this.getContext();
|
|
115
|
+
const endpoint = `projects/${id}/milestones`;
|
|
116
|
+
const requests = releaseMilestones.map(milestone => {
|
|
117
|
+
const options = {
|
|
118
|
+
method: 'GET',
|
|
119
|
+
searchParams: {
|
|
120
|
+
title: milestone,
|
|
121
|
+
include_parent_milestones: true
|
|
103
122
|
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
123
|
+
};
|
|
124
|
+
return this.request(endpoint, options).then(response => {
|
|
125
|
+
if (!Array.isArray(response)) {
|
|
126
|
+
const { baseUrl } = this.getContext();
|
|
127
|
+
throw new Error(
|
|
128
|
+
`Unexpected response from ${baseUrl}/${endpoint}. Expected an array but got: ${JSON.stringify(response)}`
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
if (response.length === 0) {
|
|
132
|
+
const error = new Error(`Milestone '${milestone}' does not exist.`);
|
|
133
|
+
this.log.warn(error.message);
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
this.log.verbose(`gitlab releases#checkReleaseMilestones: milestone '${milestone}' exists`);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
try {
|
|
140
|
+
await allSettled(requests).then(results => {
|
|
141
|
+
for (const result of results) {
|
|
142
|
+
if (result.status === 'rejected') {
|
|
143
|
+
throw e('Missing one or more milestones in GitLab. Creating a GitLab release will fail.', docs);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
} catch (err) {
|
|
148
|
+
this.debug(err);
|
|
149
|
+
throw err;
|
|
107
150
|
}
|
|
151
|
+
this.log.verbose('gitlab releases#checkReleaseMilestones: done');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
getReleaseMilestones() {
|
|
155
|
+
const { milestones } = this.options;
|
|
156
|
+
return (milestones || []).map(milestone => format(milestone, this.config.getContext()));
|
|
108
157
|
}
|
|
109
158
|
|
|
110
159
|
async release() {
|
|
@@ -138,6 +187,7 @@ class GitLab extends Release {
|
|
|
138
187
|
const name = format(releaseName, this.config.getContext());
|
|
139
188
|
const description = releaseNotes || '-';
|
|
140
189
|
const releaseUrl = `${origin}/${repo.repository}/-/releases`;
|
|
190
|
+
const releaseMilestones = this.getReleaseMilestones();
|
|
141
191
|
|
|
142
192
|
this.log.exec(`gitlab releases#createRelease "${name}" (${tagName})`, { isDryRun });
|
|
143
193
|
|
|
@@ -161,6 +211,10 @@ class GitLab extends Release {
|
|
|
161
211
|
};
|
|
162
212
|
}
|
|
163
213
|
|
|
214
|
+
if (releaseMilestones.length) {
|
|
215
|
+
options.json.milestones = releaseMilestones;
|
|
216
|
+
}
|
|
217
|
+
|
|
164
218
|
try {
|
|
165
219
|
await this.request(endpoint, options);
|
|
166
220
|
this.log.verbose('gitlab releases#createRelease: done');
|
package/lib/plugin/npm/npm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import path from 'path';
|
|
1
|
+
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';
|
|
@@ -82,7 +82,8 @@ class npm extends Plugin {
|
|
|
82
82
|
|
|
83
83
|
if (!this.config.isIncrement) return false;
|
|
84
84
|
|
|
85
|
-
const
|
|
85
|
+
const allowSameVersion = this.options.allowSameVersion ? ' --allow-same-version' : '';
|
|
86
|
+
const task = () => this.exec(`npm version ${version} --no-git-tag-version${allowSameVersion}`);
|
|
86
87
|
return this.spinner.show({ task, label: 'npm version' });
|
|
87
88
|
}
|
|
88
89
|
|
package/lib/shell.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import util from 'node:util';
|
|
1
2
|
import sh from 'shelljs';
|
|
2
3
|
import { execa } from 'execa';
|
|
3
|
-
import _debug from 'debug';
|
|
4
4
|
import { format } from './util.js';
|
|
5
5
|
|
|
6
|
-
const debug =
|
|
6
|
+
const debug = util.debug('release-it:shell');
|
|
7
7
|
|
|
8
8
|
sh.config.silent = !debug.enabled;
|
|
9
9
|
|
package/lib/util.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "release-it",
|
|
3
|
-
"version": "15.0.0
|
|
3
|
+
"version": "15.0.0",
|
|
4
4
|
"description": "Generic CLI tool to automate versioning and package publishing related tasks.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"build",
|
|
@@ -49,10 +49,7 @@
|
|
|
49
49
|
"scripts": {
|
|
50
50
|
"lint": "eslint lib test",
|
|
51
51
|
"format": "prettier --write \"{lib,test}/**/*.js\"",
|
|
52
|
-
"test": "ava --
|
|
53
|
-
"coverage": "nyc --reporter=lcov --reporter=html --config=config/.codecov.yml npm test",
|
|
54
|
-
"codecov": "nyc --reporter=json --config=config/.codecov.yml npm test && codecov -f coverage/coverage-final.json",
|
|
55
|
-
"readme": "markdown-toc README.md -i --maxdepth=2 --bullets=-",
|
|
52
|
+
"test": "ava --no-worker-threads",
|
|
56
53
|
"release": "./bin/release-it.js"
|
|
57
54
|
},
|
|
58
55
|
"author": {
|
|
@@ -64,51 +61,47 @@
|
|
|
64
61
|
"@iarna/toml": "2.2.5",
|
|
65
62
|
"@octokit/rest": "18.12.0",
|
|
66
63
|
"async-retry": "1.3.3",
|
|
67
|
-
"chalk": "
|
|
64
|
+
"chalk": "5.0.1",
|
|
68
65
|
"cosmiconfig": "7.0.1",
|
|
69
|
-
"
|
|
70
|
-
"deprecated-obj": "2.0.0",
|
|
71
|
-
"execa": "6.0.0",
|
|
66
|
+
"execa": "6.1.0",
|
|
72
67
|
"form-data": "4.0.0",
|
|
73
68
|
"git-url-parse": "11.6.0",
|
|
74
|
-
"globby": "
|
|
75
|
-
"got": "
|
|
76
|
-
"inquirer": "8.2.
|
|
69
|
+
"globby": "13.1.1",
|
|
70
|
+
"got": "12.0.4",
|
|
71
|
+
"inquirer": "8.2.4",
|
|
77
72
|
"is-ci": "3.0.1",
|
|
78
73
|
"lodash": "4.17.21",
|
|
79
|
-
"mime-types": "2.1.
|
|
74
|
+
"mime-types": "2.1.35",
|
|
80
75
|
"new-github-release-url": "2.0.0",
|
|
81
76
|
"open": "8.4.0",
|
|
82
|
-
"ora": "6.0
|
|
77
|
+
"ora": "6.1.0",
|
|
83
78
|
"os-name": "5.0.1",
|
|
84
|
-
"
|
|
85
|
-
"
|
|
79
|
+
"promise.allsettled": "1.0.5",
|
|
80
|
+
"proxy-agent": "5.0.0",
|
|
81
|
+
"semver": "7.3.7",
|
|
86
82
|
"shelljs": "0.8.5",
|
|
87
83
|
"update-notifier": "5.1.0",
|
|
88
|
-
"url-join": "
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"yargs-parser": "21.0.0"
|
|
84
|
+
"url-join": "5.0.0",
|
|
85
|
+
"wildcard-match": "5.1.2",
|
|
86
|
+
"yargs-parser": "21.0.1"
|
|
92
87
|
},
|
|
93
88
|
"devDependencies": {
|
|
94
89
|
"@octokit/request-error": "2.1.0",
|
|
95
|
-
"ava": "
|
|
96
|
-
"
|
|
97
|
-
"eslint": "8.
|
|
98
|
-
"eslint-config-prettier": "8.3.0",
|
|
90
|
+
"ava": "4.2.0",
|
|
91
|
+
"eslint": "8.14.0",
|
|
92
|
+
"eslint-config-prettier": "8.5.0",
|
|
99
93
|
"eslint-plugin-ava": "13.2.0",
|
|
100
|
-
"eslint-plugin-import": "2.
|
|
94
|
+
"eslint-plugin-import": "2.26.0",
|
|
101
95
|
"eslint-plugin-prettier": "4.0.0",
|
|
102
|
-
"markdown-toc": "1.2.0",
|
|
103
96
|
"mock-fs": "5.1.2",
|
|
104
97
|
"mock-stdio": "1.0.3",
|
|
105
|
-
"nock": "13.2.
|
|
98
|
+
"nock": "13.2.4",
|
|
106
99
|
"nyc": "15.1.0",
|
|
107
|
-
"prettier": "2.
|
|
108
|
-
"sinon": "
|
|
100
|
+
"prettier": "2.6.2",
|
|
101
|
+
"sinon": "13.0.2",
|
|
109
102
|
"strip-ansi": "7.0.1"
|
|
110
103
|
},
|
|
111
104
|
"engines": {
|
|
112
|
-
"node": "
|
|
105
|
+
"node": ">=14.9"
|
|
113
106
|
}
|
|
114
107
|
}
|