-
Notifications
You must be signed in to change notification settings - Fork 1
/
ump.js
76 lines (56 loc) · 1.79 KB
/
ump.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
'use strict';
import select from '@inquirer/select';
import confirm from '@inquirer/confirm';
import {utils, peach} from './lib/utils.js';
import {commands} from './lib/commands.js';
import {log} from './lib/log.js';
import {config} from './lib/config.js';
const sequence = [];
const runCommands = async function(sequence, options) {
try {
await peach(sequence, (command) => {
return command.cmd(options);
});
log.color('*** DONE! ***', 'green');
} catch (err) {
console.error(err);
utils.resetVersion(options);
}
};
const ump = async function(options) {
const opts = await utils.buildOptions(options);
if (opts.error) {
return;
}
log.bump(opts);
sequence.push(commands.updateVersion(opts));
if (opts.extras) {
sequence.push(commands.extras(opts));
}
// opts.inquire is set to true automatically for CLI usage
if (opts.publish && opts.inquire && config.pkgName.startsWith('@')) {
opts.publishFlags = {};
if (opts.access) {
config.publishPrompt.default = opts.access;
}
opts.publishFlags[config.publishPrompt.name] = await select(config.publishPrompt);
}
if (opts.release) {
// opts.dirty = commands.commitDirty(opts);
// gitPull needs to happen first, so we don't update files when we can't complete things
// The skipPull option is available if we are SURE we don't need to pull
sequence.unshift(commands.gitPull(opts));
sequence.push(commands.gitRelease(opts));
}
log.tasks(sequence);
// opts.inquire is set to true automatically for CLI usage
if (opts.inquire) {
const run = await confirm(config.confirmPrompt);
if (!run) {
console.log(sequence);
return log.color('\nHalted execution. Not bumping files.', 'red');
}
}
runCommands(sequence, opts);
};
export default ump;