conventional-recommended-bump 9.0.0 → 10.0.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 +62 -150
- package/dist/bumper.d.ts +51 -0
- package/dist/bumper.d.ts.map +1 -0
- package/dist/bumper.js +115 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +141 -0
- package/dist/cli/options.d.ts +6 -0
- package/dist/cli/options.d.ts.map +1 -0
- package/dist/cli/options.js +71 -0
- package/dist/cli/utils.d.ts +2 -0
- package/dist/cli/utils.d.ts.map +1 -0
- package/dist/cli/utils.js +17 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/utils.d.ts +7 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +10 -0
- package/package.json +26 -23
- package/cli.mjs +0 -104
- package/index.js +0 -86
package/README.md
CHANGED
|
@@ -1,191 +1,103 @@
|
|
|
1
1
|
# conventional-recommended-bump
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[![ESM-only package][package]][package-url]
|
|
4
|
+
[![NPM version][npm]][npm-url]
|
|
5
|
+
[![Node version][node]][node-url]
|
|
6
|
+
[![Dependencies status][deps]][deps-url]
|
|
7
|
+
[![Install size][size]][size-url]
|
|
8
|
+
[![Build status][build]][build-url]
|
|
9
|
+
[![Coverage status][coverage]][coverage-url]
|
|
4
10
|
|
|
5
|
-
|
|
11
|
+
[package]: https://img.shields.io/badge/package-ESM--only-ffe536.svg
|
|
12
|
+
[package-url]: https://nodejs.org/api/esm.html
|
|
6
13
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
14
|
+
[npm]: https://img.shields.io/npm/v/conventional-recommended-bump.svg
|
|
15
|
+
[npm-url]: https://npmjs.com/package/conventional-recommended-bump
|
|
10
16
|
|
|
17
|
+
[node]: https://img.shields.io/node/v/conventional-recommended-bump.svg
|
|
18
|
+
[node-url]: https://nodejs.org
|
|
11
19
|
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
- [API](#api)
|
|
15
|
-
- [options](#options)
|
|
16
|
-
- [ignoreReverted](#ignorereverted)
|
|
17
|
-
- [preset](#preset)
|
|
18
|
-
- [config](#config)
|
|
19
|
-
- [whatBump](#whatbump)
|
|
20
|
-
- [tagPrefix](#tagprefix)
|
|
21
|
-
- [skipUnstable](#skipunstable)
|
|
22
|
-
- [lernaPackage](#lernapackage)
|
|
23
|
-
- [path](#path)
|
|
24
|
-
- [parserOpts](#parseropts)
|
|
25
|
-
- [callback](#callback)
|
|
26
|
-
- [License](#license)
|
|
20
|
+
[deps]: https://img.shields.io/librariesio/release/npm/conventional-recommended-bump
|
|
21
|
+
[deps-url]: https://libraries.io/npm/conventional-recommended-bump/tree
|
|
27
22
|
|
|
28
|
-
|
|
23
|
+
[size]: https://packagephobia.com/badge?p=conventional-recommended-bump
|
|
24
|
+
[size-url]: https://packagephobia.com/result?p=conventional-recommended-bump
|
|
29
25
|
|
|
30
|
-
|
|
26
|
+
[build]: https://img.shields.io/github/actions/workflow/status/conventional-changelog/conventional-changelog/tests.yaml?branch=master
|
|
27
|
+
[build-url]: https://github.com/conventional-changelog/conventional-changelog/actions
|
|
31
28
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
```
|
|
29
|
+
[coverage]: https://coveralls.io/repos/github/conventional-changelog/conventional-changelog/badge.svg?branch=master
|
|
30
|
+
[coverage-url]: https://coveralls.io/github/conventional-changelog/conventional-changelog?branch=master
|
|
35
31
|
|
|
36
|
-
|
|
32
|
+
Get a recommended version bump based on conventional commits.
|
|
37
33
|
|
|
38
|
-
|
|
39
|
-
const conventionalRecommendedBump = require(`conventional-recommended-bump`);
|
|
34
|
+
> Got the idea from https://github.com/conventional-changelog/conventional-changelog/pull/29
|
|
40
35
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
<hr />
|
|
37
|
+
<a href="#install">Install</a>
|
|
38
|
+
<span> • </span>
|
|
39
|
+
<a href="#usage">Usage</a>
|
|
40
|
+
<span> • </span>
|
|
41
|
+
<a href="#api">API</a>
|
|
42
|
+
<span> • </span>
|
|
43
|
+
<a href="#cli">CLI</a>
|
|
44
|
+
<br />
|
|
45
|
+
<hr />
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
```
|
|
47
|
+
## Install
|
|
47
48
|
|
|
48
49
|
```bash
|
|
49
|
-
|
|
50
|
-
conventional-recommended-bump
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
```javascript
|
|
56
|
-
conventionalRecommendedBump(options, [parserOpts,] callback);
|
|
50
|
+
# pnpm
|
|
51
|
+
pnpm add conventional-recommended-bump
|
|
52
|
+
# yarn
|
|
53
|
+
yarn add conventional-recommended-bump
|
|
54
|
+
# npm
|
|
55
|
+
npm i conventional-recommended-bump
|
|
57
56
|
```
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
In the case you don't want to provide `parserOpts`, then `callback` must be provided as the second argument.
|
|
62
|
-
|
|
63
|
-
#### options
|
|
64
|
-
|
|
65
|
-
`options` is an object with the following properties:
|
|
66
|
-
|
|
67
|
-
* ignoreReverted
|
|
68
|
-
* preset
|
|
69
|
-
* config
|
|
70
|
-
* whatBump
|
|
71
|
-
|
|
72
|
-
##### ignoreReverted
|
|
73
|
-
|
|
74
|
-
**Type:** `boolean` **Default:** `true`
|
|
75
|
-
|
|
76
|
-
If `true`, reverted commits will be ignored.
|
|
77
|
-
|
|
78
|
-
##### preset
|
|
79
|
-
|
|
80
|
-
**Type:** `string`
|
|
81
|
-
|
|
82
|
-
It's recommended to use a preset so you don't have to define everything yourself.
|
|
83
|
-
|
|
84
|
-
The value is passed to [`conventional-changelog-preset-loader`](https://www.npmjs.com/package/conventional-changelog-preset-loader).
|
|
85
|
-
|
|
86
|
-
##### config
|
|
87
|
-
|
|
88
|
-
**Type:** `object`
|
|
89
|
-
|
|
90
|
-
This should serve as default values for other arguments of `conventional-recommended-bump` so you don't need to rewrite the same or similar config across your projects.
|
|
91
|
-
|
|
92
|
-
**NOTE:** `config` option will be overwritten by the value loaded by `conventional-changelog-preset-loader` if the `preset` options is set.
|
|
93
|
-
|
|
94
|
-
##### whatBump
|
|
58
|
+
## Usage
|
|
95
59
|
|
|
96
|
-
|
|
60
|
+
```js
|
|
61
|
+
import { Bumper } from 'conventional-recommended-bump'
|
|
97
62
|
|
|
98
|
-
|
|
63
|
+
const bumper = new Bumper(process.cwd()).loadPreset('angular')
|
|
64
|
+
const recommendation = await bumper.bump()
|
|
99
65
|
|
|
100
|
-
|
|
101
|
-
whatBump(commits) {};
|
|
66
|
+
console.log(recommendation.releaseType) // 'major'
|
|
102
67
|
```
|
|
103
68
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
This should return an object including but not limited to `level` and `reason`. `level` is a `number` indicating what bump it should be and `reason` is the reason of such release.
|
|
107
|
-
|
|
108
|
-
##### tagPrefix
|
|
109
|
-
|
|
110
|
-
**Type:** `string`
|
|
111
|
-
|
|
112
|
-
Specify a prefix for the git tag that will be taken into account during the comparison.
|
|
113
|
-
|
|
114
|
-
For instance if your version tag is prefixed by `version/` instead of `v` you would specifying `--tagPrefix=version/` using the CLI, or `version/` as the value of the `tagPrefix` option.
|
|
115
|
-
|
|
116
|
-
##### skipUnstable
|
|
117
|
-
|
|
118
|
-
**Type:** `boolean`
|
|
119
|
-
|
|
120
|
-
If true, unstable tags will be skipped, e.g., x.x.x-alpha.1, x.x.x-rc.2
|
|
121
|
-
|
|
122
|
-
##### lernaPackage
|
|
123
|
-
|
|
124
|
-
**Type:** `string`
|
|
125
|
-
|
|
126
|
-
Specify the name of a package in a [Lerna](https://lernajs.io/)-managed repository. The package name will be used when fetching all changes to a package since the last time that package was released.
|
|
127
|
-
|
|
128
|
-
For instance if your project contained a package named `conventional-changelog`, you could have only commits that have happened since the last release of `conventional-changelog` was tagged by specifying `--lernaPackage=conventional-changelog` using the CLI, or `conventional-changelog` as the value of the `lernaPackage` option.
|
|
129
|
-
|
|
130
|
-
##### path
|
|
131
|
-
|
|
132
|
-
**Type:** `string`
|
|
133
|
-
|
|
134
|
-
Specify the path to only calculate with git commits related to the path. If you want to calculate recommended bumps of packages in a [Lerna](https://lernajs.io/)-managed repository, `path` should be use along with `lernaPackage` for each of the package.
|
|
69
|
+
## API
|
|
135
70
|
|
|
136
|
-
|
|
71
|
+
### `new Bumper(cwdOrGitClient: string | ConventionalGitClient = process.cwd())`
|
|
137
72
|
|
|
138
|
-
|
|
73
|
+
Create a new Bumper instance. `cwdOrGitClient` is the current working directory or a `ConventionalGitClient` instance.
|
|
139
74
|
|
|
140
|
-
|
|
75
|
+
### `bumper.tag(paramsOrTag: GetSemverTagsParams & Params | string): this`
|
|
141
76
|
|
|
142
|
-
|
|
77
|
+
Set params to get the last semver tag or set the tag directly.
|
|
143
78
|
|
|
144
|
-
|
|
79
|
+
### `bumper.commits(params: GetCommitsParams & Params, parserOptions?: ParserStreamOptions): this`
|
|
145
80
|
|
|
146
|
-
|
|
147
|
-
callback(error, recommendation) {};
|
|
148
|
-
```
|
|
81
|
+
Set params to get the commits.
|
|
149
82
|
|
|
150
|
-
|
|
83
|
+
### `bumper.commits(commits: Iterable<Commit> | AsyncIterable<Commit>): this`
|
|
151
84
|
|
|
152
|
-
|
|
85
|
+
Set the commits directly.
|
|
153
86
|
|
|
154
|
-
|
|
87
|
+
### `bumper.loadPreset(preset: PresetParams): this`
|
|
155
88
|
|
|
156
|
-
|
|
89
|
+
Load and set necessary params from a preset.
|
|
157
90
|
|
|
158
|
-
|
|
91
|
+
### `bumper.bump(whatBump?: (commits: Commit[]) => Promise<BumperRecommendation | null | undefined>): Promise<BumperRecommendation>`
|
|
159
92
|
|
|
160
|
-
|
|
161
|
-
DEBUG=conventional-recommended-bump conventional-recommended-bump
|
|
162
|
-
```
|
|
93
|
+
Get a recommended version bump based on conventional commits. `whatBump` function is required if preset is not loaded.
|
|
163
94
|
|
|
164
|
-
|
|
95
|
+
## CLI
|
|
165
96
|
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
conventional-recommended-bump
|
|
97
|
+
```sh
|
|
98
|
+
$ conventional-recommended-bump --help
|
|
169
99
|
```
|
|
170
100
|
|
|
171
|
-
## Node Support Policy
|
|
172
|
-
|
|
173
|
-
We only support [Long-Term Support](https://github.com/nodejs/Release) versions of Node.
|
|
174
|
-
|
|
175
|
-
We specifically limit our support to LTS versions of Node, not because this package won't work on other versions, but because we have a limited amount of time, and supporting LTS offers the greatest return on that investment.
|
|
176
|
-
|
|
177
|
-
It's possible this package will work correctly on newer versions of Node. It may even be possible to use this package on older versions of Node, though that's more unlikely as we'll make every effort to take advantage of features available in the oldest LTS version we support.
|
|
178
|
-
|
|
179
|
-
As each Node LTS version reaches its end-of-life we will remove that version from the `node` `engines` property of our package's `package.json` file. Removing a Node version is considered a breaking change and will entail the publishing of a new major version of this package. We will not accept any requests to support an end-of-life version of Node. Any merge requests or issues supporting an end-of-life version of Node will be closed.
|
|
180
|
-
|
|
181
|
-
We will accept code that allows this package to run on newer, non-LTS, versions of Node. Furthermore, we will attempt to ensure our own changes work on the latest version of Node. To help in that commitment, our continuous integration setup runs against all LTS versions of Node in addition the most recent Node release; called _current_.
|
|
182
|
-
|
|
183
|
-
JavaScript package managers should allow you to install this package with any version of Node, with, at most, a warning if your version of Node does not fall within the range specified by our `node` `engines` property. If you encounter issues installing this package, please report the issue to your package manager.
|
|
184
|
-
|
|
185
|
-
## Contributing
|
|
186
|
-
|
|
187
|
-
Please read our [contributing guide](https://github.com/conventional-changelog/conventional-changelog/blob/master/CONTRIBUTING.md) to see how you may contribute to this project.
|
|
188
|
-
|
|
189
101
|
## License
|
|
190
102
|
|
|
191
103
|
MIT © [Steve Mao](https://github.com/stevemao)
|
package/dist/bumper.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ParserStreamOptions, Commit } from 'conventional-commits-parser';
|
|
2
|
+
import type { GetSemverTagsParams, GetCommitsParams, Params } from '@conventional-changelog/git-client';
|
|
3
|
+
import type { UnknownPresetCreatorParams, PresetParams } from 'conventional-changelog-preset-loader';
|
|
4
|
+
import { ConventionalGitClient, packagePrefix } from '@conventional-changelog/git-client';
|
|
5
|
+
export { packagePrefix };
|
|
6
|
+
/**
|
|
7
|
+
* Bump suggester for conventional commits
|
|
8
|
+
*/
|
|
9
|
+
export declare class Bumper {
|
|
10
|
+
private readonly gitClient;
|
|
11
|
+
private preset;
|
|
12
|
+
private whatBump;
|
|
13
|
+
private tagGetter;
|
|
14
|
+
private commitsGetter;
|
|
15
|
+
constructor(cwdOrGitClient?: string | ConventionalGitClient);
|
|
16
|
+
private getLastSemverTag;
|
|
17
|
+
private getCommits;
|
|
18
|
+
private getPreset;
|
|
19
|
+
/**
|
|
20
|
+
* Load configs from a preset
|
|
21
|
+
* @param preset
|
|
22
|
+
* @returns this
|
|
23
|
+
*/
|
|
24
|
+
loadPreset<PresetCreatorParams extends UnknownPresetCreatorParams = UnknownPresetCreatorParams>(preset: PresetParams<PresetCreatorParams>): this;
|
|
25
|
+
/**
|
|
26
|
+
* Set params to get the last semver tag
|
|
27
|
+
* @param paramsOrTag - Params to get the last semver tag or a tag name
|
|
28
|
+
* @returns this
|
|
29
|
+
*/
|
|
30
|
+
tag(paramsOrTag: GetSemverTagsParams & Params | string): this;
|
|
31
|
+
/**
|
|
32
|
+
* Set params to get commits since last release
|
|
33
|
+
* @param params - Params to get commits since last release
|
|
34
|
+
* @param parserOptions - Parser options
|
|
35
|
+
* @returns this
|
|
36
|
+
*/
|
|
37
|
+
commits(params: GetCommitsParams & Params, parserOptions?: ParserStreamOptions): this;
|
|
38
|
+
/**
|
|
39
|
+
* Set commits since last release
|
|
40
|
+
* @param commits - Iterable or async iterable of commits
|
|
41
|
+
* @returns this
|
|
42
|
+
*/
|
|
43
|
+
commits(commits: Iterable<Commit> | AsyncIterable<Commit>): this;
|
|
44
|
+
/**
|
|
45
|
+
* Recommend a bump by `whatBump` function
|
|
46
|
+
* @param whatBump - Function to recommend a bump from commits
|
|
47
|
+
* @returns Bump recommendation
|
|
48
|
+
*/
|
|
49
|
+
bump(whatBump?: ((commits: Commit[]) => Promise<import("./types.js").BumperRecommendation | null | undefined>) | null): Promise<import("./types.js").BumperRecommendation>;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=bumper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bumper.d.ts","sourceRoot":"","sources":["../src/bumper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,MAAM,EACP,MAAM,6BAA6B,CAAA;AACpC,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,MAAM,EACP,MAAM,oCAAoC,CAAA;AAC3C,OAAO,KAAK,EACV,0BAA0B,EAC1B,YAAY,EACb,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EACL,qBAAqB,EACrB,aAAa,EACd,MAAM,oCAAoC,CAAA;AAK3C,OAAO,EAAE,aAAa,EAAE,CAAA;AAQxB;;GAEG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAuB;IACjD,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,SAAS,CAAuC;IACxD,OAAO,CAAC,aAAa,CAAgD;gBAEzD,cAAc,GAAE,MAAM,GAAG,qBAAqC;IAW1E,OAAO,CAAC,gBAAgB;YAIT,UAAU;YAYX,SAAS;IAUvB;;;;OAIG;IACH,UAAU,CAAC,mBAAmB,SAAS,0BAA0B,GAAG,0BAA0B,EAC5F,MAAM,EAAE,YAAY,CAAC,mBAAmB,CAAC;IAyB3C;;;;OAIG;IACH,GAAG,CAAC,WAAW,EAAE,mBAAmB,GAAG,MAAM,GAAG,MAAM;IAUtD;;;;;OAKG;IACH,OAAO,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,EAAE,aAAa,CAAC,EAAE,mBAAmB,GAAG,IAAI;IACrF;;;;OAIG;IACH,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,IAAI;IAchE;;;;OAIG;IACG,IAAI,CAAC,QAAQ,wGAAgB;CAuBpC"}
|
package/dist/bumper.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { ConventionalGitClient, packagePrefix } from '@conventional-changelog/git-client';
|
|
2
|
+
import { loadPreset } from 'conventional-changelog-preset-loader';
|
|
3
|
+
import { isIterable } from './utils.js';
|
|
4
|
+
export { packagePrefix };
|
|
5
|
+
const VERSIONS = [
|
|
6
|
+
'major',
|
|
7
|
+
'minor',
|
|
8
|
+
'patch'
|
|
9
|
+
];
|
|
10
|
+
/**
|
|
11
|
+
* Bump suggester for conventional commits
|
|
12
|
+
*/
|
|
13
|
+
export class Bumper {
|
|
14
|
+
gitClient;
|
|
15
|
+
preset;
|
|
16
|
+
whatBump;
|
|
17
|
+
tagGetter;
|
|
18
|
+
commitsGetter;
|
|
19
|
+
constructor(cwdOrGitClient = process.cwd()) {
|
|
20
|
+
this.gitClient = typeof cwdOrGitClient === 'string'
|
|
21
|
+
? new ConventionalGitClient(cwdOrGitClient)
|
|
22
|
+
: cwdOrGitClient;
|
|
23
|
+
this.preset = null;
|
|
24
|
+
this.whatBump = null;
|
|
25
|
+
this.tagGetter = () => this.getLastSemverTag();
|
|
26
|
+
this.commitsGetter = () => this.getCommits();
|
|
27
|
+
}
|
|
28
|
+
getLastSemverTag(params) {
|
|
29
|
+
return this.gitClient.getLastSemverTag(params);
|
|
30
|
+
}
|
|
31
|
+
async *getCommits(params, parserOptions) {
|
|
32
|
+
yield* this.gitClient.getCommits({
|
|
33
|
+
format: '%B%n-hash-%n%H',
|
|
34
|
+
from: await this.tagGetter() || '',
|
|
35
|
+
filterReverts: true,
|
|
36
|
+
...params
|
|
37
|
+
}, parserOptions);
|
|
38
|
+
}
|
|
39
|
+
async getPreset() {
|
|
40
|
+
const result = await this.preset;
|
|
41
|
+
if (!result) {
|
|
42
|
+
throw Error('Preset is not loaded or have incorrect exports');
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Load configs from a preset
|
|
48
|
+
* @param preset
|
|
49
|
+
* @returns this
|
|
50
|
+
*/
|
|
51
|
+
loadPreset(preset) {
|
|
52
|
+
this.preset = loadPreset(preset);
|
|
53
|
+
this.whatBump = async (commits) => {
|
|
54
|
+
const { whatBump } = await this.getPreset();
|
|
55
|
+
return whatBump(commits);
|
|
56
|
+
};
|
|
57
|
+
this.tagGetter = async () => {
|
|
58
|
+
const { tags } = await this.getPreset();
|
|
59
|
+
return this.getLastSemverTag(tags);
|
|
60
|
+
};
|
|
61
|
+
this.commitsGetter = async function* commitsGetter() {
|
|
62
|
+
const { commits, parser } = await this.getPreset();
|
|
63
|
+
yield* this.getCommits(commits, parser);
|
|
64
|
+
};
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Set params to get the last semver tag
|
|
69
|
+
* @param paramsOrTag - Params to get the last semver tag or a tag name
|
|
70
|
+
* @returns this
|
|
71
|
+
*/
|
|
72
|
+
tag(paramsOrTag) {
|
|
73
|
+
if (typeof paramsOrTag === 'string') {
|
|
74
|
+
this.tagGetter = () => paramsOrTag;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
this.tagGetter = () => this.getLastSemverTag(paramsOrTag);
|
|
78
|
+
}
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
commits(paramsOrCommits, parserOptions) {
|
|
82
|
+
if (isIterable(paramsOrCommits)) {
|
|
83
|
+
this.commitsGetter = () => paramsOrCommits;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this.commitsGetter = () => this.getCommits(paramsOrCommits, parserOptions);
|
|
87
|
+
}
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Recommend a bump by `whatBump` function
|
|
92
|
+
* @param whatBump - Function to recommend a bump from commits
|
|
93
|
+
* @returns Bump recommendation
|
|
94
|
+
*/
|
|
95
|
+
async bump(whatBump = this.whatBump) {
|
|
96
|
+
if (typeof whatBump !== 'function') {
|
|
97
|
+
throw Error('`whatBump` must be a function');
|
|
98
|
+
}
|
|
99
|
+
const commitsStream = this.commitsGetter();
|
|
100
|
+
const commits = [];
|
|
101
|
+
let commit;
|
|
102
|
+
for await (commit of commitsStream) {
|
|
103
|
+
commits.push(commit);
|
|
104
|
+
}
|
|
105
|
+
let result = await whatBump(commits);
|
|
106
|
+
if (result && typeof result.level === 'number') {
|
|
107
|
+
result.releaseType = VERSIONS[result.level];
|
|
108
|
+
}
|
|
109
|
+
else if (!result) {
|
|
110
|
+
result = {};
|
|
111
|
+
}
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVtcGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2J1bXBlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFhQSxPQUFPLEVBQ0wscUJBQXFCLEVBQ3JCLGFBQWEsRUFDZCxNQUFNLG9DQUFvQyxDQUFBO0FBQzNDLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxzQ0FBc0MsQ0FBQTtBQUVqRSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sWUFBWSxDQUFBO0FBRXZDLE9BQU8sRUFBRSxhQUFhLEVBQUUsQ0FBQTtBQUV4Q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UFNLGFBQWEsR0FBRyxJQUFJLENBQUMsYUFBYSxFQUFFLENBQUE7UUFDMUMsTUFBTSxPQUFPLEdBQWEsRUFBRSxDQUFBO1FBQzVCLElBQUksTUFBYyxDQUFBO1FBRWxCLElBQUksS0FBSyxFQUFFLE1BQU0sSUFBSSxhQUFhLEVBQUU7WUFDbEMsT0FBTyxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQTtTQUNyQjtRQUVELElBQUksTUFBTSxHQUFHLE1BQU0sUUFBUSxDQUFDLE9BQU8sQ0FBQyxDQUFBO1FBRXBDLElBQUksTUFBTSxJQUFJLE9BQU8sTUFBTSxDQUFDLEtBQUssS0FBSyxRQUFRLEVBQUU7WUFDOUMsTUFBTSxDQUFDLFdBQVcsR0FBRyxRQUFRLENBQUMsTUFBTSxDQUFDLEtBQUssQ0FBQyxDQUFBO1NBQzVDO2FBQU0sSUFBSSxDQUFDLE1BQU0sRUFBRTtZQUNsQixNQUFNLEdBQUcsRUFBRSxDQUFBO1NBQ1o7UUFFRCxPQUFPLE1BQU0sQ0FBQTtJQUNmLENBQUM7Q0FDRiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import meow from 'meow';
|
|
3
|
+
import { Bumper } from '../index.js';
|
|
4
|
+
import { parseCommitsOptions, parseTagsOptions, parseParserOptions } from './options.js';
|
|
5
|
+
import { loadDataFile } from './utils.js';
|
|
6
|
+
const cli = meow(`
|
|
7
|
+
Usage
|
|
8
|
+
conventional-recommended-bump
|
|
9
|
+
|
|
10
|
+
Example
|
|
11
|
+
conventional-recommended-bump
|
|
12
|
+
|
|
13
|
+
Options
|
|
14
|
+
-p, --preset Name of the preset you want to use
|
|
15
|
+
-g, --config A filepath of your config script
|
|
16
|
+
-h, --header-pattern Regex to match header pattern
|
|
17
|
+
-c, --header-correspondence Comma separated parts used to define what capturing group of 'headerPattern' captures what
|
|
18
|
+
-r, --reference-actions Comma separated keywords that used to reference issues
|
|
19
|
+
-i, --issue-prefixes Comma separated prefixes of an issue
|
|
20
|
+
-n, --note-keywords Comma separated keywords for important notes
|
|
21
|
+
-f, --field-pattern Regex to match other fields
|
|
22
|
+
-v, --verbose Verbose output
|
|
23
|
+
-l, --lerna-package Recommend a bump for a specific lerna package (:pkg-name@1.0.0)
|
|
24
|
+
-t, --tag-prefix Tag prefix to consider when reading the tags
|
|
25
|
+
--commit-path Recommend a bump scoped to a specific directory
|
|
26
|
+
--skip-unstable If given, unstable tags will be skipped, e.g., x.x.x-alpha.1, x.x.x-rc.2
|
|
27
|
+
`, {
|
|
28
|
+
importMeta: import.meta,
|
|
29
|
+
flags: {
|
|
30
|
+
preset: {
|
|
31
|
+
shortFlag: 'p',
|
|
32
|
+
type: 'string'
|
|
33
|
+
},
|
|
34
|
+
config: {
|
|
35
|
+
shortFlag: 'g',
|
|
36
|
+
type: 'string'
|
|
37
|
+
},
|
|
38
|
+
verbose: {
|
|
39
|
+
shortFlag: 'v',
|
|
40
|
+
type: 'boolean'
|
|
41
|
+
},
|
|
42
|
+
// tags `prefix` param
|
|
43
|
+
lernaPackage: {
|
|
44
|
+
shortFlag: 'l',
|
|
45
|
+
type: 'string'
|
|
46
|
+
},
|
|
47
|
+
// tags `prefix` param
|
|
48
|
+
tagPrefix: {
|
|
49
|
+
shortFlag: 't',
|
|
50
|
+
type: 'string'
|
|
51
|
+
},
|
|
52
|
+
// tags `skipUnstable` param
|
|
53
|
+
skipUnstable: {
|
|
54
|
+
type: 'boolean'
|
|
55
|
+
},
|
|
56
|
+
// commits `path` param
|
|
57
|
+
commitPath: {
|
|
58
|
+
type: 'string'
|
|
59
|
+
},
|
|
60
|
+
// parser options
|
|
61
|
+
headerPattern: {
|
|
62
|
+
shortFlag: 'h',
|
|
63
|
+
type: 'string'
|
|
64
|
+
},
|
|
65
|
+
headerCorrespondence: {
|
|
66
|
+
shortFlag: 'c',
|
|
67
|
+
type: 'string'
|
|
68
|
+
},
|
|
69
|
+
referenceActions: {
|
|
70
|
+
shortFlag: 'r',
|
|
71
|
+
type: 'string'
|
|
72
|
+
},
|
|
73
|
+
issuePrefixes: {
|
|
74
|
+
shortFlag: 'i',
|
|
75
|
+
type: 'string'
|
|
76
|
+
},
|
|
77
|
+
noteKeywords: {
|
|
78
|
+
shortFlag: 'n',
|
|
79
|
+
type: 'string'
|
|
80
|
+
},
|
|
81
|
+
fieldPattern: {
|
|
82
|
+
shortFlag: 'f',
|
|
83
|
+
type: 'string'
|
|
84
|
+
},
|
|
85
|
+
revertPattern: {
|
|
86
|
+
type: 'string'
|
|
87
|
+
},
|
|
88
|
+
revertCorrespondence: {
|
|
89
|
+
type: 'string'
|
|
90
|
+
},
|
|
91
|
+
mergePattern: {
|
|
92
|
+
type: 'string'
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
const { flags } = cli;
|
|
97
|
+
let tagsOptions = parseTagsOptions(flags);
|
|
98
|
+
let commitsOptions = parseCommitsOptions(flags);
|
|
99
|
+
let parserOptions = parseParserOptions(flags);
|
|
100
|
+
let whatBump;
|
|
101
|
+
const { preset, config } = flags;
|
|
102
|
+
const bumper = new Bumper(process.cwd());
|
|
103
|
+
if (preset) {
|
|
104
|
+
bumper.loadPreset(preset);
|
|
105
|
+
}
|
|
106
|
+
else if (config) {
|
|
107
|
+
const configOptions = await loadDataFile(config);
|
|
108
|
+
if (configOptions.tags) {
|
|
109
|
+
tagsOptions = {
|
|
110
|
+
...configOptions.tags,
|
|
111
|
+
...tagsOptions
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (configOptions.commits) {
|
|
115
|
+
commitsOptions = {
|
|
116
|
+
...configOptions.commits,
|
|
117
|
+
...commitsOptions
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
if (configOptions.parser) {
|
|
121
|
+
parserOptions = {
|
|
122
|
+
...configOptions.parser,
|
|
123
|
+
...parserOptions
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
whatBump ||= configOptions.whatBump;
|
|
127
|
+
}
|
|
128
|
+
if (tagsOptions) {
|
|
129
|
+
bumper.tag(tagsOptions);
|
|
130
|
+
}
|
|
131
|
+
if (commitsOptions) {
|
|
132
|
+
bumper.commits(commitsOptions, parserOptions || undefined);
|
|
133
|
+
}
|
|
134
|
+
const data = await bumper.bump(whatBump);
|
|
135
|
+
if (data.releaseType) {
|
|
136
|
+
console.log(data.releaseType);
|
|
137
|
+
}
|
|
138
|
+
if (flags.verbose && data.reason) {
|
|
139
|
+
console.log(`Reason: ${data.reason}`);
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY2xpL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFDQSxPQUFPLElBQUksTUFBTSxNQUFNLENBQUE7QUFFdkIsT0FBTyxFQUFFLE1BQU0sRUFBRSxNQUFNLGFBQWEsQ0FBQTtBQUNwQyxPQUFPLEVBQ0wsbUJBQW1CLEVBQ25CLGdCQUFnQixFQUNoQixrQkFBa0IsRUFDbkIsTUFBTSxjQUFjLENBQUE7QUFDckIsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLFlBQVksQ0FBQTtBQUV6QyxNQUFNLEdBQUcsR0FBRyxJQUFJLENBQUM7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztDQXFCaEIsRUFBRTtJQUNELFVBQVUsRUFBRSxNQUFNLENBQUMsSUFBSTtJQUN2QixLQUFLLEVBQUU7UUFDTCxNQUFNLEVBQUU7WUFDTixTQUFTLEVBQUUsR0FBRztZQUNkLElBQUksRUFBRSxRQUFRO1NBQ2Y7UUFDRC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RCxJQUFJLGFBQWEsQ0FBQyxNQUFNLEVBQUU7UUFDeEIsYUFBYSxHQUFHO1lBQ2QsR0FBRyxhQUFhLENBQUMsTUFBTTtZQUN2QixHQUFHLGFBQWE7U0FDakIsQ0FBQTtLQUNGO0lBRUQsUUFBUSxLQUFLLGFBQWEsQ0FBQyxRQUFRLENBQUE7Q0FDcEM7QUFFRCxJQUFJLFdBQVcsRUFBRTtJQUNmLE1BQU0sQ0FBQyxHQUFHLENBQUMsV0FBVyxDQUFDLENBQUE7Q0FDeEI7QUFFRCxJQUFJLGNBQWMsRUFBRTtJQUNsQixNQUFNLENBQUMsT0FBTyxDQUFDLGNBQWMsRUFBRSxhQUFhLElBQUksU0FBUyxDQUFDLENBQUE7Q0FDM0Q7QUFFRCxNQUFNLElBQUksR0FBRyxNQUFNLE1BQU0sQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDLENBQUE7QUFFeEMsSUFBSSxJQUFJLENBQUMsV0FBVyxFQUFFO0lBQ3BCLE9BQU8sQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxDQUFBO0NBQzlCO0FBRUQsSUFBSSxLQUFLLENBQUMsT0FBTyxJQUFJLElBQUksQ0FBQyxNQUFNLEVBQUU7SUFDaEMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxXQUFXLElBQUksQ0FBQyxNQUFNLEVBQUUsQ0FBQyxDQUFBO0NBQ3RDIn0=
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ParserStreamOptions } from 'conventional-commits-parser';
|
|
2
|
+
import type { GetCommitsParams, GetSemverTagsParams, Params } from '@conventional-changelog/git-client';
|
|
3
|
+
export declare function parseTagsOptions(options: Record<string, unknown>): GetSemverTagsParams & Params | null;
|
|
4
|
+
export declare function parseCommitsOptions(options: Record<string, unknown>): GetCommitsParams & Params | null;
|
|
5
|
+
export declare function parseParserOptions(options: Record<string, unknown>): ParserStreamOptions | null;
|
|
6
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/cli/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAA;AAOvG,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,mBAAmB,GAAG,MAAM,GAAG,IAAI,CAoBtG;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,gBAAgB,GAAG,MAAM,GAAG,IAAI,CAYtG;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,mBAAmB,GAAG,IAAI,CAkD/F"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { packagePrefix } from '@conventional-changelog/git-client';
|
|
2
|
+
function trim(str) {
|
|
3
|
+
return str.trim();
|
|
4
|
+
}
|
|
5
|
+
export function parseTagsOptions(options) {
|
|
6
|
+
const result = {};
|
|
7
|
+
if (typeof options.tagPrefix === 'string') {
|
|
8
|
+
result.prefix = options.tagPrefix;
|
|
9
|
+
}
|
|
10
|
+
if (typeof options.lernaPackage === 'string') {
|
|
11
|
+
result.prefix = packagePrefix(options.lernaPackage);
|
|
12
|
+
}
|
|
13
|
+
if (options.skipUnstable) {
|
|
14
|
+
result.skipUnstable = true;
|
|
15
|
+
}
|
|
16
|
+
if (!Object.keys(result).length) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
export function parseCommitsOptions(options) {
|
|
22
|
+
const result = {};
|
|
23
|
+
if (typeof options.commitPath === 'string') {
|
|
24
|
+
result.path = options.commitPath;
|
|
25
|
+
}
|
|
26
|
+
if (!Object.keys(result).length) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
export function parseParserOptions(options) {
|
|
32
|
+
const result = {};
|
|
33
|
+
if (typeof options.headerPattern === 'string') {
|
|
34
|
+
result.headerPattern = new RegExp(options.headerPattern);
|
|
35
|
+
}
|
|
36
|
+
if (typeof options.headerCorrespondence === 'string') {
|
|
37
|
+
result.headerCorrespondence = options.headerCorrespondence.split(',').map(trim);
|
|
38
|
+
}
|
|
39
|
+
if (typeof options.referenceActions === 'string') {
|
|
40
|
+
result.referenceActions = options.referenceActions.split(',').map(trim);
|
|
41
|
+
}
|
|
42
|
+
if (typeof options.issuePrefixes === 'string') {
|
|
43
|
+
result.issuePrefixes = options.issuePrefixes.split(',').map(trim);
|
|
44
|
+
}
|
|
45
|
+
if (typeof options.noteKeywords === 'string') {
|
|
46
|
+
result.noteKeywords = options.noteKeywords.split(',').map(trim);
|
|
47
|
+
}
|
|
48
|
+
if (typeof options.fieldPattern === 'string') {
|
|
49
|
+
result.fieldPattern = new RegExp(options.fieldPattern);
|
|
50
|
+
}
|
|
51
|
+
if (typeof options.revertPattern === 'string') {
|
|
52
|
+
result.revertPattern = new RegExp(options.revertPattern);
|
|
53
|
+
}
|
|
54
|
+
if (typeof options.revertCorrespondence === 'string') {
|
|
55
|
+
result.revertCorrespondence = options.revertCorrespondence.split(',').map(trim);
|
|
56
|
+
}
|
|
57
|
+
if (typeof options.mergePattern === 'string') {
|
|
58
|
+
result.mergePattern = new RegExp(options.mergePattern);
|
|
59
|
+
}
|
|
60
|
+
if (options.verbose) {
|
|
61
|
+
result.warn = console.warn.bind(console);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
result.warn = true;
|
|
65
|
+
}
|
|
66
|
+
if (!Object.keys(result).length) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
return options;
|
|
70
|
+
}
|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BSSxDQUFDLE9BQU8sQ0FBQyxDQUFBO0tBQ3pDO1NBQU07UUFDTCxNQUFNLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQTtLQUNuQjtJQUVELElBQUksQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFDLE1BQU0sRUFBRTtRQUMvQixPQUFPLElBQUksQ0FBQTtLQUNaO0lBRUQsT0FBTyxPQUFPLENBQUE7QUFDaEIsQ0FBQyJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/cli/utils.ts"],"names":[],"mappings":"AAQA,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAWpE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { resolve, extname } from 'path';
|
|
2
|
+
import { pathToFileURL } from 'url';
|
|
3
|
+
import { readFile } from 'fs/promises';
|
|
4
|
+
function relativeResolve(filePath) {
|
|
5
|
+
return pathToFileURL(resolve(process.cwd(), filePath));
|
|
6
|
+
}
|
|
7
|
+
export async function loadDataFile(filePath) {
|
|
8
|
+
const resolvedFilePath = relativeResolve(filePath);
|
|
9
|
+
const ext = extname(resolvedFilePath.toString());
|
|
10
|
+
if (ext === '.json') {
|
|
11
|
+
return JSON.parse(await readFile(resolvedFilePath, 'utf8'));
|
|
12
|
+
}
|
|
13
|
+
// @ts-expect-error Dynamic import actually works with file URLs
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
15
|
+
return (await import(resolvedFilePath)).default;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY2xpL3V0aWxzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJB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type { ParserStreamOptions, Commit } from 'conventional-commits-parser';
|
|
2
|
+
import type { GetSemverTagsParams, GetCommitsParams, Params } from '@conventional-changelog/git-client';
|
|
3
|
+
export interface BumperRecommendation {
|
|
4
|
+
level?: 0 | 1 | 2;
|
|
5
|
+
reason?: string;
|
|
6
|
+
releaseType?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface Preset {
|
|
9
|
+
whatBump(commits: Commit[]): Promise<BumperRecommendation | null | undefined>;
|
|
10
|
+
tags?: GetSemverTagsParams & Params;
|
|
11
|
+
commits?: GetCommitsParams & Params;
|
|
12
|
+
parser?: ParserStreamOptions;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,MAAM,EACP,MAAM,6BAA6B,CAAA;AACpC,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,MAAM,EACP,MAAM,oCAAoC,CAAA;AAE3C,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,GAAG,SAAS,CAAC,CAAA;IAC7E,IAAI,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAAA;IACnC,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAAA;IACnC,MAAM,CAAC,EAAE,mBAAmB,CAAA;CAC7B"}
|
package/dist/types.js
ADDED
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAKrF"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test if a value is an iterable
|
|
3
|
+
* @param value
|
|
4
|
+
* @returns `true` if value is an iterable, `false` otherwise
|
|
5
|
+
*/
|
|
6
|
+
export function isIterable(value) {
|
|
7
|
+
return value !== null && (typeof value[Symbol.iterator] === 'function'
|
|
8
|
+
|| typeof value[Symbol.asyncIterator] === 'function');
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7R0FJRztBQUNILE1BQU0sVUFBVSxVQUFVLENBQUksS0FBYztJQUMxQyxPQUFPLEtBQUssS0FBSyxJQUFJLElBQUksQ0FDdkIsT0FBUSxLQUFxQixDQUFDLE1BQU0sQ0FBQyxRQUFRLENBQUMsS0FBSyxVQUFVO1dBQzFELE9BQVEsS0FBMEIsQ0FBQyxNQUFNLENBQUMsYUFBYSxDQUFDLEtBQUssVUFBVSxDQUMzRSxDQUFBO0FBQ0gsQ0FBQyJ9
|
package/package.json
CHANGED
|
@@ -1,44 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "conventional-recommended-bump",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"url": "https://github.com/conventional-changelog/conventional-changelog/issues"
|
|
7
|
-
},
|
|
8
|
-
"homepage": "https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-recommended-bump#readme",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "10.0.0",
|
|
5
|
+
"description": "Get a recommended version bump based on conventional commits.",
|
|
9
6
|
"author": {
|
|
10
7
|
"name": "Steve Mao",
|
|
11
8
|
"email": "maochenyan@gmail.com",
|
|
12
9
|
"url": "https://github.com/stevemao"
|
|
13
10
|
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"homepage": "https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-recommended-bump#readme",
|
|
14
13
|
"repository": {
|
|
15
14
|
"type": "git",
|
|
16
|
-
"url": "https://github.com/conventional-changelog/conventional-changelog.git"
|
|
15
|
+
"url": "https://github.com/conventional-changelog/conventional-changelog.git",
|
|
16
|
+
"directory": "packages/conventional-recommended-bump"
|
|
17
17
|
},
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
"node": ">=16"
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/conventional-changelog/conventional-changelog/issues"
|
|
21
20
|
},
|
|
22
|
-
"files": [
|
|
23
|
-
"index.js",
|
|
24
|
-
"cli.mjs"
|
|
25
|
-
],
|
|
26
21
|
"keywords": [
|
|
27
22
|
"conventional-recommended-bump",
|
|
28
23
|
"recommend",
|
|
29
24
|
"conventional",
|
|
30
25
|
"bump"
|
|
31
26
|
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18"
|
|
29
|
+
},
|
|
30
|
+
"exports": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/index.js"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist"
|
|
36
|
+
],
|
|
32
37
|
"dependencies": {
|
|
33
|
-
"meow": "^
|
|
34
|
-
"conventional-changelog-
|
|
35
|
-
"conventional-
|
|
36
|
-
"conventional-commits-parser": "^
|
|
37
|
-
"
|
|
38
|
-
"git-semver-tags": "^7.0.0"
|
|
38
|
+
"meow": "^13.0.0",
|
|
39
|
+
"@conventional-changelog/git-client": "^1.0.0",
|
|
40
|
+
"conventional-changelog-preset-loader": "^5.0.0",
|
|
41
|
+
"conventional-commits-parser": "^6.0.0",
|
|
42
|
+
"conventional-commits-filter": "^5.0.0"
|
|
39
43
|
},
|
|
40
|
-
"bin":
|
|
41
|
-
|
|
42
|
-
"conventional-changelog-conventionalcommits": "^7.0.2"
|
|
44
|
+
"bin": {
|
|
45
|
+
"conventional-recommended-bump": "./dist/cli/index.js"
|
|
43
46
|
}
|
|
44
47
|
}
|
package/cli.mjs
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { resolve } from 'path'
|
|
3
|
-
import { pathToFileURL } from 'url'
|
|
4
|
-
import meow from 'meow'
|
|
5
|
-
import conventionalRecommendedBump from './index.js'
|
|
6
|
-
|
|
7
|
-
function relativeResolve (filePath) {
|
|
8
|
-
return pathToFileURL(resolve(process.cwd(), filePath))
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const cli = meow(`
|
|
12
|
-
Usage
|
|
13
|
-
conventional-recommended-bump
|
|
14
|
-
|
|
15
|
-
Example
|
|
16
|
-
conventional-recommended-bump
|
|
17
|
-
|
|
18
|
-
Options
|
|
19
|
-
-p, --preset Name of the preset you want to use
|
|
20
|
-
-g, --config A filepath of your config script
|
|
21
|
-
-h, --header-pattern Regex to match header pattern
|
|
22
|
-
-c, --header-correspondence Comma separated parts used to define what capturing group of 'headerPattern' captures what
|
|
23
|
-
-r, --reference-actions Comma separated keywords that used to reference issues
|
|
24
|
-
-i, --issue-prefixes Comma separated prefixes of an issue
|
|
25
|
-
-n, --note-keywords Comma separated keywords for important notes
|
|
26
|
-
-f, --field-pattern Regex to match other fields
|
|
27
|
-
-v, --verbose Verbose output
|
|
28
|
-
-l, --lerna-package Recommend a bump for a specific lerna package (:pkg-name@1.0.0)
|
|
29
|
-
-t, --tag-prefix Tag prefix to consider when reading the tags
|
|
30
|
-
--commit-path Recommend a bump scoped to a specific directory
|
|
31
|
-
--skip-unstable If given, unstable tags will be skipped, e.g., x.x.x-alpha.1, x.x.x-rc.2
|
|
32
|
-
`, {
|
|
33
|
-
importMeta: import.meta,
|
|
34
|
-
flags: {
|
|
35
|
-
preset: {
|
|
36
|
-
shortFlag: 'p'
|
|
37
|
-
},
|
|
38
|
-
config: {
|
|
39
|
-
shortFlag: 'g'
|
|
40
|
-
},
|
|
41
|
-
headerPattern: {
|
|
42
|
-
shortFlag: 'h'
|
|
43
|
-
},
|
|
44
|
-
headerCorrespondence: {
|
|
45
|
-
shortFlag: 'c'
|
|
46
|
-
},
|
|
47
|
-
referenceActions: {
|
|
48
|
-
shortFlag: 'r'
|
|
49
|
-
},
|
|
50
|
-
issuePrefixes: {
|
|
51
|
-
shortFlag: 'i'
|
|
52
|
-
},
|
|
53
|
-
noteKeywords: {
|
|
54
|
-
shortFlag: 'n'
|
|
55
|
-
},
|
|
56
|
-
fieldPattern: {
|
|
57
|
-
shortFlag: 'f'
|
|
58
|
-
},
|
|
59
|
-
verbose: {
|
|
60
|
-
shortFlag: 'v'
|
|
61
|
-
},
|
|
62
|
-
lernaPackage: {
|
|
63
|
-
shortFlag: 'l'
|
|
64
|
-
},
|
|
65
|
-
tagPrefix: {
|
|
66
|
-
shortFlag: 't'
|
|
67
|
-
},
|
|
68
|
-
skipUnstable: {
|
|
69
|
-
type: 'boolean'
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
const options = {
|
|
75
|
-
path: cli.flags.commitPath,
|
|
76
|
-
lernaPackage: cli.flags.lernaPackage,
|
|
77
|
-
tagPrefix: cli.flags.tagPrefix,
|
|
78
|
-
skipUnstable: cli.flags.skipUnstable
|
|
79
|
-
}
|
|
80
|
-
const flags = cli.flags
|
|
81
|
-
const preset = flags.preset
|
|
82
|
-
const config = flags.config
|
|
83
|
-
|
|
84
|
-
if (preset) {
|
|
85
|
-
options.preset = preset
|
|
86
|
-
delete flags.preset
|
|
87
|
-
} else if (config) {
|
|
88
|
-
options.config = (await import(relativeResolve(config))).default
|
|
89
|
-
delete flags.config
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (flags.verbose) {
|
|
93
|
-
options.warn = console.warn.bind(console)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const data = await conventionalRecommendedBump(options, flags)
|
|
97
|
-
|
|
98
|
-
if (data.releaseType) {
|
|
99
|
-
console.log(data.releaseType)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (flags.verbose && data.reason) {
|
|
103
|
-
console.log(`Reason: ${data.reason}`)
|
|
104
|
-
}
|
package/index.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
const conventionalCommitsFilter = require('conventional-commits-filter')
|
|
3
|
-
const conventionalCommitsParser = require('conventional-commits-parser')
|
|
4
|
-
const { loadPreset } = require('conventional-changelog-preset-loader')
|
|
5
|
-
const gitSemverTags = require('git-semver-tags')
|
|
6
|
-
const gitRawCommits = require('git-raw-commits')
|
|
7
|
-
|
|
8
|
-
const VERSIONS = ['major', 'minor', 'patch']
|
|
9
|
-
|
|
10
|
-
function noop () {}
|
|
11
|
-
|
|
12
|
-
async function conventionalRecommendedBump (optionsArgument, parserOptsArgument) {
|
|
13
|
-
if (typeof optionsArgument !== 'object') {
|
|
14
|
-
throw new Error('The \'options\' argument must be an object.')
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const options = Object.assign({
|
|
18
|
-
ignoreReverted: true,
|
|
19
|
-
gitRawCommitsOpts: {}
|
|
20
|
-
}, optionsArgument)
|
|
21
|
-
|
|
22
|
-
let config = options.config || {}
|
|
23
|
-
if (options.preset) {
|
|
24
|
-
config = await loadPreset(options.preset)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const whatBump = options.whatBump ||
|
|
28
|
-
((config.recommendedBumpOpts && config.recommendedBumpOpts.whatBump)
|
|
29
|
-
? config.recommendedBumpOpts.whatBump
|
|
30
|
-
: noop)
|
|
31
|
-
|
|
32
|
-
if (typeof whatBump !== 'function') {
|
|
33
|
-
throw Error('whatBump must be a function')
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// TODO: For now we defer to `config.recommendedBumpOpts.parserOpts` if it exists, as our initial refactor
|
|
37
|
-
// efforts created a `parserOpts` object under the `recommendedBumpOpts` object in each preset package.
|
|
38
|
-
// In the future we want to merge differences found in `recommendedBumpOpts.parserOpts` into the top-level
|
|
39
|
-
// `parserOpts` object and remove `recommendedBumpOpts.parserOpts` from each preset package if it exists.
|
|
40
|
-
const parserOpts = Object.assign({},
|
|
41
|
-
config.recommendedBumpOpts && config.recommendedBumpOpts.parserOpts
|
|
42
|
-
? config.recommendedBumpOpts.parserOpts
|
|
43
|
-
: config.parserOpts,
|
|
44
|
-
parserOptsArgument)
|
|
45
|
-
|
|
46
|
-
const warn = typeof parserOpts.warn === 'function' ? parserOpts.warn : noop
|
|
47
|
-
const tags = await gitSemverTags({
|
|
48
|
-
lernaTags: !!options.lernaPackage,
|
|
49
|
-
package: options.lernaPackage,
|
|
50
|
-
tagPrefix: options.tagPrefix,
|
|
51
|
-
skipUnstable: options.skipUnstable,
|
|
52
|
-
cwd: options.cwd
|
|
53
|
-
})
|
|
54
|
-
const commitsStream = gitRawCommits({
|
|
55
|
-
format: '%B%n-hash-%n%H',
|
|
56
|
-
from: tags[0] || '',
|
|
57
|
-
path: options.path,
|
|
58
|
-
...options.gitRawCommitsOpts
|
|
59
|
-
}, {
|
|
60
|
-
cwd: options.cwd
|
|
61
|
-
})
|
|
62
|
-
.pipe(conventionalCommitsParser(parserOpts))
|
|
63
|
-
let commits = []
|
|
64
|
-
|
|
65
|
-
for await (const commit of commitsStream) {
|
|
66
|
-
commits.push(commit)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
commits = options.ignoreReverted ? conventionalCommitsFilter(commits) : commits
|
|
70
|
-
|
|
71
|
-
if (!commits || !commits.length) {
|
|
72
|
-
warn('No commits since last release')
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
let result = whatBump(commits, options)
|
|
76
|
-
|
|
77
|
-
if (result && result.level != null) {
|
|
78
|
-
result.releaseType = VERSIONS[result.level]
|
|
79
|
-
} else if (result == null) {
|
|
80
|
-
result = {}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return result
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
module.exports = conventionalRecommendedBump
|