Skip to content

Commit d78ae9e

Browse files
author
Charlike Mike Reagent
committed
fix: update recommended-bump to latest and update docs
Signed-off-by: Charlike Mike Reagent <mameto2011@gmail.com>
1 parent c98c729 commit d78ae9e

File tree

5 files changed

+91
-10
lines changed

5 files changed

+91
-10
lines changed

.verb.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ _Generated using [docks](http://npm.im/docks)._
5858

5959
### [src/index.js](/src/index.js)
6060

61-
#### [detectNextVersion](/src/index.js#L45)
61+
#### [detectNextVersion](/src/index.js#L72)
6262
Calculates next version of given package with `name`,
6363
based given `commitMessages` which should follow
6464
the [Conventional Commits Specification](https://www.conventionalcommits.org/).
@@ -72,14 +72,27 @@ returned result won't have `nextVersion` and `increment` will be `false`.
7272

7373
**Params**
7474
- `name` **{string}** a package name which you looking to update
75-
- `commitMessages` **{string|}** commit messages since last version
75+
- `commits` **{string|}** directly passed to [recommended-bump][]
76+
May be one of `string`, `Array<string>` or `Array<Commit>`
7677
- `[options]` **{object}** optional, passed to above mentioned packages.
7778

7879
**Returns**
7980
- `object` an object which is basically the return of [recommended-bump][]
8081
plus `{ pkg, lastVersion, nextVersion? }`.
8182

8283
**Examples**
84+
```ts
85+
type Commit = {
86+
header: {
87+
type: string,
88+
scope: string,
89+
subject: string,
90+
toString: Function,
91+
},
92+
body: string | null,
93+
footer: string | null
94+
}
95+
```
8396
```javascript
8497
import detector from 'detect-next-version';
8598

@@ -98,6 +111,20 @@ async function main() {
98111
console.log(result.patch[0].header.toString()); // => 'fix(cli): foobar'
99112
}
100113

114+
main().catch(console.error);
115+
```
116+
```javascript
117+
import { parse, plugins } from 'parse-commit-message';
118+
import detectNextVersion from 'detect-next-version';
119+
120+
async function main() {
121+
const commitOne = parse('fix: foo bar', plugins);
122+
const commitTwo = parse('feat: some feature subject', plugins);
123+
124+
const result = detectNextVersion('@my-org/my-awesomepkg', [commitOne, commitTwo]);
125+
console.log(result.increment); // => 'minor'
126+
}
127+
101128
main().catch(console.error);
102129
```
103130

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ _Generated using [docks](http://npm.im/docks)._
6868

6969
### [src/index.js](/src/index.js)
7070

71-
#### [detectNextVersion](/src/index.js#L45)
71+
#### [detectNextVersion](/src/index.js#L72)
7272
Calculates next version of given package with `name`,
7373
based given `commitMessages` which should follow
7474
the [Conventional Commits Specification](https://www.conventionalcommits.org/).
@@ -82,14 +82,27 @@ returned result won't have `nextVersion` and `increment` will be `false`.
8282

8383
**Params**
8484
- `name` **{string}** a package name which you looking to update
85-
- `commitMessages` **{string|}** commit messages since last version
85+
- `commits` **{string|}** directly passed to [recommended-bump][]
86+
May be one of `string`, `Array<string>` or `Array<Commit>`
8687
- `[options]` **{object}** optional, passed to above mentioned packages.
8788

8889
**Returns**
8990
- `object` an object which is basically the return of [recommended-bump][]
9091
plus `{ pkg, lastVersion, nextVersion? }`.
9192

9293
**Examples**
94+
```ts
95+
type Commit = {
96+
header: {
97+
type: string,
98+
scope: string,
99+
subject: string,
100+
toString: Function,
101+
},
102+
body: string | null,
103+
footer: string | null
104+
}
105+
```
93106
```javascript
94107
import detector from 'detect-next-version';
95108

@@ -108,6 +121,20 @@ async function main() {
108121
console.log(result.patch[0].header.toString()); // => 'fix(cli): foobar'
109122
}
110123

124+
main().catch(console.error);
125+
```
126+
```javascript
127+
import { parse, plugins } from 'parse-commit-message';
128+
import detectNextVersion from 'detect-next-version';
129+
130+
async function main() {
131+
const commitOne = parse('fix: foo bar', plugins);
132+
const commitTwo = parse('feat: some feature subject', plugins);
133+
134+
const result = detectNextVersion('@my-org/my-awesomepkg', [commitOne, commitTwo]);
135+
console.log(result.increment); // => 'minor'
136+
}
137+
111138
main().catch(console.error);
112139
```
113140

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@tunnckocore/package-json": "^1.0.1",
1919
"esm": "^3.0.84",
2020
"parse-commit-message": "1.1.2",
21-
"recommended-bump": "^1.0.1"
21+
"recommended-bump": "^1.2.0"
2222
},
2323
"devDependencies": {
2424
"@tunnckocore/config": "^0.5.1",

src/index.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ import increment from './semver-inc';
1414
* or containing `BREAKING CHANGE:` label (e.g. the `chore` type), then the
1515
* returned result won't have `nextVersion` and `increment` will be `false`.
1616
*
17+
* @example ts
18+
* type Commit = {
19+
* header: {
20+
* type: string,
21+
* scope: string,
22+
* subject: string,
23+
* toString: Function,
24+
* },
25+
* body: string | null,
26+
* footer: string | null
27+
* }
28+
*
1729
* @example
1830
* import detector from 'detect-next-version';
1931
*
@@ -34,10 +46,25 @@ import increment from './semver-inc';
3446
*
3547
* main().catch(console.error);
3648
*
49+
* @example
50+
* import { parse, plugins } from 'parse-commit-message';
51+
* import detectNextVersion from 'detect-next-version';
52+
*
53+
* async function main() {
54+
* const commitOne = parse('fix: foo bar', plugins);
55+
* const commitTwo = parse('feat: some feature subject', plugins);
56+
*
57+
* const result = detectNextVersion('@my-org/my-awesomepkg', [commitOne, commitTwo]);
58+
* console.log(result.increment); // => 'minor'
59+
* }
60+
*
61+
* main().catch(console.error);
62+
*
3763
* @name detectNextVersion
3864
* @public
3965
* @param {string} name a package name which you looking to update
40-
* @param {string|string[]} commitMessages commit messages since last version
66+
* @param {string|string[]} commits directly passed to [recommended-bump][]
67+
* May be one of `string`, `Array<string>` or `Array<Commit>`
4168
* @param {object} [options={}] optional, passed to above mentioned packages.
4269
* @returns {object} an object which is basically the return of [recommended-bump][]
4370
* plus `{ pkg, lastVersion, nextVersion? }`.

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3207,10 +3207,10 @@ readable-stream@^2.0.0:
32073207
string_decoder "~1.1.1"
32083208
util-deprecate "~1.0.1"
32093209

3210-
recommended-bump@^1.0.1:
3211-
version "1.0.1"
3212-
resolved "https://registry.yarnpkg.com/recommended-bump/-/recommended-bump-1.0.1.tgz#d476ba482e318e60837d2936ff6a65ba640a35e1"
3213-
integrity sha512-mBQcJEXU0ccCIov7y7aT0wwTyzj5wYlHqrw3+f7TLNnZxPF/8drdsIq6nrpmRf6CdXsw4qF0VAQ0mE9FmleXRQ==
3210+
recommended-bump@^1.2.0:
3211+
version "1.2.0"
3212+
resolved "https://registry.yarnpkg.com/recommended-bump/-/recommended-bump-1.2.0.tgz#50eb5a22e0a6c04e78a9dad133063724bfa83dd7"
3213+
integrity sha512-LbADFBSq6i+jfatugYtYJ7PX3R4H7tEx25uZ2DjMwps6LV6HdR1sAXbwMzgAnfzkmFB6V1eL6GK/H5Q5Rx56ew==
32143214
dependencies:
32153215
esm "^3.0.84"
32163216
parse-commit-message "^2.1.4"

0 commit comments

Comments
 (0)