Skip to content

Commit

Permalink
fix: update recommended-bump to latest and update docs
Browse files Browse the repository at this point in the history
Signed-off-by: Charlike Mike Reagent <mameto2011@gmail.com>
  • Loading branch information
Charlike Mike Reagent committed Nov 6, 2018
1 parent c98c729 commit d78ae9e
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 10 deletions.
31 changes: 29 additions & 2 deletions .verb.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ _Generated using [docks](http://npm.im/docks)._

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

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

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

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

**Examples**
```ts
type Commit = {
header: {
type: string,
scope: string,
subject: string,
toString: Function,
},
body: string | null,
footer: string | null
}
```
```javascript
import detector from 'detect-next-version';

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

main().catch(console.error);
```
```javascript
import { parse, plugins } from 'parse-commit-message';
import detectNextVersion from 'detect-next-version';

async function main() {
const commitOne = parse('fix: foo bar', plugins);
const commitTwo = parse('feat: some feature subject', plugins);

const result = detectNextVersion('@my-org/my-awesomepkg', [commitOne, commitTwo]);
console.log(result.increment); // => 'minor'
}

main().catch(console.error);
```

Expand Down
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ _Generated using [docks](http://npm.im/docks)._

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

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

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

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

**Examples**
```ts
type Commit = {
header: {
type: string,
scope: string,
subject: string,
toString: Function,
},
body: string | null,
footer: string | null
}
```
```javascript
import detector from 'detect-next-version';

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

main().catch(console.error);
```
```javascript
import { parse, plugins } from 'parse-commit-message';
import detectNextVersion from 'detect-next-version';

async function main() {
const commitOne = parse('fix: foo bar', plugins);
const commitTwo = parse('feat: some feature subject', plugins);

const result = detectNextVersion('@my-org/my-awesomepkg', [commitOne, commitTwo]);
console.log(result.increment); // => 'minor'
}

main().catch(console.error);
```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@tunnckocore/package-json": "^1.0.1",
"esm": "^3.0.84",
"parse-commit-message": "1.1.2",
"recommended-bump": "^1.0.1"
"recommended-bump": "^1.2.0"
},
"devDependencies": {
"@tunnckocore/config": "^0.5.1",
Expand Down
29 changes: 28 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ import increment from './semver-inc';
* or containing `BREAKING CHANGE:` label (e.g. the `chore` type), then the
* returned result won't have `nextVersion` and `increment` will be `false`.
*
* @example ts
* type Commit = {
* header: {
* type: string,
* scope: string,
* subject: string,
* toString: Function,
* },
* body: string | null,
* footer: string | null
* }
*
* @example
* import detector from 'detect-next-version';
*
Expand All @@ -34,10 +46,25 @@ import increment from './semver-inc';
*
* main().catch(console.error);
*
* @example
* import { parse, plugins } from 'parse-commit-message';
* import detectNextVersion from 'detect-next-version';
*
* async function main() {
* const commitOne = parse('fix: foo bar', plugins);
* const commitTwo = parse('feat: some feature subject', plugins);
*
* const result = detectNextVersion('@my-org/my-awesomepkg', [commitOne, commitTwo]);
* console.log(result.increment); // => 'minor'
* }
*
* main().catch(console.error);
*
* @name detectNextVersion
* @public
* @param {string} name a package name which you looking to update
* @param {string|string[]} commitMessages commit messages since last version
* @param {string|string[]} commits directly passed to [recommended-bump][]
* May be one of `string`, `Array<string>` or `Array<Commit>`
* @param {object} [options={}] optional, passed to above mentioned packages.
* @returns {object} an object which is basically the return of [recommended-bump][]
* plus `{ pkg, lastVersion, nextVersion? }`.
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3207,10 +3207,10 @@ readable-stream@^2.0.0:
string_decoder "~1.1.1"
util-deprecate "~1.0.1"

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

0 comments on commit d78ae9e

Please sign in to comment.