release-it 15.0.0-esm.4 → 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 +12 -6
- package/config/release-it.json +2 -0
- package/lib/config.js +7 -15
- package/lib/index.js +12 -20
- 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/test/stub/gitlab.js
CHANGED
|
@@ -11,16 +11,24 @@ export let 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
|
-
export let
|
|
15
|
-
|
|
14
|
+
export let interceptPublish = ({ host = 'https://gitlab.com', owner = 'user', project = 'repo', body } = {}, options) =>
|
|
15
|
+
nock(host, options).post(`/api/v4/projects/${owner}%2F${project}/releases`, body).reply(200, {});
|
|
16
|
+
|
|
17
|
+
export let interceptMilestones = (
|
|
18
|
+
{ host = 'https://gitlab.com', owner = 'user', project = 'repo', query = {}, milestones = [] } = {},
|
|
16
19
|
options
|
|
17
20
|
) =>
|
|
18
21
|
nock(host, options)
|
|
19
|
-
.get(`/api/v4/projects/${
|
|
20
|
-
.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
.get(`/api/v4/projects/${owner}%2F${project}/milestones`)
|
|
23
|
+
.query(
|
|
24
|
+
Object.assign(
|
|
25
|
+
{
|
|
26
|
+
include_parent_milestones: true
|
|
27
|
+
},
|
|
28
|
+
query
|
|
29
|
+
)
|
|
30
|
+
)
|
|
31
|
+
.reply(200, JSON.stringify(milestones));
|
|
24
32
|
|
|
25
33
|
export let interceptAsset = ({ host = 'https://gitlab.com', owner = 'user', project = 'repo' } = {}) =>
|
|
26
34
|
nock(host)
|
package/test/stub/shell.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import path from 'path';
|
|
1
|
+
import path from 'node:path';
|
|
2
2
|
import test from 'ava';
|
|
3
3
|
import sh from 'shelljs';
|
|
4
4
|
import _ from 'lodash';
|
|
@@ -19,8 +19,7 @@ const sandbox = sinon.createSandbox();
|
|
|
19
19
|
|
|
20
20
|
const testConfig = {
|
|
21
21
|
ci: false,
|
|
22
|
-
config: false
|
|
23
|
-
'disable-metrics': true
|
|
22
|
+
config: false
|
|
24
23
|
};
|
|
25
24
|
|
|
26
25
|
const log = sandbox.createStubInstance(Log);
|
package/test/tasks.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import path from 'path';
|
|
1
|
+
import path from 'node:path';
|
|
2
2
|
import test from 'ava';
|
|
3
3
|
import sh from 'shelljs';
|
|
4
4
|
import _ from 'lodash';
|
|
@@ -30,8 +30,7 @@ const sandbox = sinon.createSandbox();
|
|
|
30
30
|
|
|
31
31
|
const testConfig = {
|
|
32
32
|
ci: true,
|
|
33
|
-
config: false
|
|
34
|
-
'disable-metrics': true
|
|
33
|
+
config: false
|
|
35
34
|
};
|
|
36
35
|
|
|
37
36
|
const log = sandbox.createStubInstance(Log);
|
|
@@ -358,7 +357,7 @@ test.serial('should initially publish non-private scoped npm package privately',
|
|
|
358
357
|
test.serial('should use pkg.publishConfig.registry', async t => {
|
|
359
358
|
const { target } = t.context;
|
|
360
359
|
const pkgName = path.basename(target);
|
|
361
|
-
const registry = 'https://my-registry.
|
|
360
|
+
const registry = 'https://my-registry.example.org';
|
|
362
361
|
|
|
363
362
|
gitAdd(
|
|
364
363
|
JSON.stringify({
|
package/test/util/helpers.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
3
4
|
import sh from 'shelljs';
|
|
4
|
-
import tmp from 'tmp';
|
|
5
5
|
|
|
6
6
|
const mkTmpDir = () => {
|
|
7
|
-
const dir =
|
|
8
|
-
return dir
|
|
7
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'release-it-'));
|
|
8
|
+
return dir;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
const readFile = file => fs.readFile(path.resolve(file), 'utf8');
|
|
11
|
+
const readFile = file => fs.promises.readFile(path.resolve(file), 'utf8');
|
|
12
12
|
|
|
13
13
|
const gitAdd = (content, file, message) => {
|
|
14
14
|
sh.ShellString(content).toEnd(file);
|
package/test/util/index.js
CHANGED
|
@@ -47,10 +47,11 @@ export let runTasks = async plugin => {
|
|
|
47
47
|
|
|
48
48
|
const name = (await plugin.getName()) || '__test__';
|
|
49
49
|
const latestVersion = (await plugin.getLatestVersion()) || '1.0.0';
|
|
50
|
+
const latestTag = plugin.config.getContext('latestTag');
|
|
50
51
|
const changelog = (await plugin.getChangelog(latestVersion)) || null;
|
|
51
52
|
const increment = getIncrement(plugin);
|
|
52
53
|
|
|
53
|
-
plugin.config.setContext({ name, latestVersion, latestTag
|
|
54
|
+
plugin.config.setContext({ name, latestVersion, latestTag, changelog });
|
|
54
55
|
|
|
55
56
|
const { preRelease } = plugin.config.options;
|
|
56
57
|
const isPreRelease = Boolean(preRelease);
|
package/test/utils.js
CHANGED
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
|
-
});
|