release-it 14.11.8 → 15.0.0-esm.3
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/bin/release-it.js +6 -4
- package/lib/cli.js +18 -4
- package/lib/config.js +12 -14
- package/lib/deprecated.js +6 -4
- package/lib/index.js +139 -13
- package/lib/log.js +6 -4
- package/lib/metrics.js +11 -8
- package/lib/plugin/GitBase.js +4 -4
- package/lib/plugin/GitRelease.js +6 -4
- package/lib/plugin/Plugin.js +3 -3
- package/lib/plugin/factory.js +26 -14
- package/lib/plugin/git/Git.js +7 -7
- package/lib/plugin/git/prompts.js +2 -2
- package/lib/plugin/github/GitHub.js +20 -15
- package/lib/plugin/github/prompts.js +2 -2
- package/lib/plugin/gitlab/GitLab.js +10 -10
- package/lib/plugin/gitlab/prompts.js +2 -2
- package/lib/plugin/npm/npm.js +8 -8
- package/lib/plugin/npm/prompts.js +1 -1
- package/lib/plugin/version/Version.js +4 -4
- package/lib/prompt.js +2 -2
- package/lib/shell.js +7 -5
- package/lib/spinner.js +5 -5
- package/lib/util.js +13 -9
- package/package.json +19 -17
- package/test/cli.js +6 -4
- package/test/config.js +7 -5
- package/test/deprecated.js +4 -4
- package/test/git.init.js +9 -7
- package/test/git.js +7 -7
- package/test/github.js +57 -15
- package/test/gitlab.js +7 -7
- package/test/log.js +5 -5
- package/test/metrics.js +3 -3
- package/test/npm.js +7 -9
- package/test/plugins.js +92 -117
- package/test/prompt.js +9 -9
- package/test/shell.js +6 -6
- package/test/spinner.js +11 -13
- package/test/stub/github.js +2 -2
- package/test/stub/gitlab.js +7 -9
- package/test/stub/plugin-context.js +36 -0
- package/test/stub/plugin-replace.js +9 -0
- package/test/stub/plugin.js +39 -0
- package/test/stub/shell.js +5 -3
- package/test/tasks.interactive.js +14 -14
- package/test/tasks.js +35 -34
- package/test/util/helpers.js +5 -10
- package/test/util/index.js +12 -12
- package/test/util/setup.js +2 -14
- package/test/utils.js +5 -5
- package/test/version.js +4 -4
- package/lib/tasks.js +0 -139
package/test/util/helpers.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import sh from 'shelljs';
|
|
4
|
+
import tmp from 'tmp';
|
|
5
5
|
|
|
6
6
|
const mkTmpDir = () => {
|
|
7
7
|
const dir = tmp.dirSync({ prefix: 'release-it-' });
|
|
@@ -21,9 +21,4 @@ const gitAdd = (content, file, message) => {
|
|
|
21
21
|
const getArgs = (args, prefix) =>
|
|
22
22
|
args.filter(args => typeof args[0] === 'string' && args[0].startsWith(prefix)).map(args => args[0].trim());
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
mkTmpDir,
|
|
26
|
-
readFile,
|
|
27
|
-
gitAdd,
|
|
28
|
-
getArgs
|
|
29
|
-
};
|
|
24
|
+
export { mkTmpDir, readFile, gitAdd, getArgs };
|
package/test/util/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import sinon from 'sinon';
|
|
3
|
+
import semver from 'semver';
|
|
4
|
+
import { parseVersion } from '../../lib/util.js';
|
|
5
|
+
import Log from '../../lib/log.js';
|
|
6
|
+
import Config from '../../lib/config.js';
|
|
7
|
+
import ShellStub from '../stub/shell.js';
|
|
8
|
+
import Spinner from '../../lib/spinner.js';
|
|
9
|
+
import Prompt from '../../lib/prompt.js';
|
|
10
|
+
|
|
11
|
+
export let factory = (Definition, { namespace, options = {}, container = {} } = {}) => {
|
|
12
12
|
_.defaults(options, { ci: true, verbose: false, 'dry-run': false, debug: false });
|
|
13
13
|
|
|
14
14
|
const ns = namespace || Definition.name.toLowerCase();
|
|
@@ -51,7 +51,7 @@ const getVersion = async (plugin, { latestVersion, increment }) => {
|
|
|
51
51
|
);
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
export let runTasks = async plugin => {
|
|
55
55
|
await plugin.init();
|
|
56
56
|
|
|
57
57
|
const name = (await plugin.getName()) || '__test__';
|
package/test/util/setup.js
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const test = require('ava');
|
|
1
|
+
import shelljs from 'shelljs';
|
|
2
|
+
import nock from 'nock';
|
|
4
3
|
|
|
5
4
|
shelljs.config.silent = true;
|
|
6
5
|
nock.disableNetConnect();
|
|
7
|
-
|
|
8
|
-
const { GITHUB_TOKEN, GITLAB_TOKEN, GITHUB_ACTIONS, GITHUB_ACTOR } = process.env;
|
|
9
|
-
|
|
10
|
-
process.env.GITHUB_TOKEN = process.env.GITLAB_TOKEN = 1;
|
|
11
|
-
|
|
12
|
-
test.after.always(() => {
|
|
13
|
-
process.env.GITHUB_TOKEN = GITHUB_TOKEN;
|
|
14
|
-
process.env.GITLAB_TOKEN = GITLAB_TOKEN;
|
|
15
|
-
process.env.GITHUB_ACTIONS = GITHUB_ACTIONS;
|
|
16
|
-
process.env.GITHUB_ACTOR = GITHUB_ACTOR;
|
|
17
|
-
});
|
package/test/utils.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { EOL } from 'os';
|
|
2
|
+
import test from 'ava';
|
|
3
|
+
import mockStdIo from 'mock-stdio';
|
|
4
|
+
import stripAnsi from 'strip-ansi';
|
|
5
|
+
import { format, truncateLines, parseGitUrl, parseVersion } from '../lib/util.js';
|
|
6
6
|
|
|
7
7
|
test('format', t => {
|
|
8
8
|
t.is(format('release v${version}', { version: '1.0.0' }), 'release v1.0.0');
|
package/test/version.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import sinon from 'sinon';
|
|
3
|
+
import Version from '../lib/plugin/version/Version.js';
|
|
4
|
+
import { factory, runTasks } from './util/index.js';
|
|
5
5
|
|
|
6
6
|
test('isValidVersion', t => {
|
|
7
7
|
const v = factory(Version);
|
package/lib/tasks.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
const _ = require('lodash');
|
|
2
|
-
const Factory = require('./plugin/factory');
|
|
3
|
-
const Logger = require('./log');
|
|
4
|
-
const Config = require('./config');
|
|
5
|
-
const Shell = require('./shell');
|
|
6
|
-
const Prompt = require('./prompt');
|
|
7
|
-
const Spinner = require('./spinner');
|
|
8
|
-
const Metrics = require('./metrics');
|
|
9
|
-
const { reduceUntil, parseVersion } = require('./util');
|
|
10
|
-
const handleDeprecated = require('./deprecated');
|
|
11
|
-
|
|
12
|
-
const runTasks = async (opts, di) => {
|
|
13
|
-
let container = {};
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
Object.assign(container, di);
|
|
17
|
-
container.config = container.config || new Config(opts);
|
|
18
|
-
|
|
19
|
-
const { config } = container;
|
|
20
|
-
const { isCI, isVerbose, verbosityLevel, isDryRun } = config;
|
|
21
|
-
|
|
22
|
-
container.log = container.log || new Logger({ isCI, isVerbose, verbosityLevel, isDryRun });
|
|
23
|
-
container.spinner = container.spinner || new Spinner({ container, config });
|
|
24
|
-
container.prompt = container.prompt || new Prompt({ container: { config } });
|
|
25
|
-
container.metrics = new Metrics({ isEnabled: config.isCollectMetrics });
|
|
26
|
-
container.shell = container.shell || new Shell({ container });
|
|
27
|
-
|
|
28
|
-
const { log, metrics, shell, spinner } = container;
|
|
29
|
-
|
|
30
|
-
const options = handleDeprecated(config.getContext(), log);
|
|
31
|
-
|
|
32
|
-
metrics.trackEvent('start', options);
|
|
33
|
-
|
|
34
|
-
const { hooks } = options;
|
|
35
|
-
|
|
36
|
-
const runHook = async (...name) => {
|
|
37
|
-
const scripts = hooks[name.join(':')];
|
|
38
|
-
if (!scripts || !scripts.length) return;
|
|
39
|
-
const context = config.getContext();
|
|
40
|
-
const external = true;
|
|
41
|
-
for (const script of _.castArray(scripts)) {
|
|
42
|
-
const task = () => shell.exec(script, { external }, context);
|
|
43
|
-
await spinner.show({ task, label: script, context, external });
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const runLifeCycleHook = async (plugin, name, ...args) => {
|
|
48
|
-
if (plugin === _.first(plugins)) await runHook('before', name);
|
|
49
|
-
await runHook('before', plugin.namespace, name);
|
|
50
|
-
const willHookRun = (await plugin[name](...args)) !== false;
|
|
51
|
-
if (willHookRun) {
|
|
52
|
-
await runHook('after', plugin.namespace, name);
|
|
53
|
-
}
|
|
54
|
-
if (plugin === _.last(plugins)) await runHook('after', name);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const [internal, external] = await Factory.getPlugins(config, container);
|
|
58
|
-
let plugins = [...external, ...internal];
|
|
59
|
-
|
|
60
|
-
for (const plugin of plugins) {
|
|
61
|
-
await runLifeCycleHook(plugin, 'init');
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const { increment, isPreRelease, preReleaseId } = options.version;
|
|
65
|
-
|
|
66
|
-
const name = await reduceUntil(plugins, plugin => plugin.getName());
|
|
67
|
-
const latestVersion = (await reduceUntil(plugins, plugin => plugin.getLatestVersion())) || '0.0.0';
|
|
68
|
-
const changelog = await reduceUntil(plugins, plugin => plugin.getChangelog(latestVersion));
|
|
69
|
-
|
|
70
|
-
const incrementBase = { latestVersion, increment, isPreRelease, preReleaseId };
|
|
71
|
-
|
|
72
|
-
let version;
|
|
73
|
-
if (config.isIncrement) {
|
|
74
|
-
incrementBase.increment = await reduceUntil(plugins, plugin => plugin.getIncrement(incrementBase));
|
|
75
|
-
version = await reduceUntil(plugins, plugin => plugin.getIncrementedVersionCI(incrementBase));
|
|
76
|
-
} else {
|
|
77
|
-
version = latestVersion;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (config.isReleaseVersion) {
|
|
81
|
-
log.log(version);
|
|
82
|
-
process.exit(0);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
config.setContext({ name, latestVersion, version, changelog });
|
|
86
|
-
|
|
87
|
-
const action = config.isIncrement ? 'release' : 'update';
|
|
88
|
-
const suffix = version && config.isIncrement ? `${latestVersion}...${version}` : `currently at ${latestVersion}`;
|
|
89
|
-
|
|
90
|
-
log.obtrusive(`🚀 Let's ${action} ${name} (${suffix})`);
|
|
91
|
-
|
|
92
|
-
log.preview({ title: 'changelog', text: changelog });
|
|
93
|
-
|
|
94
|
-
if (config.isIncrement) {
|
|
95
|
-
version = version || (await reduceUntil(plugins, plugin => plugin.getIncrementedVersion(incrementBase)));
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
config.setContext(parseVersion(version));
|
|
99
|
-
|
|
100
|
-
if (config.isPromptOnlyVersion) {
|
|
101
|
-
config.setCI(true);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
for (const hook of ['beforeBump', 'bump', 'beforeRelease']) {
|
|
105
|
-
for (const plugin of plugins) {
|
|
106
|
-
const args = hook === 'bump' ? [version] : [];
|
|
107
|
-
await runLifeCycleHook(plugin, hook, ...args);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
plugins = [...internal, ...external];
|
|
112
|
-
|
|
113
|
-
for (const hook of ['release', 'afterRelease']) {
|
|
114
|
-
for (const plugin of plugins) {
|
|
115
|
-
await runLifeCycleHook(plugin, hook);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
await metrics.trackEvent('end');
|
|
120
|
-
|
|
121
|
-
log.log(`🏁 Done (in ${Math.floor(process.uptime())}s.)`);
|
|
122
|
-
|
|
123
|
-
return {
|
|
124
|
-
name,
|
|
125
|
-
changelog,
|
|
126
|
-
latestVersion,
|
|
127
|
-
version
|
|
128
|
-
};
|
|
129
|
-
} catch (err) {
|
|
130
|
-
const { log, metrics } = container;
|
|
131
|
-
if (metrics) {
|
|
132
|
-
await metrics.trackException(err);
|
|
133
|
-
}
|
|
134
|
-
log ? log.error(err.message || err) : console.error(err); // eslint-disable-line no-console
|
|
135
|
-
throw err;
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
module.exports = runTasks;
|