ump 3.3.0 → 3.5.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 +6 -1
- package/eslint.config.mjs +9 -0
- package/lib/commands.js +11 -1
- package/lib/config.js +35 -26
- package/lib/utils.js +4 -3
- package/package.json +15 -14
- package/ump.js +10 -5
- package/.eslintrc.cjs +0 -6
package/README.md
CHANGED
|
@@ -21,12 +21,17 @@ For programmatic use (i.e. requiring it as a module in a node.js script), instal
|
|
|
21
21
|
* `-m`, `--message`: Message to be used for the commit and tag when `-r` or `-p` is set. Default: Release %s
|
|
22
22
|
* `-r`, `--release`: If set, runs `git add` and `git commit` for the bumped files and pushes a tagged release.
|
|
23
23
|
* `-p`, `--publish`: If set, automatically runs with the `--release` flag and then publishes the release to npm.
|
|
24
|
+
* `-a`, `--autostash`: Default: `true`. Whether to use the `--autostash` flag when running `git pull`
|
|
25
|
+
* `-x`, `--skip-pull`: If set, skips executing the initial git pull command during a release/publish task. USE WITH CAUTION.
|
|
26
|
+
* `-t`, `--tag-prefix`: Optional prefix for the version in git tag. (e.g. With `--message "Release %s" --tag-prefix version`, The tag might look like "version 1.2.3" and its commit message "Release version 1.2.3")
|
|
24
27
|
* `-d`, `--debug`: If set, ump will run in debug mode, outputting a json file instead of doing something
|
|
25
28
|
* `-h`, `--help`: Shows help information on the command line
|
|
26
29
|
|
|
27
30
|
## Module Usage
|
|
28
31
|
|
|
29
|
-
The only required option is `files`, which takes an array of files. All other options are the same as the command-line long-hand options
|
|
32
|
+
The only required option is `files`, which takes an array of files. All other options are the same as the command-line *long-hand* options — `message, release, publish, debug` (not `help`).
|
|
33
|
+
|
|
34
|
+
Note: Options can be written as either kebab case (`skip-pull`, `tag-prefix`) or camel case (`skipPull`, `tagPrefix`).
|
|
30
35
|
|
|
31
36
|
```js
|
|
32
37
|
import ump from 'ump';
|
package/lib/commands.js
CHANGED
|
@@ -27,6 +27,16 @@ const commands = {
|
|
|
27
27
|
gitPull: function gitPull(opts) {
|
|
28
28
|
// Need to pull before mucking with files, so we can stop it if git branch isn't clean.
|
|
29
29
|
// Otherwise files will be bumped and committed but not pushed and things will get messed up.
|
|
30
|
+
// However, if the user is SURE this task can be skipped, the option is available
|
|
31
|
+
|
|
32
|
+
if (opts.skipPull) {
|
|
33
|
+
return {
|
|
34
|
+
log: '',
|
|
35
|
+
cmd: function() {
|
|
36
|
+
log.color('SKIPPED git pull', 'yellow');
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
30
40
|
// **We can autostash on pull because we handle existence of uncommitted files later
|
|
31
41
|
const pull = opts.autostash ? 'git pull --autostash' : 'git pull';
|
|
32
42
|
|
|
@@ -105,7 +115,7 @@ const commands = {
|
|
|
105
115
|
|
|
106
116
|
gitRelease: function gitRelease(opts) {
|
|
107
117
|
const files = utils.getFiles(opts.files.concat(opts.extras || []));
|
|
108
|
-
const newVersion = opts.newVersion
|
|
118
|
+
const newVersion = `${opts.tagPrefix || ''}${opts.newVersion}`;
|
|
109
119
|
let msg = opts.message.replace('%s', newVersion);
|
|
110
120
|
|
|
111
121
|
msg = utils.escapeQuotes(msg);
|
package/lib/config.js
CHANGED
|
@@ -10,6 +10,7 @@ try {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const config = {
|
|
13
|
+
pkgName: pkg.name || '',
|
|
13
14
|
defaults: {
|
|
14
15
|
sourceFile: 'package.json',
|
|
15
16
|
message: 'Release %s',
|
|
@@ -17,6 +18,8 @@ const config = {
|
|
|
17
18
|
regexReplace: '(?:[0-9]+\\.){2}[0-9]+[0-9a-zA-Z\\-_\\+\\.]*',
|
|
18
19
|
regexFlags: 'g',
|
|
19
20
|
autostash: true,
|
|
21
|
+
skipPull: false,
|
|
22
|
+
tagPrefix: '',
|
|
20
23
|
},
|
|
21
24
|
|
|
22
25
|
messages: {
|
|
@@ -39,28 +42,22 @@ const config = {
|
|
|
39
42
|
'prepatch',
|
|
40
43
|
],
|
|
41
44
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
],
|
|
45
|
+
confirmPrompt: {
|
|
46
|
+
message: 'Are you sure you want to continue?',
|
|
47
|
+
name: 'run',
|
|
48
|
+
type: 'confirm',
|
|
49
|
+
},
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
{name: 'restricted'},
|
|
61
|
-
],
|
|
62
|
-
},
|
|
63
|
-
],
|
|
51
|
+
|
|
52
|
+
publishPrompt: {
|
|
53
|
+
name: 'access',
|
|
54
|
+
message: 'Is access public or restricted?',
|
|
55
|
+
default: 'public',
|
|
56
|
+
choices: [
|
|
57
|
+
'public',
|
|
58
|
+
'restricted',
|
|
59
|
+
],
|
|
60
|
+
},
|
|
64
61
|
};
|
|
65
62
|
|
|
66
63
|
Object.assign(config, {
|
|
@@ -89,17 +86,29 @@ Object.assign(config, {
|
|
|
89
86
|
description: 'If set, automatically runs with the `--release` flag and then publishes the release to npm.',
|
|
90
87
|
type: 'boolean',
|
|
91
88
|
},
|
|
92
|
-
d: {
|
|
93
|
-
alias: 'debug',
|
|
94
|
-
description: 'If set, ump will run in debug mode, outputting a json file instead of doing something',
|
|
95
|
-
type: 'boolean',
|
|
96
|
-
},
|
|
97
89
|
a: {
|
|
98
90
|
alias: 'autostash',
|
|
99
91
|
description: 'Whether to use the --autostash flag when running `git pull`',
|
|
100
92
|
type: 'boolean',
|
|
101
93
|
default: true,
|
|
102
94
|
},
|
|
95
|
+
x: {
|
|
96
|
+
alias: 'skip-pull',
|
|
97
|
+
description: 'If set, skips executing the initial git pull command during a release/publish task. USE WITH CAUTION.',
|
|
98
|
+
type: 'boolean',
|
|
99
|
+
default: false,
|
|
100
|
+
},
|
|
101
|
+
t: {
|
|
102
|
+
alias: 'tag-prefix',
|
|
103
|
+
description: 'Optional prefix for the version in git tag. (e.g. With `--message "Release %s" --tag-prefix version-`, The tag might look like "version-1.2.3" and its commit message "Release version-1.2.3"',
|
|
104
|
+
type: 'string',
|
|
105
|
+
default: '',
|
|
106
|
+
},
|
|
107
|
+
d: {
|
|
108
|
+
alias: 'debug',
|
|
109
|
+
description: 'If set, ump will run in debug mode, outputting a json file instead of doing something',
|
|
110
|
+
type: 'boolean',
|
|
111
|
+
},
|
|
103
112
|
extras: {
|
|
104
113
|
description: 'Array of objects. ONLY AVAILABLE VIA .umprc OR when using ump() AS MODULE. Props: file, prefix (optional regex string), replaced (optional regex string), flags (optional). See https://github.com/kswedberg/ump/blob/master/README.md for more info.',
|
|
105
114
|
},
|
package/lib/utils.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
import util from 'util';
|
|
6
|
-
import
|
|
6
|
+
import {globSync} from 'glob';
|
|
7
7
|
import chalk from 'chalk';
|
|
8
8
|
import rc from 'rc';
|
|
9
9
|
import semver from 'semver';
|
|
@@ -53,7 +53,7 @@ const utils = {
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
files.forEach((item) => {
|
|
56
|
-
const fileGlob =
|
|
56
|
+
const fileGlob = globSync(item.file || item, {
|
|
57
57
|
dot: true,
|
|
58
58
|
});
|
|
59
59
|
|
|
@@ -209,7 +209,8 @@ const utils = {
|
|
|
209
209
|
opts.files = utils.getFiles(opts.files);
|
|
210
210
|
opts.extraFiles = utils.getFiles(opts.extras || []);
|
|
211
211
|
opts.sourceFile = opts.files[0];
|
|
212
|
-
|
|
212
|
+
opts.skipPull = opts.skipPull || opts['skip-pull'];
|
|
213
|
+
opts.tagPrefix = opts.tagPrefix || opts['tag-prefix'];
|
|
213
214
|
// opts.publish always implies opts.release as well (git push && git push --tags)
|
|
214
215
|
if (opts.publish) {
|
|
215
216
|
opts.release = true;
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ump",
|
|
3
3
|
"title": "ump",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.5.0",
|
|
5
5
|
"description": "Bump without the B",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "npm run test:clean && npm run test:pre && npm run test:run",
|
|
8
8
|
"test:clean": "rm -rf ./test/testarea",
|
|
9
9
|
"test:pre": "npm run lint && mkdir -p \"./test/testarea\"",
|
|
10
10
|
"test:run": "node_modules/.bin/mocha --delay --reporter spec",
|
|
11
|
-
"lint": "eslint
|
|
11
|
+
"lint": "eslint *.js bin lib test"
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
@@ -28,22 +28,23 @@
|
|
|
28
28
|
"node": ">=14"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"
|
|
32
|
-
"
|
|
31
|
+
"@inquirer/confirm": "^5.0.0",
|
|
32
|
+
"@inquirer/select": "^4.0.0",
|
|
33
|
+
"chalk": "^5.3.0",
|
|
34
|
+
"fs-extra": "^11.2.0",
|
|
33
35
|
"git-config": "^0.0.7",
|
|
34
|
-
"glob": "^
|
|
35
|
-
"inquirer": "^9.1.4",
|
|
36
|
+
"glob": "^11.0.0",
|
|
36
37
|
"rc": "^1.2.8",
|
|
37
|
-
"semver": "^7.3
|
|
38
|
-
"update-notifier": "^
|
|
39
|
-
"yargs": "^17.
|
|
38
|
+
"semver": "^7.6.3",
|
|
39
|
+
"update-notifier": "^7.3.1",
|
|
40
|
+
"yargs": "^17.7.2"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
|
-
"@types/mocha": "^10.0.
|
|
43
|
-
"chai": "^
|
|
44
|
-
"eslint": "^
|
|
45
|
-
"eslint-config-kswedberg": "^
|
|
46
|
-
"mocha": "^
|
|
43
|
+
"@types/mocha": "^10.0.9",
|
|
44
|
+
"chai": "^5.1.1",
|
|
45
|
+
"eslint": "^9.13.0",
|
|
46
|
+
"eslint-config-kswedberg": "^7.1.0",
|
|
47
|
+
"mocha": "^10.7.3"
|
|
47
48
|
},
|
|
48
49
|
"license": "MIT"
|
|
49
50
|
}
|
package/ump.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import select from '@inquirer/select';
|
|
4
|
+
import confirm from '@inquirer/confirm';
|
|
4
5
|
|
|
5
6
|
import {utils, peach} from './lib/utils.js';
|
|
6
7
|
import {commands} from './lib/commands.js';
|
|
@@ -37,14 +38,18 @@ const ump = async function(options) {
|
|
|
37
38
|
sequence.push(commands.extras(opts));
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
|
|
40
42
|
// opts.inquire is set to true automatically for CLI usage
|
|
41
|
-
if (opts.publish && opts.inquire) {
|
|
42
|
-
opts.publishFlags =
|
|
43
|
+
if (opts.publish && opts.inquire && config.pkgName.startsWith('@')) {
|
|
44
|
+
opts.publishFlags = {};
|
|
45
|
+
opts.publishFlags[config.publishPrompt.name] = await select(config.publishPrompt);
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
if (opts.release) {
|
|
46
49
|
// opts.dirty = commands.commitDirty(opts);
|
|
50
|
+
|
|
47
51
|
// gitPull needs to happen first, so we don't update files when we can't complete things
|
|
52
|
+
// The skipPull option is available if we are SURE we don't need to pull
|
|
48
53
|
sequence.unshift(commands.gitPull(opts));
|
|
49
54
|
sequence.push(commands.gitRelease(opts));
|
|
50
55
|
}
|
|
@@ -53,9 +58,9 @@ const ump = async function(options) {
|
|
|
53
58
|
|
|
54
59
|
// opts.inquire is set to true automatically for CLI usage
|
|
55
60
|
if (opts.inquire) {
|
|
56
|
-
const
|
|
61
|
+
const run = await confirm(config.confirmPrompt);
|
|
57
62
|
|
|
58
|
-
if (!
|
|
63
|
+
if (!run) {
|
|
59
64
|
console.log(sequence);
|
|
60
65
|
|
|
61
66
|
return log.color('\nHalted execution. Not bumping files.', 'red');
|