release-it 15.0.0-esm.2 → 15.0.0-esm.5
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 +22 -16
- package/config/release-it.json +5 -1
- package/lib/config.js +7 -15
- package/lib/index.js +13 -21
- package/lib/log.js +1 -1
- package/lib/plugin/GitBase.js +2 -2
- 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 +11 -4
- package/lib/plugin/github/GitHub.js +59 -15
- package/lib/plugin/gitlab/GitLab.js +69 -15
- package/lib/plugin/npm/npm.js +3 -2
- package/lib/plugin/version/Version.js +5 -5
- package/lib/shell.js +3 -3
- package/lib/spinner.js +3 -3
- package/lib/util.js +2 -2
- package/package.json +36 -42
- package/test/config.js +21 -28
- package/test/git.init.js +32 -7
- package/test/git.js +5 -2
- package/test/github.js +116 -19
- package/test/gitlab.js +69 -18
- package/test/log.js +1 -1
- package/test/npm.js +12 -3
- package/test/plugins.js +34 -22
- package/test/spinner.js +8 -11
- 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 +26 -10
- 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 +44 -4
- package/test/util/helpers.js +6 -6
- package/test/util/index.js +13 -18
- package/test/utils.js +1 -1
- package/test/version.js +14 -9
- 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/test/util/index.js
CHANGED
|
@@ -30,23 +30,14 @@ export let factory = (Definition, { namespace, options = {}, container = {} } =
|
|
|
30
30
|
});
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
const getIncrement =
|
|
34
|
-
|
|
35
|
-
plugin.getIncrement({
|
|
36
|
-
latestVersion,
|
|
37
|
-
increment: plugin.options.increment,
|
|
38
|
-
isPreRelease: false,
|
|
39
|
-
preReleaseId: null
|
|
40
|
-
}) ||
|
|
41
|
-
plugin.getContext('increment') ||
|
|
42
|
-
plugin.config.getContext('increment')
|
|
43
|
-
);
|
|
44
|
-
};
|
|
33
|
+
const getIncrement = plugin =>
|
|
34
|
+
plugin.getIncrement(plugin.options) || plugin.getContext('increment') || plugin.config.getContext('increment');
|
|
45
35
|
|
|
46
|
-
const getVersion = async (plugin,
|
|
36
|
+
const getVersion = async (plugin, options) => {
|
|
37
|
+
const { latestVersion, increment } = options;
|
|
47
38
|
return (
|
|
48
|
-
(await plugin.getIncrementedVersionCI(
|
|
49
|
-
(await plugin.getIncrementedVersion(
|
|
39
|
+
(await plugin.getIncrementedVersionCI(options)) ||
|
|
40
|
+
(await plugin.getIncrementedVersion(options)) ||
|
|
50
41
|
(increment !== false ? semver.inc(latestVersion, increment || 'patch') : latestVersion)
|
|
51
42
|
);
|
|
52
43
|
};
|
|
@@ -56,12 +47,16 @@ export let runTasks = async plugin => {
|
|
|
56
47
|
|
|
57
48
|
const name = (await plugin.getName()) || '__test__';
|
|
58
49
|
const latestVersion = (await plugin.getLatestVersion()) || '1.0.0';
|
|
50
|
+
const latestTag = plugin.config.getContext('latestTag');
|
|
59
51
|
const changelog = (await plugin.getChangelog(latestVersion)) || null;
|
|
60
|
-
const increment = getIncrement(plugin
|
|
52
|
+
const increment = getIncrement(plugin);
|
|
61
53
|
|
|
62
|
-
plugin.config.setContext({ name, latestVersion, latestTag
|
|
54
|
+
plugin.config.setContext({ name, latestVersion, latestTag, changelog });
|
|
63
55
|
|
|
64
|
-
const
|
|
56
|
+
const { preRelease } = plugin.config.options;
|
|
57
|
+
const isPreRelease = Boolean(preRelease);
|
|
58
|
+
const preReleaseId = typeof preRelease === 'string' ? preRelease : null;
|
|
59
|
+
const version = await getVersion(plugin, { latestVersion, increment, isPreRelease, preReleaseId });
|
|
65
60
|
|
|
66
61
|
plugin.config.setContext(parseVersion(version));
|
|
67
62
|
|
package/test/utils.js
CHANGED
package/test/version.js
CHANGED
|
@@ -148,21 +148,26 @@ test('should run tasks without errors', async t => {
|
|
|
148
148
|
await runTasks(v);
|
|
149
149
|
|
|
150
150
|
t.is(getIncrement.callCount, 1);
|
|
151
|
-
t.deepEqual(getIncrement.firstCall.args[0], {
|
|
152
|
-
|
|
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',
|
|
153
155
|
increment: 'minor',
|
|
154
156
|
isPreRelease: false,
|
|
155
157
|
preReleaseId: null
|
|
156
158
|
});
|
|
157
|
-
t.is(
|
|
158
|
-
t.deepEqual(getIncrementedVersionCI.firstCall.args[0], { latestVersion: '0.0.0', increment: 'minor' });
|
|
159
|
-
t.is(await incrementVersion.firstCall.returnValue, '0.1.0');
|
|
159
|
+
t.is(await incrementVersion.firstCall.returnValue, '1.1.0');
|
|
160
160
|
t.is(incrementVersion.callCount, 1);
|
|
161
|
-
t.deepEqual(incrementVersion.firstCall.args[0], {
|
|
162
|
-
|
|
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');
|
|
163
168
|
const { latestVersion, version, isPreRelease, preReleaseId } = v.config.getContext();
|
|
164
|
-
t.is(latestVersion, '
|
|
165
|
-
t.is(version, '
|
|
169
|
+
t.is(latestVersion, '1.0.0');
|
|
170
|
+
t.is(version, '1.1.0');
|
|
166
171
|
t.is(isPreRelease, false);
|
|
167
172
|
t.is(preReleaseId, null);
|
|
168
173
|
});
|
package/config/.codecov.yml
DELETED
package/config/deprecated.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|
package/lib/deprecated.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import Deprecated from 'deprecated-obj';
|
|
2
|
-
import { readJSON } from './util.js';
|
|
3
|
-
import Log from './log.js';
|
|
4
|
-
|
|
5
|
-
const deprecated = readJSON(new URL('../config/deprecated.json', import.meta.url));
|
|
6
|
-
|
|
7
|
-
export default (config, log = new Log()) => {
|
|
8
|
-
const deprecations = new Deprecated(deprecated, config);
|
|
9
|
-
const compliant = deprecations.getCompliant();
|
|
10
|
-
const violations = deprecations.getViolations();
|
|
11
|
-
if (Object.keys(violations).length > 0) {
|
|
12
|
-
log.warn(`Deprecated configuration options found. Please migrate before the next major release.`);
|
|
13
|
-
}
|
|
14
|
-
for (const d in violations) {
|
|
15
|
-
log.warn(
|
|
16
|
-
`The "${d}" option is deprecated. ${
|
|
17
|
-
violations[d] ? (/^[A-Z]/.test(violations[d]) ? violations[d] : `Please use "${violations[d]}" instead.`) : ''
|
|
18
|
-
}`
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
return compliant;
|
|
22
|
-
};
|
package/lib/metrics.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { EOL } from 'os';
|
|
2
|
-
import got from 'got';
|
|
3
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
4
|
-
import osName from 'os-name';
|
|
5
|
-
import isCi from 'is-ci';
|
|
6
|
-
import _debug from 'debug';
|
|
7
|
-
import { readJSON } from './util.js';
|
|
8
|
-
|
|
9
|
-
const debug = _debug('release-it:metrics');
|
|
10
|
-
const pkg = readJSON(new URL('../package.json', import.meta.url));
|
|
11
|
-
|
|
12
|
-
const noop = Promise.resolve();
|
|
13
|
-
|
|
14
|
-
const cast = value => (value ? 1 : 0);
|
|
15
|
-
|
|
16
|
-
const cid = uuidv4();
|
|
17
|
-
|
|
18
|
-
const payload = config => ({
|
|
19
|
-
v: 1,
|
|
20
|
-
tid: 'UA-108828841-1',
|
|
21
|
-
cid,
|
|
22
|
-
cd1: pkg.version,
|
|
23
|
-
cd2: process.version,
|
|
24
|
-
cd3: osName(),
|
|
25
|
-
cd4: cast(!config.isCI),
|
|
26
|
-
cd5: cast(config.isDryRun),
|
|
27
|
-
cd6: cast(config.isVerbose),
|
|
28
|
-
cd7: cast(config.isDebug),
|
|
29
|
-
cd8: null,
|
|
30
|
-
cd9: config.preReleaseId,
|
|
31
|
-
cd11: cast(isCi),
|
|
32
|
-
cd12: cast(config.git.tag),
|
|
33
|
-
cd13: cast(config.npm.publish),
|
|
34
|
-
cd14: cast(config.github.release),
|
|
35
|
-
cd15: config.increment,
|
|
36
|
-
cd16: cast(config.gitlab.release)
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
class Metrics {
|
|
40
|
-
constructor({ isEnabled = true, request = got } = {}) {
|
|
41
|
-
this.isEnabled = isEnabled;
|
|
42
|
-
this.request = request;
|
|
43
|
-
}
|
|
44
|
-
send(payload) {
|
|
45
|
-
return !this.isEnabled
|
|
46
|
-
? noop
|
|
47
|
-
: this.request('http://www.google-analytics.com/collect', {
|
|
48
|
-
timeout: 300,
|
|
49
|
-
retries: 0,
|
|
50
|
-
method: 'POST',
|
|
51
|
-
form: payload
|
|
52
|
-
})
|
|
53
|
-
.then(res => {
|
|
54
|
-
const { url, statusCode, statusMessage } = res;
|
|
55
|
-
debug({ url, statusCode, statusMessage, payload: new URLSearchParams(payload).toString() });
|
|
56
|
-
})
|
|
57
|
-
.catch(debug);
|
|
58
|
-
}
|
|
59
|
-
trackEvent(action, config) {
|
|
60
|
-
return this.send(
|
|
61
|
-
Object.assign(config ? payload(config) : {}, {
|
|
62
|
-
t: 'event',
|
|
63
|
-
ec: 'session',
|
|
64
|
-
ea: action
|
|
65
|
-
})
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
trackException(err) {
|
|
69
|
-
return this.send({
|
|
70
|
-
t: 'exception',
|
|
71
|
-
exd: err.toString().split(EOL)[0]
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export default Metrics;
|
package/test/deprecated.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import test from 'ava';
|
|
2
|
-
import sinon from 'sinon';
|
|
3
|
-
import deprecated from '../lib/deprecated.js';
|
|
4
|
-
import Log from '../lib/log.js';
|
|
5
|
-
|
|
6
|
-
test('should show deprecation warnings and return compliant object', t => {
|
|
7
|
-
const log = sinon.createStubInstance(Log);
|
|
8
|
-
const config = deprecated({ keep: 1 }, log);
|
|
9
|
-
t.is(log.warn.callCount, 0);
|
|
10
|
-
t.deepEqual(config, { keep: 1 });
|
|
11
|
-
});
|
package/test/metrics.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import test from 'ava';
|
|
2
|
-
import sinon from 'sinon';
|
|
3
|
-
import Metrics from '../lib/metrics.js';
|
|
4
|
-
|
|
5
|
-
test('should send metrics', async t => {
|
|
6
|
-
const stub = sinon.stub().resolves();
|
|
7
|
-
const metrics = new Metrics({ request: stub });
|
|
8
|
-
await metrics.trackEvent('test');
|
|
9
|
-
t.true(stub.calledWithMatch(/google-analytics.com\/collect/, sinon.match.object));
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test('should not send metrics when disabled', async t => {
|
|
13
|
-
const stub = sinon.stub().resolves();
|
|
14
|
-
const metrics = new Metrics({ isEnabled: false, request: stub });
|
|
15
|
-
await metrics.trackEvent('test');
|
|
16
|
-
t.true(stub.notCalled);
|
|
17
|
-
});
|