bump-cli 1.0.4 → 1.1.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/Help.txt +2 -0
- package/History.md +21 -2
- package/Readme.md +5 -5
- package/bin/bump +11 -8
- package/package.json +5 -2
- package/test/cli.js +153 -0
- package/test/support/cli.js +124 -0
- package/test/test.js +2 -2
package/Help.txt
CHANGED
|
@@ -8,6 +8,7 @@ Options:
|
|
|
8
8
|
Interactivity:
|
|
9
9
|
-y, --yes assume yes, don't prompt
|
|
10
10
|
-q, --quiet supress messages (implies -y)
|
|
11
|
+
-n, --dry-run don't do anything, just simulate
|
|
11
12
|
|
|
12
13
|
Bumping:
|
|
13
14
|
-v, --to VERSION use this version
|
|
@@ -16,6 +17,7 @@ Bumping:
|
|
|
16
17
|
-M, --major bump major version (2.3.4 -> 3.0.0)
|
|
17
18
|
|
|
18
19
|
Preleases:
|
|
20
|
+
--pre same as --prerelease
|
|
19
21
|
--prerelease bump a prerelease number (2.3.4-8 -> 2.3.4-9)
|
|
20
22
|
--prepatch bump patch and add prerelease (2.3.4 -> 2.3.5-0)
|
|
21
23
|
--preminor bump minor and add prerelease (2.3.4 -> 2.4.0-0)
|
package/History.md
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
|
+
## v1.1.3 - August 13, 2014
|
|
2
|
+
|
|
3
|
+
* No actual changes; just add `repository` metadata in the npm package.
|
|
4
|
+
|
|
5
|
+
## v1.1.2 - August 11, 2014
|
|
6
|
+
|
|
7
|
+
* Fix execution error.
|
|
8
|
+
|
|
9
|
+
## v1.1.1 - August 11, 2014
|
|
10
|
+
|
|
11
|
+
* Return a non-zero exit code when aborted.
|
|
12
|
+
|
|
13
|
+
## v1.1.0 - August 11, 2014
|
|
14
|
+
|
|
15
|
+
* Implement `--dry-run` (`-n`) to simulate.
|
|
16
|
+
* Implement `--pre` as an alias for `--prerelease`.
|
|
17
|
+
* Supress the 'Done' message when using `--yes`.
|
|
18
|
+
* Remove dependency with the *prompt* npm package.
|
|
19
|
+
|
|
1
20
|
## v1.0.4 - August 11, 2014
|
|
2
21
|
|
|
3
|
-
* Fix
|
|
4
|
-
* Improve
|
|
22
|
+
* Fix `--version` not working.
|
|
23
|
+
* Improve `--help` appearance.
|
|
5
24
|
|
|
6
25
|
## v1.0.3 - August 11, 2014
|
|
7
26
|
|
package/Readme.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Bumps semantic versions according to [semver] guidelines.
|
|
4
4
|
|
|
5
|
-

|
|
6
6
|
|
|
7
7
|
[](https://travis-ci.org/rstacruz/bump-cli)
|
|
8
8
|
|
|
@@ -25,16 +25,16 @@ Inspired by [@marksteve]'s [bump][bump-py]. `bump-cli` is backwards-compatible
|
|
|
25
25
|
[@marksteve]: https://github.com/marksteve
|
|
26
26
|
[bump-py]: https://github.com/marksteve/bump
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
:copyright:
|
|
29
29
|
|
|
30
|
-
**bump-cli** © 2014+, Rico Sta. Cruz. Released under the [MIT License
|
|
31
|
-
Authored and maintained by Rico Sta. Cruz with help from [contributors]
|
|
30
|
+
**bump-cli** © 2014+, Rico Sta. Cruz. Released under the [MIT] License.<br>
|
|
31
|
+
Authored and maintained by Rico Sta. Cruz with help from contributors. [(list)][contributors]
|
|
32
32
|
|
|
33
33
|
> [ricostacruz.com](http://ricostacruz.com) ·
|
|
34
34
|
> GitHub [@rstacruz](https://github.com/rstacruz) ·
|
|
35
35
|
> Twitter [@rstacruz](https://twitter.com/rstacruz)
|
|
36
36
|
|
|
37
|
-
[MIT
|
|
37
|
+
[MIT]: http://mit-license.org/
|
|
38
38
|
[contributors]: http://github.com/rstacruz/bump-cli/contributors
|
|
39
39
|
[semver]: https://www.npmjs.org/package/semver
|
|
40
40
|
[options]: Help.txt
|
package/bin/bump
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
var Context = require('../index').Context;
|
|
3
|
-
var prompt = require('prompt');
|
|
4
3
|
var fs = require('fs');
|
|
5
4
|
|
|
6
5
|
var args = require('minimist')(process.argv.slice(2), {
|
|
7
6
|
string: 'to',
|
|
8
|
-
boolean: ['patch', 'minor', 'major', 'premajor', 'preminor', 'prepatch', 'prerelease', 'yes', 'quiet'],
|
|
9
|
-
alias: { h: 'help', V: 'version', v: 'to', p: 'patch', m: 'minor', M: 'major', y: 'yes', q: 'quiet' }
|
|
7
|
+
boolean: ['patch', 'minor', 'major', 'premajor', 'preminor', 'prepatch', 'prerelease', 'yes', 'quiet', 'dry-run', 'pre'],
|
|
8
|
+
alias: { h: 'help', V: 'version', v: 'to', p: 'patch', m: 'minor', M: 'major', y: 'yes', q: 'quiet', n: 'dry-run' }
|
|
10
9
|
});
|
|
11
10
|
|
|
12
11
|
if (args.version) {
|
|
@@ -31,20 +30,23 @@ try {
|
|
|
31
30
|
contexts.push(ctx);
|
|
32
31
|
});
|
|
33
32
|
|
|
34
|
-
print();
|
|
35
33
|
contexts.forEach(function (ctx) {
|
|
36
|
-
print(ctx.preview());
|
|
37
34
|
print();
|
|
35
|
+
print(ctx.preview());
|
|
38
36
|
});
|
|
39
37
|
|
|
38
|
+
// don't proceed with --dry-run
|
|
39
|
+
if (args['dry-run']) return;
|
|
40
|
+
|
|
40
41
|
askToProceed(function (res) {
|
|
41
42
|
if (res) {
|
|
42
43
|
contexts.forEach(function (ctx) {
|
|
43
44
|
fs.writeFileSync(ctx.filename, ctx.toString(), 'utf-8');
|
|
44
45
|
});
|
|
45
|
-
print('\033[1A\033[2K\033[32m✓\033[0m', 'done!');
|
|
46
|
+
if (!args.yes) print('\033[1A\033[2K\033[32m✓\033[0m', 'done!');
|
|
46
47
|
} else {
|
|
47
|
-
print('\033[1A\033[2K\033[31m✗\033[0m', 'cancelled');
|
|
48
|
+
if (!args.yes) print('\033[1A\033[2K\033[31m✗\033[0m', 'cancelled');
|
|
49
|
+
process.exit(16);
|
|
48
50
|
}
|
|
49
51
|
});
|
|
50
52
|
|
|
@@ -60,6 +62,7 @@ function print () {
|
|
|
60
62
|
|
|
61
63
|
function askToProceed (fn) {
|
|
62
64
|
if (args.yes || args.quiet) return fn(true);
|
|
65
|
+
print();
|
|
63
66
|
ask('proceed? [Yn] ', function (res) {
|
|
64
67
|
if (res.toLowerCase() === 'y' || !res)
|
|
65
68
|
fn(true);
|
|
@@ -82,7 +85,7 @@ function toOptions (args) {
|
|
|
82
85
|
else if (args.premajor) options.inc = 'premajor';
|
|
83
86
|
else if (args.preminor) options.inc = 'preminor';
|
|
84
87
|
else if (args.prepatch) options.inc = 'prepatch';
|
|
85
|
-
else if (args.prerelease) options.inc = 'prerelease';
|
|
88
|
+
else if (args.prerelease || args.pre) options.inc = 'prerelease';
|
|
86
89
|
else options.inc = 'patch';
|
|
87
90
|
|
|
88
91
|
return options;
|
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bump-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Increments version numbers in files",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
7
7
|
"test": "test"
|
|
8
8
|
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/rstacruz/bump-cli.git"
|
|
12
|
+
},
|
|
9
13
|
"scripts": {
|
|
10
14
|
"test": "mocha"
|
|
11
15
|
},
|
|
@@ -22,7 +26,6 @@
|
|
|
22
26
|
},
|
|
23
27
|
"dependencies": {
|
|
24
28
|
"minimist": "^1.1.0",
|
|
25
|
-
"prompt": "^0.2.13",
|
|
26
29
|
"semver": "^3.0.1"
|
|
27
30
|
}
|
|
28
31
|
}
|
package/test/cli.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
require('./setup');
|
|
2
|
+
var cli = require('./support/cli');
|
|
3
|
+
cli.bin = './bin/bump';
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
var res = cli.result;
|
|
6
|
+
|
|
7
|
+
function tempfile() {
|
|
8
|
+
return '/tmp/tmp' + Math.random();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
describe('CLI: --help', function () {
|
|
12
|
+
cli.run('--help');
|
|
13
|
+
cli.success();
|
|
14
|
+
|
|
15
|
+
it('prints the command name', function () {
|
|
16
|
+
expect(res.out).match(/bump FILES/);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('prints the command name', function () {
|
|
20
|
+
expect(res.out).match(/bump FILES/);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('CLI: --version', function () {
|
|
25
|
+
cli.run('--version');
|
|
26
|
+
cli.success();
|
|
27
|
+
|
|
28
|
+
it('prints out the version', function () {
|
|
29
|
+
expect(res.out).include(require('../package.json').version);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// NB: this is sequential!
|
|
34
|
+
describe('working with files', function () {
|
|
35
|
+
var fname = tempfile();
|
|
36
|
+
|
|
37
|
+
before(function (next) {
|
|
38
|
+
fs.writeFile(fname, 'VERSION = "1.0.0"\n', 'utf-8', next);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
after(function (next) {
|
|
42
|
+
fs.unlink(fname, next);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('invoking with -v', function () {
|
|
46
|
+
cli.pipe('\n', [fname, '-v', '2.2.0']);
|
|
47
|
+
cli.success();
|
|
48
|
+
|
|
49
|
+
it('works', function () {
|
|
50
|
+
var str = fs.readFileSync(fname, 'utf-8');
|
|
51
|
+
expect(str).eql('VERSION = "2.2.0"\n');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('produced preview output', function () {
|
|
55
|
+
expect(res.stderr).match(/done!/);
|
|
56
|
+
expect(res.stderr).include('2.2.0');
|
|
57
|
+
expect(res.stderr).include('was 1.0.0');
|
|
58
|
+
expect(res.stderr).match(/VERSION = .*2\.2\.0.*/);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe('invoking with --yes', function () {
|
|
63
|
+
cli.run(fname + ' -y');
|
|
64
|
+
cli.success();
|
|
65
|
+
|
|
66
|
+
it('works', function () {
|
|
67
|
+
var str = fs.readFileSync(fname, 'utf-8');
|
|
68
|
+
expect(str).eql('VERSION = "2.2.1"\n');
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe('invoking by default', function () {
|
|
73
|
+
cli.pipe('\n', [fname]);
|
|
74
|
+
cli.success();
|
|
75
|
+
|
|
76
|
+
it('prints a preview', function () {
|
|
77
|
+
expect(res.stderr).match(/done!/);
|
|
78
|
+
expect(res.stderr).include('2.2.2');
|
|
79
|
+
expect(res.stderr).include('was 2.2.1');
|
|
80
|
+
expect(res.stderr).match(/VERSION = .*2\.2\.2.*/);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('updates the version', function () {
|
|
84
|
+
var str = fs.readFileSync(fname, 'utf-8');
|
|
85
|
+
expect(str).eql('VERSION = "2.2.2"\n');
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe('aborting with "n"', function () {
|
|
90
|
+
cli.pipe('n\n', [fname]);
|
|
91
|
+
|
|
92
|
+
it('produces a non-zero exit', function () {
|
|
93
|
+
expect(res.code).gt(0);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('prints an aborted message', function () {
|
|
97
|
+
expect(res.stderr).match(/cancelled/);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('doesnt do anything', function () {
|
|
101
|
+
var str = fs.readFileSync(fname, 'utf-8');
|
|
102
|
+
expect(str).eql('VERSION = "2.2.2"\n');
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe('invoking with --minor', function () {
|
|
107
|
+
cli.run(fname + ' -m -y');
|
|
108
|
+
cli.success();
|
|
109
|
+
|
|
110
|
+
it('works', function () {
|
|
111
|
+
var str = fs.readFileSync(fname, 'utf-8');
|
|
112
|
+
expect(str).eql('VERSION = "2.3.0"\n');
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe('invoking with --quiet', function () {
|
|
117
|
+
cli.run(fname + ' -q -v 2.2.0');
|
|
118
|
+
cli.success();
|
|
119
|
+
|
|
120
|
+
it('works', function () {
|
|
121
|
+
var str = fs.readFileSync(fname, 'utf-8');
|
|
122
|
+
expect(str).eql('VERSION = "2.2.0"\n');
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('produces no stderr', function () {
|
|
126
|
+
expect(res.stderr).eql("");
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
describe('invoking with a file without a version', function () {
|
|
131
|
+
cli.run('bin/bump');
|
|
132
|
+
|
|
133
|
+
it('produces a non-zero exit', function () {
|
|
134
|
+
expect(res.code).gt(0);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('produces stderr', function () {
|
|
138
|
+
expect(res.stderr).match(/no version found/);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
describe('invoking with an invalid file', function () {
|
|
143
|
+
cli.run('trololololol');
|
|
144
|
+
|
|
145
|
+
it('produces a non-zero exit', function () {
|
|
146
|
+
expect(res.code).gt(0);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('produces stderr', function () {
|
|
150
|
+
expect(res.stderr).match(/no such file/);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
});
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/* jshint expr: true */
|
|
2
|
+
|
|
3
|
+
/***
|
|
4
|
+
* cli:
|
|
5
|
+
* Helper for CLI tests.
|
|
6
|
+
*
|
|
7
|
+
* var cli = require('...');
|
|
8
|
+
* cli.bin = './bin/hello';
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
var exec = require('child_process').exec;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* result : cli.result
|
|
15
|
+
* the result.
|
|
16
|
+
*
|
|
17
|
+
* describe('help', function () {
|
|
18
|
+
* cli.run('--help');
|
|
19
|
+
*
|
|
20
|
+
* it('works', function () {
|
|
21
|
+
* cli.result.code => 0
|
|
22
|
+
* cli.result.error => true/false
|
|
23
|
+
* cli.result.out => "..." (stdout output)
|
|
24
|
+
* cli.result.stderr => "..." (stderr output)
|
|
25
|
+
* });
|
|
26
|
+
* });
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
exports.result = {};
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* bin : cli.bin
|
|
34
|
+
* the bin to run.
|
|
35
|
+
*
|
|
36
|
+
* var cli = require('...');
|
|
37
|
+
* cli.bin = './bin/hello';
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
exports.bin = './bin/lol';
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* run() : cli.run(cmd)
|
|
44
|
+
* Runs a given command.
|
|
45
|
+
*
|
|
46
|
+
* describe('running', function () {
|
|
47
|
+
* cli.run('--help');
|
|
48
|
+
* cli.success();
|
|
49
|
+
* });
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
exports.run = function (args) {
|
|
53
|
+
before(function (next) {
|
|
54
|
+
exec(exports.bin + ' ' + args, function (_exit, _cout, _cerr) {
|
|
55
|
+
exports.result.code = _exit && _exit.code || 0;
|
|
56
|
+
exports.result.error = _exit;
|
|
57
|
+
exports.result.out = _cout;
|
|
58
|
+
exports.result.stripped = _cout.replace(/\033\[[^m]*m/g, '');
|
|
59
|
+
exports.result.stderr = _cerr;
|
|
60
|
+
next();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
after(function () {
|
|
65
|
+
delete exports.result.code;
|
|
66
|
+
delete exports.result.error;
|
|
67
|
+
delete exports.result.out;
|
|
68
|
+
delete exports.result.stripped;
|
|
69
|
+
delete exports.result.stderr;
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* success() : cli.success()
|
|
75
|
+
* asserts success
|
|
76
|
+
*
|
|
77
|
+
* describe('running', function () {
|
|
78
|
+
* cli.run('--help');
|
|
79
|
+
* cli.success();
|
|
80
|
+
* });
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
exports.success = function () {
|
|
84
|
+
it('is successful', function () {
|
|
85
|
+
expect(exports.result.code).eql(0);
|
|
86
|
+
expect(exports.result.error).falsy;
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* pipe() : cli.pipe(input, args)
|
|
92
|
+
* runs and pipes things into stdin
|
|
93
|
+
*
|
|
94
|
+
* describe('pipes', function () {
|
|
95
|
+
* cli.pipe('var x = 2', ['--no-pager'])
|
|
96
|
+
* cli.success();
|
|
97
|
+
* });
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
exports.pipe = function (input, args) {
|
|
101
|
+
before(function (next) {
|
|
102
|
+
var spawn = require('child_process').spawn;
|
|
103
|
+
var child = spawn(exports.bin, args || [], { stdio: 'pipe' });
|
|
104
|
+
exports.result.out = '';
|
|
105
|
+
exports.result.stderr = '';
|
|
106
|
+
|
|
107
|
+
if (input) {
|
|
108
|
+
child.stdin.write(input);
|
|
109
|
+
child.stdin.end();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
child.stdout.on('data', function (data) { exports.result.out += data; });
|
|
113
|
+
child.stderr.on('data', function (data) { exports.result.stderr += data; });
|
|
114
|
+
child.on('close', function (code) {
|
|
115
|
+
exports.result.code = code;
|
|
116
|
+
next();
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
after(function () {
|
|
121
|
+
delete exports.result.out;
|
|
122
|
+
delete exports.result.stderr;
|
|
123
|
+
});
|
|
124
|
+
};
|
package/test/test.js
CHANGED
|
@@ -123,9 +123,9 @@ describe('using different version schemes', function () {
|
|
|
123
123
|
});
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
describe('xml', function () {
|
|
127
127
|
it('ignores xml version strings', function () {
|
|
128
|
-
ctx = new Context("<?xml version='1.0
|
|
128
|
+
ctx = new Context("<?xml version='1.0'?>\n<app version='2.0.4'>");
|
|
129
129
|
expect(ctx.version).eql('2.0.4');
|
|
130
130
|
});
|
|
131
131
|
});
|