fork-version 1.8.0 → 2.0.2
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/CHANGELOG.md +23 -0
- package/dist/{chunk-RLGF46N7.js → chunk-D2PQT6ZM.js} +806 -147
- package/dist/chunk-D2PQT6ZM.js.map +1 -0
- package/dist/{chunk-EAMGFCWC.cjs → chunk-RJRVHSEG.cjs} +808 -146
- package/dist/chunk-RJRVHSEG.cjs.map +1 -0
- package/dist/cli.cjs +14 -13
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +8 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +27 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +400 -326
- package/dist/index.d.ts +400 -326
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +30 -31
- package/dist/chunk-EAMGFCWC.cjs.map +0 -1
- package/dist/chunk-RLGF46N7.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,330 +1,294 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ReleaseType } from 'semver';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
interface ParserOptions {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Pattern to match commit subjects
|
|
7
|
+
* - Expected capture groups: `type` `title`
|
|
8
|
+
* - Optional capture groups: `scope`, `breakingChange`
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
+
subjectPattern: RegExp | undefined;
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* ```js
|
|
14
|
-
* ["bower.json", "deno.json", "deno.jsonc", "jsr.json", "jsr.jsonc", "manifest.json", "npm-shrinkwrap.json", "package-lock.json", "package.json"]
|
|
15
|
-
* ```
|
|
12
|
+
* Pattern to match merge commits
|
|
13
|
+
* - Expected capture groups: `id`, `source`
|
|
16
14
|
*/
|
|
17
|
-
|
|
15
|
+
mergePattern: RegExp | undefined;
|
|
18
16
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* Internally we're using [glob](https://github.com/isaacs/node-glob) to match files.
|
|
22
|
-
*
|
|
23
|
-
* Read more about the pattern syntax [here](https://github.com/isaacs/node-glob/tree/v10.3.12?tab=readme-ov-file#glob-primer).
|
|
24
|
-
*
|
|
25
|
-
* @default undefined
|
|
26
|
-
* @example "*.json"
|
|
17
|
+
* Pattern to match revert commits
|
|
18
|
+
* - Expected capture groups: `subject`, `hash`
|
|
27
19
|
*/
|
|
28
|
-
|
|
20
|
+
revertPattern: RegExp | undefined;
|
|
29
21
|
/**
|
|
30
|
-
*
|
|
31
|
-
* @default
|
|
32
|
-
* ```js
|
|
33
|
-
* process.cwd()
|
|
34
|
-
* ```
|
|
22
|
+
* Pattern to match commented out lines which will be trimmed
|
|
35
23
|
*/
|
|
36
|
-
|
|
24
|
+
commentPattern: RegExp | undefined;
|
|
37
25
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
26
|
+
* Pattern to match mentions
|
|
27
|
+
* - Expected capture groups: `username`
|
|
40
28
|
*/
|
|
41
|
-
|
|
29
|
+
mentionPattern: RegExp | undefined;
|
|
42
30
|
/**
|
|
43
|
-
*
|
|
31
|
+
* List of action labels to match reference sections
|
|
44
32
|
* @default
|
|
45
|
-
*
|
|
46
|
-
* # Changelog
|
|
47
|
-
*
|
|
48
|
-
* All notable changes to this project will be documented in this file. See [fork-version](https://github.com/eglavin/fork-version) for commit guidelines.
|
|
49
|
-
* ```
|
|
33
|
+
* ["close", "closes", "closed", "fix", "fixes", "fixed", "resolve", "resolves", "resolved"]
|
|
50
34
|
*/
|
|
51
|
-
|
|
35
|
+
referenceActions?: string[];
|
|
52
36
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* For instance if your version tag is prefixed by "version/" instead of "v" you have to specify
|
|
56
|
-
* `tagPrefix: "version/"`.
|
|
57
|
-
*
|
|
58
|
-
* `tagPrefix` can also be used for a monorepo environment where you might want to deploy
|
|
59
|
-
* multiple package from the same repository. In this case you can specify a prefix for
|
|
60
|
-
* each package:
|
|
61
|
-
*
|
|
62
|
-
* | Example Value | Tag Created |
|
|
63
|
-
* |:-------------------------|:------------------------------|
|
|
64
|
-
* | "" | `1.2.3` |
|
|
65
|
-
* | "version/" | `version/1.2.3` |
|
|
66
|
-
* | "@eglavin/fork-version-" | `@eglavin/fork-version-1.2.3` |
|
|
67
|
-
*
|
|
68
|
-
* @example "", "version/", "@eglavin/fork-version-"
|
|
69
|
-
* @default "v"
|
|
37
|
+
* Pattern to match reference sections
|
|
38
|
+
* - Expected capture groups: `action`, `reference`
|
|
70
39
|
*/
|
|
71
|
-
|
|
40
|
+
referenceActionPattern: RegExp | undefined;
|
|
72
41
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* |:--------------|:-----------------|
|
|
77
|
-
* | true | `1.2.3-0` |
|
|
78
|
-
* | "alpha" | `1.2.3-alpha-0` |
|
|
79
|
-
* | "beta" | `1.2.3-beta-0` |
|
|
80
|
-
*
|
|
81
|
-
* @example true, "alpha", "beta", "rc"
|
|
82
|
-
* @default undefined
|
|
83
|
-
*/
|
|
84
|
-
preRelease: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
|
|
85
|
-
/**
|
|
86
|
-
* If set, Fork-Version will use this version instead of trying to determine one.
|
|
87
|
-
* @example "1.0.0"
|
|
88
|
-
* @default undefined
|
|
42
|
+
* List of issue prefixes to match issue ids
|
|
43
|
+
* @default
|
|
44
|
+
* ["#"]
|
|
89
45
|
*/
|
|
90
|
-
|
|
46
|
+
issuePrefixes?: string[];
|
|
91
47
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* @default undefined
|
|
48
|
+
* Pattern to match issue references
|
|
49
|
+
* - Expected capture groups: `repository`, `prefix`, `issue`
|
|
95
50
|
*/
|
|
96
|
-
|
|
51
|
+
issuePattern: RegExp | undefined;
|
|
97
52
|
/**
|
|
98
|
-
*
|
|
99
|
-
* @
|
|
100
|
-
*
|
|
53
|
+
* List of keywords to match note titles
|
|
54
|
+
* @default
|
|
55
|
+
* ["BREAKING CHANGE", "BREAKING-CHANGE"]
|
|
101
56
|
*/
|
|
102
|
-
|
|
57
|
+
noteKeywords?: string[];
|
|
103
58
|
/**
|
|
104
|
-
*
|
|
105
|
-
*
|
|
59
|
+
* Pattern to match note sections
|
|
60
|
+
* - Expected capture groups: `title`
|
|
61
|
+
* - Optional capture groups: `text`
|
|
106
62
|
*/
|
|
63
|
+
notePattern: RegExp | undefined;
|
|
64
|
+
}
|
|
65
|
+
declare function createParserOptions(userOptions?: Partial<ParserOptions>): ParserOptions;
|
|
66
|
+
|
|
67
|
+
declare const ForkConfigSchema: z.ZodObject<{
|
|
68
|
+
inspectVersion: z.ZodBoolean;
|
|
69
|
+
files: z.ZodArray<z.ZodString>;
|
|
70
|
+
glob: z.ZodOptional<z.ZodString>;
|
|
71
|
+
path: z.ZodString;
|
|
72
|
+
changelog: z.ZodString;
|
|
73
|
+
header: z.ZodString;
|
|
74
|
+
tagPrefix: z.ZodString;
|
|
75
|
+
preRelease: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
|
|
76
|
+
currentVersion: z.ZodOptional<z.ZodString>;
|
|
77
|
+
nextVersion: z.ZodOptional<z.ZodString>;
|
|
78
|
+
releaseAs: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"major">, z.ZodLiteral<"minor">, z.ZodLiteral<"patch">]>>;
|
|
107
79
|
allowMultipleVersions: z.ZodBoolean;
|
|
108
|
-
/**
|
|
109
|
-
* Commit all changes, not just files updated by Fork-Version.
|
|
110
|
-
* @default false
|
|
111
|
-
*/
|
|
112
80
|
commitAll: z.ZodBoolean;
|
|
113
|
-
/**
|
|
114
|
-
* By default the conventional-changelog spec will only add commit types of `feat` and `fix` to the generated changelog.
|
|
115
|
-
* If this flag is set, all [default commit types](https://github.com/conventional-changelog/conventional-changelog-config-spec/blob/238093090c14bd7d5151eb5316e635623ce633f9/versions/2.2.0/schema.json#L18)
|
|
116
|
-
* will be added to the changelog.
|
|
117
|
-
* @default false
|
|
118
|
-
*/
|
|
119
81
|
changelogAll: z.ZodBoolean;
|
|
120
|
-
/**
|
|
121
|
-
* Output debug information.
|
|
122
|
-
* @default false
|
|
123
|
-
*/
|
|
124
82
|
debug: z.ZodBoolean;
|
|
125
|
-
/**
|
|
126
|
-
* No output will be written to disk or committed.
|
|
127
|
-
* @default false
|
|
128
|
-
*/
|
|
129
83
|
dryRun: z.ZodBoolean;
|
|
130
|
-
/**
|
|
131
|
-
* Run without logging to the terminal.
|
|
132
|
-
* @default false
|
|
133
|
-
*/
|
|
134
84
|
silent: z.ZodBoolean;
|
|
135
|
-
/**
|
|
136
|
-
* If unable to find a version in the given files, fallback and attempt to use the latest git tag.
|
|
137
|
-
* @default true
|
|
138
|
-
*/
|
|
139
85
|
gitTagFallback: z.ZodBoolean;
|
|
140
|
-
/**
|
|
141
|
-
* If true, git will sign the commit with the systems GPG key.
|
|
142
|
-
* @see {@link https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--Sltkeyidgt Git - GPG Sign Commits}
|
|
143
|
-
* @default false
|
|
144
|
-
*/
|
|
145
86
|
sign: z.ZodBoolean;
|
|
146
|
-
/**
|
|
147
|
-
* If true, git will run user defined git hooks before committing.
|
|
148
|
-
* @see {@link https://git-scm.com/docs/githooks Git - Git Hooks}
|
|
149
|
-
* @default false
|
|
150
|
-
*/
|
|
151
87
|
verify: z.ZodBoolean;
|
|
152
|
-
/**
|
|
153
|
-
* Skip the bump step.
|
|
154
|
-
* @default false
|
|
155
|
-
*/
|
|
156
88
|
skipBump: z.ZodBoolean;
|
|
157
|
-
/**
|
|
158
|
-
* Skip the changelog step.
|
|
159
|
-
* @default false
|
|
160
|
-
*/
|
|
161
89
|
skipChangelog: z.ZodBoolean;
|
|
162
|
-
/**
|
|
163
|
-
* Skip the commit step.
|
|
164
|
-
* @default false
|
|
165
|
-
*/
|
|
166
90
|
skipCommit: z.ZodBoolean;
|
|
167
|
-
/**
|
|
168
|
-
* Skip the tag step.
|
|
169
|
-
* @default false
|
|
170
|
-
*/
|
|
171
91
|
skipTag: z.ZodBoolean;
|
|
172
|
-
/**
|
|
173
|
-
* Override the default "conventional-changelog-conventionalcommits" preset configuration.
|
|
174
|
-
*/
|
|
175
92
|
changelogPresetConfig: z.ZodObject<{
|
|
176
93
|
types: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
177
|
-
/**
|
|
178
|
-
* The type of commit message.
|
|
179
|
-
* @example "feat", "fix", "chore", etc..
|
|
180
|
-
*/
|
|
181
94
|
type: z.ZodString;
|
|
182
|
-
/**
|
|
183
|
-
* The scope of the commit message.
|
|
184
|
-
*/
|
|
185
95
|
scope: z.ZodOptional<z.ZodString>;
|
|
186
|
-
/**
|
|
187
|
-
* The section of the `CHANGELOG` the commit should show up in.
|
|
188
|
-
*/
|
|
189
96
|
section: z.ZodOptional<z.ZodString>;
|
|
190
|
-
/**
|
|
191
|
-
* Should show in the generated changelog message?
|
|
192
|
-
*/
|
|
193
97
|
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
194
|
-
},
|
|
195
|
-
type: string;
|
|
196
|
-
scope?: string | undefined;
|
|
197
|
-
section?: string | undefined;
|
|
198
|
-
hidden?: boolean | undefined;
|
|
199
|
-
}, {
|
|
200
|
-
type: string;
|
|
201
|
-
scope?: string | undefined;
|
|
202
|
-
section?: string | undefined;
|
|
203
|
-
hidden?: boolean | undefined;
|
|
204
|
-
}>, "many">>;
|
|
98
|
+
}, z.core.$strip>>>;
|
|
205
99
|
commitUrlFormat: z.ZodOptional<z.ZodString>;
|
|
206
100
|
compareUrlFormat: z.ZodOptional<z.ZodString>;
|
|
207
101
|
issueUrlFormat: z.ZodOptional<z.ZodString>;
|
|
208
102
|
userUrlFormat: z.ZodOptional<z.ZodString>;
|
|
209
103
|
releaseCommitMessageFormat: z.ZodOptional<z.ZodString>;
|
|
210
|
-
issuePrefixes: z.ZodOptional<z.ZodArray<z.ZodString
|
|
211
|
-
},
|
|
212
|
-
commitUrlFormat?: string | undefined;
|
|
213
|
-
compareUrlFormat?: string | undefined;
|
|
214
|
-
issueUrlFormat?: string | undefined;
|
|
215
|
-
userUrlFormat?: string | undefined;
|
|
216
|
-
releaseCommitMessageFormat?: string | undefined;
|
|
217
|
-
types?: {
|
|
218
|
-
type: string;
|
|
219
|
-
scope?: string | undefined;
|
|
220
|
-
section?: string | undefined;
|
|
221
|
-
hidden?: boolean | undefined;
|
|
222
|
-
}[] | undefined;
|
|
223
|
-
issuePrefixes?: string[] | undefined;
|
|
224
|
-
}, {
|
|
225
|
-
commitUrlFormat?: string | undefined;
|
|
226
|
-
compareUrlFormat?: string | undefined;
|
|
227
|
-
issueUrlFormat?: string | undefined;
|
|
228
|
-
userUrlFormat?: string | undefined;
|
|
229
|
-
releaseCommitMessageFormat?: string | undefined;
|
|
230
|
-
types?: {
|
|
231
|
-
type: string;
|
|
232
|
-
scope?: string | undefined;
|
|
233
|
-
section?: string | undefined;
|
|
234
|
-
hidden?: boolean | undefined;
|
|
235
|
-
}[] | undefined;
|
|
236
|
-
issuePrefixes?: string[] | undefined;
|
|
237
|
-
}>;
|
|
238
|
-
/**
|
|
239
|
-
* Add a suffix to the release commit message.
|
|
240
|
-
* @example "[skip ci]"
|
|
241
|
-
*/
|
|
104
|
+
issuePrefixes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
105
|
+
}, z.core.$strip>;
|
|
242
106
|
releaseMessageSuffix: z.ZodOptional<z.ZodString>;
|
|
243
|
-
},
|
|
244
|
-
inspectVersion: boolean;
|
|
245
|
-
files: string[];
|
|
246
|
-
path: string;
|
|
247
|
-
changelog: string;
|
|
248
|
-
header: string;
|
|
249
|
-
tagPrefix: string;
|
|
250
|
-
allowMultipleVersions: boolean;
|
|
251
|
-
commitAll: boolean;
|
|
252
|
-
changelogAll: boolean;
|
|
253
|
-
debug: boolean;
|
|
254
|
-
dryRun: boolean;
|
|
255
|
-
silent: boolean;
|
|
256
|
-
gitTagFallback: boolean;
|
|
257
|
-
sign: boolean;
|
|
258
|
-
verify: boolean;
|
|
259
|
-
skipBump: boolean;
|
|
260
|
-
skipChangelog: boolean;
|
|
261
|
-
skipCommit: boolean;
|
|
262
|
-
skipTag: boolean;
|
|
263
|
-
changelogPresetConfig: {
|
|
264
|
-
commitUrlFormat?: string | undefined;
|
|
265
|
-
compareUrlFormat?: string | undefined;
|
|
266
|
-
issueUrlFormat?: string | undefined;
|
|
267
|
-
userUrlFormat?: string | undefined;
|
|
268
|
-
releaseCommitMessageFormat?: string | undefined;
|
|
269
|
-
types?: {
|
|
270
|
-
type: string;
|
|
271
|
-
scope?: string | undefined;
|
|
272
|
-
section?: string | undefined;
|
|
273
|
-
hidden?: boolean | undefined;
|
|
274
|
-
}[] | undefined;
|
|
275
|
-
issuePrefixes?: string[] | undefined;
|
|
276
|
-
};
|
|
277
|
-
glob?: string | undefined;
|
|
278
|
-
preRelease?: string | boolean | undefined;
|
|
279
|
-
currentVersion?: string | undefined;
|
|
280
|
-
nextVersion?: string | undefined;
|
|
281
|
-
releaseAs?: "major" | "minor" | "patch" | undefined;
|
|
282
|
-
releaseMessageSuffix?: string | undefined;
|
|
283
|
-
}, {
|
|
284
|
-
inspectVersion: boolean;
|
|
285
|
-
files: string[];
|
|
286
|
-
path: string;
|
|
287
|
-
changelog: string;
|
|
288
|
-
header: string;
|
|
289
|
-
tagPrefix: string;
|
|
290
|
-
allowMultipleVersions: boolean;
|
|
291
|
-
commitAll: boolean;
|
|
292
|
-
changelogAll: boolean;
|
|
293
|
-
debug: boolean;
|
|
294
|
-
dryRun: boolean;
|
|
295
|
-
silent: boolean;
|
|
296
|
-
gitTagFallback: boolean;
|
|
297
|
-
sign: boolean;
|
|
298
|
-
verify: boolean;
|
|
299
|
-
skipBump: boolean;
|
|
300
|
-
skipChangelog: boolean;
|
|
301
|
-
skipCommit: boolean;
|
|
302
|
-
skipTag: boolean;
|
|
303
|
-
changelogPresetConfig: {
|
|
304
|
-
commitUrlFormat?: string | undefined;
|
|
305
|
-
compareUrlFormat?: string | undefined;
|
|
306
|
-
issueUrlFormat?: string | undefined;
|
|
307
|
-
userUrlFormat?: string | undefined;
|
|
308
|
-
releaseCommitMessageFormat?: string | undefined;
|
|
309
|
-
types?: {
|
|
310
|
-
type: string;
|
|
311
|
-
scope?: string | undefined;
|
|
312
|
-
section?: string | undefined;
|
|
313
|
-
hidden?: boolean | undefined;
|
|
314
|
-
}[] | undefined;
|
|
315
|
-
issuePrefixes?: string[] | undefined;
|
|
316
|
-
};
|
|
317
|
-
glob?: string | undefined;
|
|
318
|
-
preRelease?: string | boolean | undefined;
|
|
319
|
-
currentVersion?: string | undefined;
|
|
320
|
-
nextVersion?: string | undefined;
|
|
321
|
-
releaseAs?: "major" | "minor" | "patch" | undefined;
|
|
322
|
-
releaseMessageSuffix?: string | undefined;
|
|
323
|
-
}>;
|
|
107
|
+
}, z.core.$strip>;
|
|
324
108
|
|
|
325
109
|
type ForkConfig = z.infer<typeof ForkConfigSchema>;
|
|
326
110
|
type Config = Partial<ForkConfig>;
|
|
327
111
|
|
|
112
|
+
declare class Logger {
|
|
113
|
+
private config;
|
|
114
|
+
disableLogs: boolean;
|
|
115
|
+
constructor(config: Pick<ForkConfig, "silent" | "debug" | "inspectVersion">);
|
|
116
|
+
log(...messages: any[]): void;
|
|
117
|
+
warn(...messages: any[]): void;
|
|
118
|
+
error(...messages: any[]): void;
|
|
119
|
+
debug(...messages: any[]): void;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
interface CommitMerge {
|
|
123
|
+
id: string;
|
|
124
|
+
source: string;
|
|
125
|
+
}
|
|
126
|
+
interface CommitRevert {
|
|
127
|
+
hash: string;
|
|
128
|
+
subject: string;
|
|
129
|
+
}
|
|
130
|
+
interface CommitReference {
|
|
131
|
+
prefix: string;
|
|
132
|
+
issue: string;
|
|
133
|
+
action: string | null;
|
|
134
|
+
owner: string | null;
|
|
135
|
+
repository: string | null;
|
|
136
|
+
}
|
|
137
|
+
interface CommitNote {
|
|
138
|
+
title: string;
|
|
139
|
+
text: string;
|
|
140
|
+
}
|
|
141
|
+
interface Commit {
|
|
142
|
+
raw: string;
|
|
143
|
+
subject: string;
|
|
144
|
+
body: string;
|
|
145
|
+
hash: string;
|
|
146
|
+
/**
|
|
147
|
+
* Committer date in ISO 8601 format
|
|
148
|
+
* @example
|
|
149
|
+
* "2024-12-22T17:36:50Z"
|
|
150
|
+
*/
|
|
151
|
+
date: string;
|
|
152
|
+
/**
|
|
153
|
+
* Committer name (respects .mailmap)
|
|
154
|
+
*/
|
|
155
|
+
name: string;
|
|
156
|
+
/**
|
|
157
|
+
* Committer email (respects .mailmap)
|
|
158
|
+
*/
|
|
159
|
+
email: string;
|
|
160
|
+
type: string;
|
|
161
|
+
scope: string;
|
|
162
|
+
breakingChange: string;
|
|
163
|
+
title: string;
|
|
164
|
+
merge: CommitMerge | null;
|
|
165
|
+
revert: CommitRevert | null;
|
|
166
|
+
mentions: string[];
|
|
167
|
+
references: CommitReference[];
|
|
168
|
+
notes: CommitNote[];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
declare class CommitParser {
|
|
172
|
+
#private;
|
|
173
|
+
constructor(userOptions?: Partial<ParserOptions>);
|
|
174
|
+
setLogger(logger: Logger): this;
|
|
175
|
+
createCommit(): Commit;
|
|
176
|
+
/**
|
|
177
|
+
* Parse the raw commit message into its expected parts
|
|
178
|
+
* - subject
|
|
179
|
+
* - body
|
|
180
|
+
* - hash
|
|
181
|
+
* - date
|
|
182
|
+
* - name
|
|
183
|
+
* - email
|
|
184
|
+
*
|
|
185
|
+
* @throws {ParserError}
|
|
186
|
+
*/
|
|
187
|
+
parseRawCommit(rawCommit: string): Commit;
|
|
188
|
+
/**
|
|
189
|
+
* Parse the commit subject into its expected parts
|
|
190
|
+
* - type
|
|
191
|
+
* - scope (optional)
|
|
192
|
+
* - breaking change (optional)
|
|
193
|
+
* - title
|
|
194
|
+
*
|
|
195
|
+
* @throws {ParserError}
|
|
196
|
+
*/
|
|
197
|
+
parseSubject(commit: Commit): boolean;
|
|
198
|
+
/**
|
|
199
|
+
* Parse merge information from the commit subject
|
|
200
|
+
* @example
|
|
201
|
+
* ```txt
|
|
202
|
+
* "Merge pull request #123 from fork-version/feature"
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
parseMerge(commit: Commit): boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Parse revert information from the commit body
|
|
208
|
+
* @example
|
|
209
|
+
* ```txt
|
|
210
|
+
* "Revert "feat: initial commit"
|
|
211
|
+
*
|
|
212
|
+
* This reverts commit 4a79e9e546b4020d2882b7810dc549fa71960f4f."
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
parseRevert(commit: Commit): boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Search for mentions from the commit line
|
|
218
|
+
* @example
|
|
219
|
+
* ```txt
|
|
220
|
+
* "@fork-version"
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
parseMentions(line: string, outMentions: Set<string>): boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Search for references from the commit line
|
|
226
|
+
* @example
|
|
227
|
+
* ```txt
|
|
228
|
+
* "#1234"
|
|
229
|
+
* "owner/repo#1234"
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
parseReferenceParts(referenceText: string, action: string | null): CommitReference[] | undefined;
|
|
233
|
+
/**
|
|
234
|
+
* Search for actions and references from the commit line
|
|
235
|
+
* @example
|
|
236
|
+
* ```txt
|
|
237
|
+
* "Closes #1234"
|
|
238
|
+
* "fixes owner/repo#1234"
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
parseReferences(line: string, outReferences: CommitReference[]): boolean;
|
|
242
|
+
/**
|
|
243
|
+
* Search for notes from the commit line
|
|
244
|
+
* @example
|
|
245
|
+
* ```txt
|
|
246
|
+
* "BREAKING CHANGE: this is a breaking change"
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
parseNotes(line: string, outNotes: CommitNote[]): boolean;
|
|
250
|
+
/**
|
|
251
|
+
* Parse the raw commit for mentions, references and notes
|
|
252
|
+
*/
|
|
253
|
+
parseRawLines(commit: Commit): void;
|
|
254
|
+
/**
|
|
255
|
+
* Parse a commit log with the following format separated by new line characters:
|
|
256
|
+
* ```txt
|
|
257
|
+
* refactor: add test file
|
|
258
|
+
* Add a test file to the project
|
|
259
|
+
* 4ef2c86d393a9660aa9f753144256b1f200c16bd
|
|
260
|
+
* 2024-12-22T17:36:50Z
|
|
261
|
+
* Fork Version
|
|
262
|
+
* fork-version@example.com
|
|
263
|
+
* ```
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* ```ts
|
|
267
|
+
* parse("refactor: add test file\nAdd a test file to the project\n4ef2c86d393a9660aa9f753144256b1f200c16bd\n2024-12-22T17:36:50Z\nFork Version\nfork-version@example.com");
|
|
268
|
+
* ```
|
|
269
|
+
*
|
|
270
|
+
* The expected input value can be generated by running the following command:
|
|
271
|
+
* ```sh
|
|
272
|
+
* git log --format="%s%n%b%n%H%n%cI%n%cN%n%cE%n"
|
|
273
|
+
* ```
|
|
274
|
+
* @see {@link https://git-scm.com/docs/pretty-formats|Git Pretty Format Documentation}
|
|
275
|
+
*/
|
|
276
|
+
parse(rawCommit: string): Commit | undefined;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Filter out revert commits and their corresponding reverted commits,
|
|
281
|
+
* this function expects the input to be sorted by date in descending order
|
|
282
|
+
* from the most recent to the oldest commit.
|
|
283
|
+
*
|
|
284
|
+
* @example
|
|
285
|
+
* ```ts
|
|
286
|
+
* const commits: Commit[] = [...];
|
|
287
|
+
* const filteredCommits = filterRevertedCommits(commits);
|
|
288
|
+
* ```
|
|
289
|
+
*/
|
|
290
|
+
declare function filterRevertedCommits(parsedCommits: Commit[]): Commit[];
|
|
291
|
+
|
|
328
292
|
/**
|
|
329
293
|
* [Fork-Version - Config Properties](https://github.com/eglavin/fork-version/blob/main/README.md#config-properties)
|
|
330
294
|
*/
|
|
@@ -366,16 +330,165 @@ declare function getCliArguments(): {
|
|
|
366
330
|
|
|
367
331
|
declare function getUserConfig(cliArguments: Partial<ReturnType<typeof getCliArguments>>): Promise<ForkConfig>;
|
|
368
332
|
|
|
369
|
-
declare class
|
|
333
|
+
declare class Git {
|
|
334
|
+
#private;
|
|
370
335
|
private config;
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
336
|
+
constructor(config: Pick<ForkConfig, "path" | "dryRun">);
|
|
337
|
+
/**
|
|
338
|
+
* Add file contents to the index
|
|
339
|
+
*
|
|
340
|
+
* [git-add Documentation](https://git-scm.com/docs/git-add)
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```ts
|
|
344
|
+
* await git.add("CHANGELOG.md");
|
|
345
|
+
* ```
|
|
346
|
+
*/
|
|
347
|
+
add(...args: (string | undefined)[]): Promise<string>;
|
|
348
|
+
/**
|
|
349
|
+
* Record changes to the repository
|
|
350
|
+
*
|
|
351
|
+
* [git-commit Documentation](https://git-scm.com/docs/git-commit)
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* ```ts
|
|
355
|
+
* await git.commit("--message", "chore(release): 1.2.3");
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
358
|
+
commit(...args: (string | undefined)[]): Promise<string>;
|
|
359
|
+
/**
|
|
360
|
+
* Create, list, delete or verify a tag object
|
|
361
|
+
*
|
|
362
|
+
* [git-tag Documentation](https://git-scm.com/docs/git-tag)
|
|
363
|
+
*
|
|
364
|
+
* @example
|
|
365
|
+
* ```ts
|
|
366
|
+
* await git.tag("--annotate", "v1.2.3", "--message", "chore(release): 1.2.3");
|
|
367
|
+
* ```
|
|
368
|
+
*/
|
|
369
|
+
tag(...args: (string | undefined)[]): Promise<string>;
|
|
370
|
+
/**
|
|
371
|
+
* Show commit logs
|
|
372
|
+
*
|
|
373
|
+
* - [git-log Documentation](https://git-scm.com/docs/git-log)
|
|
374
|
+
* - [pretty-formats Documentation](https://git-scm.com/docs/pretty-formats)
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* ```ts
|
|
378
|
+
* await git.log("--oneline");
|
|
379
|
+
* ```
|
|
380
|
+
*/
|
|
381
|
+
log(...args: (string | undefined)[]): Promise<string>;
|
|
382
|
+
/**
|
|
383
|
+
* Check if a file is ignored by git
|
|
384
|
+
*
|
|
385
|
+
* [git-check-ignore Documentation](https://git-scm.com/docs/git-check-ignore)
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```ts
|
|
389
|
+
* await git.isIgnored("src/my-file.txt");
|
|
390
|
+
* ```
|
|
391
|
+
*/
|
|
392
|
+
isIgnored(file: string): Promise<boolean>;
|
|
393
|
+
/**
|
|
394
|
+
* Get the name of the current branch
|
|
395
|
+
*
|
|
396
|
+
* [git-rev-parse Documentation](https://git-scm.com/docs/git-rev-parse)
|
|
397
|
+
*
|
|
398
|
+
* @example
|
|
399
|
+
* ```ts
|
|
400
|
+
* await git.getBranchName(); // "main"
|
|
401
|
+
* ```
|
|
402
|
+
*/
|
|
403
|
+
getBranchName(): Promise<string>;
|
|
404
|
+
/**
|
|
405
|
+
* Get the URL of the remote repository
|
|
406
|
+
*
|
|
407
|
+
* [git-config Documentation](https://git-scm.com/docs/git-config)
|
|
408
|
+
*
|
|
409
|
+
* @example
|
|
410
|
+
* ```ts
|
|
411
|
+
* await git.getRemoteUrl(); // "https://github.com/eglavin/fork-version"
|
|
412
|
+
* ```
|
|
413
|
+
*/
|
|
414
|
+
getRemoteUrl(): Promise<string>;
|
|
415
|
+
/**
|
|
416
|
+
* `getTags` returns valid semver version tags in order of the commit history
|
|
417
|
+
*
|
|
418
|
+
* Using `git log` to get the commit history, we then parse the tags from the
|
|
419
|
+
* commit details which is expected to be in the following format:
|
|
420
|
+
* ```txt
|
|
421
|
+
* commit 3841b1d05750d42197fe958e3d8e06df378a842d (HEAD -> main, tag: v1.0.2, tag: v1.0.1, tag: v1.0.0)
|
|
422
|
+
* Author: Username <username@example.com>
|
|
423
|
+
* Date: Sat Nov 9 15:00:00 2024 +0000
|
|
424
|
+
*
|
|
425
|
+
* chore(release): v1.0.0
|
|
426
|
+
* ```
|
|
427
|
+
*
|
|
428
|
+
* - [Functionality extracted from the conventional-changelog - git-semver-tags project](https://github.com/conventional-changelog/conventional-changelog/blob/fac8045242099c016f5f3905e54e02b7d466bd7b/packages/git-semver-tags/index.js)
|
|
429
|
+
* - [conventional-changelog git-semver-tags MIT Licence](https://github.com/conventional-changelog/conventional-changelog/blob/fac8045242099c016f5f3905e54e02b7d466bd7b/packages/git-semver-tags/LICENSE.md)
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* ```ts
|
|
433
|
+
* await git.getTags("v"); // ["v1.0.2", "v1.0.1", "v1.0.0"]
|
|
434
|
+
* ```
|
|
435
|
+
*/
|
|
436
|
+
getTags(tagPrefix: string | undefined): Promise<string[]>;
|
|
437
|
+
/**
|
|
438
|
+
* Returns the latest git tag based on commit date
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* ```ts
|
|
442
|
+
* await git.getMostRecentTag("v"); // "1.2.3"
|
|
443
|
+
* ```
|
|
444
|
+
*/
|
|
445
|
+
getMostRecentTag(tagPrefix: string | undefined): Promise<string | undefined>;
|
|
446
|
+
/**
|
|
447
|
+
* Get cleaned semver tags, with any tag prefix's removed
|
|
448
|
+
*
|
|
449
|
+
* @example
|
|
450
|
+
* ```ts
|
|
451
|
+
* await git.getCleanedTags("v"); // ["1.2.3", "1.2.2", "1.2.1"]
|
|
452
|
+
* ```
|
|
453
|
+
*/
|
|
454
|
+
getCleanedTags(tagPrefix: string | undefined): Promise<string[]>;
|
|
455
|
+
/**
|
|
456
|
+
* Get the highest semver version from git tags. This will return the highest
|
|
457
|
+
* semver version found for the given tag prefix, regardless of the commit date.
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* ```ts
|
|
461
|
+
* await git.getHighestSemverVersionFromTags("v"); // "1.2.3"
|
|
462
|
+
* ```
|
|
463
|
+
*/
|
|
464
|
+
getHighestSemverVersionFromTags(tagPrefix: string | undefined): Promise<string | undefined>;
|
|
465
|
+
/**
|
|
466
|
+
* Get commit history in a parsable format
|
|
467
|
+
*
|
|
468
|
+
* An array of strings with commit details is returned in the following format:
|
|
469
|
+
* ```txt
|
|
470
|
+
* subject
|
|
471
|
+
* body
|
|
472
|
+
* hash
|
|
473
|
+
* committer date
|
|
474
|
+
* committer name
|
|
475
|
+
* committer email
|
|
476
|
+
* ```
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
* ```ts
|
|
480
|
+
* await git.getCommits("v1.0.0", "HEAD", "src/utils");
|
|
481
|
+
* ```
|
|
482
|
+
*/
|
|
483
|
+
getCommits(from?: string, to?: string, ...paths: string[]): Promise<string[]>;
|
|
377
484
|
}
|
|
378
485
|
|
|
486
|
+
interface CommitsSinceTag {
|
|
487
|
+
latestTag: string | undefined;
|
|
488
|
+
commits: Commit[];
|
|
489
|
+
}
|
|
490
|
+
declare function getCommitsSinceTag(config: ForkConfig, logger: Logger, git: Git): Promise<CommitsSinceTag>;
|
|
491
|
+
|
|
379
492
|
interface FileState {
|
|
380
493
|
name: string;
|
|
381
494
|
path: string;
|
|
@@ -424,48 +537,6 @@ declare class FileManager {
|
|
|
424
537
|
write(fileState: FileState, newVersion: string): void;
|
|
425
538
|
}
|
|
426
539
|
|
|
427
|
-
declare class Git {
|
|
428
|
-
private config;
|
|
429
|
-
constructor(config: Pick<ForkConfig, "path" | "dryRun">);
|
|
430
|
-
private execGit;
|
|
431
|
-
/**
|
|
432
|
-
* - [git-add Documentation](https://git-scm.com/docs/git-add)
|
|
433
|
-
*/
|
|
434
|
-
add(...args: (string | undefined)[]): Promise<string>;
|
|
435
|
-
/**
|
|
436
|
-
* - [git-commit Documentation](https://git-scm.com/docs/git-commit)
|
|
437
|
-
*/
|
|
438
|
-
commit(...args: (string | undefined)[]): Promise<string>;
|
|
439
|
-
/**
|
|
440
|
-
* - [git-tag Documentation](https://git-scm.com/docs/git-tag)
|
|
441
|
-
*/
|
|
442
|
-
tag(...args: (string | undefined)[]): Promise<string>;
|
|
443
|
-
/**
|
|
444
|
-
* - [git-check-ignore Documentation](https://git-scm.com/docs/git-check-ignore)
|
|
445
|
-
*/
|
|
446
|
-
isIgnored(file: string): Promise<boolean>;
|
|
447
|
-
getCurrentBranchName(): Promise<string>;
|
|
448
|
-
/**
|
|
449
|
-
* `getTags` returns valid semver version tags in order of the commit history.
|
|
450
|
-
*
|
|
451
|
-
* Using `git log` to get the commit history, we then parse the tags from the
|
|
452
|
-
* commit details which is expected to be in the following format:
|
|
453
|
-
* @example
|
|
454
|
-
* ```txt
|
|
455
|
-
* commit 3841b1d05750d42197fe958e3d8e06df378a842d (HEAD -> main, tag: 1.0.2)
|
|
456
|
-
* Author: Username <username@example.com>
|
|
457
|
-
* Date: Sat Nov 9 15:00:00 2024 +0000
|
|
458
|
-
*
|
|
459
|
-
* chore(release): 1.2.3
|
|
460
|
-
* ```
|
|
461
|
-
*
|
|
462
|
-
* - [Functionality extracted from the conventional-changelog - git-semver-tags project](https://github.com/conventional-changelog/conventional-changelog/blob/fac8045242099c016f5f3905e54e02b7d466bd7b/packages/git-semver-tags/index.js)
|
|
463
|
-
* - [conventional-changelog git-semver-tags MIT Licence](https://github.com/conventional-changelog/conventional-changelog/blob/fac8045242099c016f5f3905e54e02b7d466bd7b/packages/git-semver-tags/LICENSE.md)
|
|
464
|
-
*/
|
|
465
|
-
getTags(tagPrefix: string | undefined): Promise<string[]>;
|
|
466
|
-
getLatestTag(tagPrefix: string | undefined): Promise<string>;
|
|
467
|
-
}
|
|
468
|
-
|
|
469
540
|
interface CurrentVersion {
|
|
470
541
|
version: string;
|
|
471
542
|
files: FileState[];
|
|
@@ -473,12 +544,15 @@ interface CurrentVersion {
|
|
|
473
544
|
declare function getCurrentVersion(config: ForkConfig, logger: Logger, git: Git, fileManager: FileManager, filesToUpdate: string[]): Promise<CurrentVersion>;
|
|
474
545
|
interface NextVersion {
|
|
475
546
|
version: string;
|
|
476
|
-
level?: number;
|
|
477
|
-
preMajor?: boolean;
|
|
478
|
-
reason?: string;
|
|
479
547
|
releaseType?: ReleaseType;
|
|
548
|
+
preMajor?: boolean;
|
|
549
|
+
changes?: {
|
|
550
|
+
major: number;
|
|
551
|
+
minor: number;
|
|
552
|
+
patch: number;
|
|
553
|
+
};
|
|
480
554
|
}
|
|
481
|
-
declare function getNextVersion(config: ForkConfig, logger: Logger, currentVersion: string): Promise<NextVersion>;
|
|
555
|
+
declare function getNextVersion(config: ForkConfig, logger: Logger, commits: Commit[], currentVersion: string): Promise<NextVersion>;
|
|
482
556
|
|
|
483
557
|
declare function updateChangelog(config: ForkConfig, logger: Logger, nextVersion: string): Promise<void>;
|
|
484
558
|
|
|
@@ -486,4 +560,4 @@ declare function commitChanges(config: ForkConfig, logger: Logger, git: Git, fil
|
|
|
486
560
|
|
|
487
561
|
declare function tagChanges(config: ForkConfig, logger: Logger, git: Git, nextVersion: string): Promise<void>;
|
|
488
562
|
|
|
489
|
-
export { type Config, type CurrentVersion, FileManager, type FileState, type ForkConfig, ForkConfigSchema, Git, type IFileManager, Logger, type NextVersion, commitChanges, defineConfig, getCurrentVersion, getNextVersion, getUserConfig, tagChanges, updateChangelog };
|
|
563
|
+
export { type Commit, type CommitMerge, type CommitNote, CommitParser, type CommitReference, type CommitRevert, type CommitsSinceTag, type Config, type CurrentVersion, FileManager, type FileState, type ForkConfig, ForkConfigSchema, Git, type IFileManager, Logger, type NextVersion, type ParserOptions, commitChanges, createParserOptions, defineConfig, filterRevertedCommits, getCommitsSinceTag, getCurrentVersion, getNextVersion, getUserConfig, tagChanges, updateChangelog };
|