fork-version 3.0.2 → 3.1.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/dist/index.d.cts CHANGED
@@ -1,71 +1,10 @@
1
1
  import { z } from 'zod';
2
+ import * as meow from 'meow';
2
3
  import { ReleaseType } from 'semver';
3
4
 
4
- interface ParserOptions {
5
- /**
6
- * Pattern to match commit subjects
7
- * - Expected capture groups: `type` `title`
8
- * - Optional capture groups: `scope`, `breakingChange`
9
- */
10
- subjectPattern: RegExp | undefined;
11
- /**
12
- * Pattern to match merge commits
13
- * - Expected capture groups: `id`, `source`
14
- */
15
- mergePattern: RegExp | undefined;
16
- /**
17
- * Pattern to match revert commits
18
- * - Expected capture groups: `subject`, `hash`
19
- */
20
- revertPattern: RegExp | undefined;
21
- /**
22
- * Pattern to match commented out lines which will be trimmed
23
- */
24
- commentPattern: RegExp | undefined;
25
- /**
26
- * Pattern to match mentions
27
- * - Expected capture groups: `username`
28
- */
29
- mentionPattern: RegExp | undefined;
30
- /**
31
- * List of action labels to match reference sections
32
- * @default
33
- * ["close", "closes", "closed", "fix", "fixes", "fixed", "resolve", "resolves", "resolved"]
34
- */
35
- referenceActions?: string[];
36
- /**
37
- * Pattern to match reference sections
38
- * - Expected capture groups: `action`, `reference`
39
- */
40
- referenceActionPattern: RegExp | undefined;
41
- /**
42
- * List of issue prefixes to match issue ids
43
- * @default
44
- * ["#"]
45
- */
46
- issuePrefixes?: string[];
47
- /**
48
- * Pattern to match issue references
49
- * - Expected capture groups: `repository`, `prefix`, `issue`
50
- */
51
- issuePattern: RegExp | undefined;
52
- /**
53
- * List of keywords to match note titles
54
- * @default
55
- * ["BREAKING CHANGE", "BREAKING-CHANGE"]
56
- */
57
- noteKeywords?: string[];
58
- /**
59
- * Pattern to match note sections
60
- * - Expected capture groups: `title`
61
- * - Optional capture groups: `text`
62
- */
63
- notePattern: RegExp | undefined;
64
- }
65
- declare function createParserOptions(userOptions?: Partial<ParserOptions>): ParserOptions;
66
-
67
5
  declare const ForkConfigSchema: z.ZodObject<{
68
- inspectVersion: z.ZodBoolean;
6
+ command: z.ZodLiteral<"main" | "inspect-version" | "inspect-tag" | "validate-config">;
7
+ inspectVersion: z.ZodOptional<z.ZodBoolean>;
69
8
  files: z.ZodArray<z.ZodString>;
70
9
  glob: z.ZodOptional<z.ZodString>;
71
10
  path: z.ZodString;
@@ -106,19 +45,332 @@ declare const ForkConfigSchema: z.ZodObject<{
106
45
  releaseMessageSuffix: z.ZodOptional<z.ZodString>;
107
46
  }, z.core.$strip>;
108
47
 
48
+ declare function getCliArguments(): meow.Result<{
49
+ /** @deprecated Set the `inspect-version` command instead. */
50
+ inspectVersion: {
51
+ type: "boolean";
52
+ };
53
+ files: {
54
+ type: "string";
55
+ isMultiple: true;
56
+ aliases: string[];
57
+ shortFlag: string;
58
+ };
59
+ glob: {
60
+ type: "string";
61
+ shortFlag: string;
62
+ };
63
+ path: {
64
+ type: "string";
65
+ shortFlag: string;
66
+ };
67
+ changelog: {
68
+ type: "string";
69
+ };
70
+ header: {
71
+ type: "string";
72
+ };
73
+ tagPrefix: {
74
+ type: "string";
75
+ };
76
+ preRelease: {
77
+ type: "boolean";
78
+ };
79
+ preReleaseTag: {
80
+ type: "string";
81
+ };
82
+ currentVersion: {
83
+ type: "string";
84
+ };
85
+ nextVersion: {
86
+ type: "string";
87
+ };
88
+ releaseAs: {
89
+ type: "string";
90
+ choices: string[];
91
+ };
92
+ allowMultipleVersions: {
93
+ type: "boolean";
94
+ };
95
+ commitAll: {
96
+ type: "boolean";
97
+ };
98
+ changelogAll: {
99
+ type: "boolean";
100
+ };
101
+ debug: {
102
+ type: "boolean";
103
+ };
104
+ dryRun: {
105
+ type: "boolean";
106
+ };
107
+ silent: {
108
+ type: "boolean";
109
+ };
110
+ gitTagFallback: {
111
+ type: "boolean";
112
+ };
113
+ sign: {
114
+ type: "boolean";
115
+ };
116
+ verify: {
117
+ type: "boolean";
118
+ };
119
+ skipBump: {
120
+ type: "boolean";
121
+ };
122
+ skipChangelog: {
123
+ type: "boolean";
124
+ };
125
+ skipCommit: {
126
+ type: "boolean";
127
+ };
128
+ skipTag: {
129
+ type: "boolean";
130
+ };
131
+ commitUrlFormat: {
132
+ type: "string";
133
+ };
134
+ compareUrlFormat: {
135
+ type: "string";
136
+ };
137
+ issueUrlFormat: {
138
+ type: "string";
139
+ };
140
+ userUrlFormat: {
141
+ type: "string";
142
+ };
143
+ releaseCommitMessageFormat: {
144
+ type: "string";
145
+ };
146
+ releaseMessageSuffix: {
147
+ type: "string";
148
+ };
149
+ }>;
150
+
109
151
  type ForkConfig = z.infer<typeof ForkConfigSchema>;
110
152
  type Config = Partial<ForkConfig>;
153
+ type CLIArguments = ReturnType<typeof getCliArguments>;
154
+ interface ForkVersionCLIArgs {
155
+ input: CLIArguments["input"];
156
+ flags: Partial<CLIArguments["flags"]>;
157
+ }
158
+
159
+ declare class Git {
160
+ #private;
161
+ private config;
162
+ constructor(config: Pick<ForkConfig, "path" | "dryRun">);
163
+ /**
164
+ * Add file contents to the index
165
+ *
166
+ * [git-add Documentation](https://git-scm.com/docs/git-add)
167
+ *
168
+ * @example
169
+ * ```ts
170
+ * await git.add("CHANGELOG.md");
171
+ * ```
172
+ */
173
+ add(...args: (string | undefined)[]): Promise<string>;
174
+ /**
175
+ * Record changes to the repository
176
+ *
177
+ * [git-commit Documentation](https://git-scm.com/docs/git-commit)
178
+ *
179
+ * @example
180
+ * ```ts
181
+ * await git.commit("--message", "chore(release): 1.2.3");
182
+ * ```
183
+ */
184
+ commit(...args: (string | undefined)[]): Promise<string>;
185
+ /**
186
+ * Create, list, delete or verify a tag object
187
+ *
188
+ * [git-tag Documentation](https://git-scm.com/docs/git-tag)
189
+ *
190
+ * @example
191
+ * ```ts
192
+ * await git.tag("--annotate", "v1.2.3", "--message", "chore(release): 1.2.3");
193
+ * ```
194
+ */
195
+ tag(...args: (string | undefined)[]): Promise<string>;
196
+ /**
197
+ * Show commit logs
198
+ *
199
+ * - [git-log Documentation](https://git-scm.com/docs/git-log)
200
+ * - [pretty-formats Documentation](https://git-scm.com/docs/pretty-formats)
201
+ *
202
+ * @example
203
+ * ```ts
204
+ * await git.log("--oneline");
205
+ * ```
206
+ */
207
+ log(...args: (string | undefined)[]): Promise<string>;
208
+ /**
209
+ * Check if a file is ignored by git
210
+ *
211
+ * [git-check-ignore Documentation](https://git-scm.com/docs/git-check-ignore)
212
+ *
213
+ * @example
214
+ * ```ts
215
+ * await git.isIgnored("src/my-file.txt");
216
+ * ```
217
+ */
218
+ isIgnored(file: string): Promise<boolean>;
219
+ /**
220
+ * Get the name of the current branch
221
+ *
222
+ * [git-rev-parse Documentation](https://git-scm.com/docs/git-rev-parse)
223
+ *
224
+ * @example
225
+ * ```ts
226
+ * await git.getBranchName(); // "main"
227
+ * ```
228
+ */
229
+ getBranchName(): Promise<string>;
230
+ /**
231
+ * Get the URL of the remote repository
232
+ *
233
+ * [git-config Documentation](https://git-scm.com/docs/git-config)
234
+ *
235
+ * @example
236
+ * ```ts
237
+ * await git.getRemoteUrl(); // "https://github.com/eglavin/fork-version"
238
+ * ```
239
+ */
240
+ getRemoteUrl(): Promise<string>;
241
+ /**
242
+ * `getTags` returns valid semver version tags in order of the commit history
243
+ *
244
+ * Using `git log` to get the commit history, we then parse the tags from the
245
+ * commit details which is expected to be in the following format:
246
+ * ```txt
247
+ * commit 3841b1d05750d42197fe958e3d8e06df378a842d (HEAD -> main, tag: v1.0.2, tag: v1.0.1, tag: v1.0.0)
248
+ * Author: Username <username@example.com>
249
+ * Date: Sat Nov 9 15:00:00 2024 +0000
250
+ *
251
+ * chore(release): v1.0.0
252
+ * ```
253
+ *
254
+ * - [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)
255
+ * - [conventional-changelog git-semver-tags MIT Licence](https://github.com/conventional-changelog/conventional-changelog/blob/fac8045242099c016f5f3905e54e02b7d466bd7b/packages/git-semver-tags/LICENSE.md)
256
+ *
257
+ * @example
258
+ * ```ts
259
+ * await git.getTags("v"); // ["v1.0.2", "v1.0.1", "v1.0.0"]
260
+ * ```
261
+ */
262
+ getTags(tagPrefix: string | undefined): Promise<string[]>;
263
+ /**
264
+ * Returns the latest git tag based on commit date
265
+ *
266
+ * @example
267
+ * ```ts
268
+ * await git.getMostRecentTag("v"); // "1.2.3"
269
+ * ```
270
+ */
271
+ getMostRecentTag(tagPrefix: string | undefined): Promise<string | undefined>;
272
+ /**
273
+ * Get cleaned semver tags, with any tag prefix's removed
274
+ *
275
+ * @example
276
+ * ```ts
277
+ * await git.getCleanedTags("v"); // ["1.2.3", "1.2.2", "1.2.1"]
278
+ * ```
279
+ */
280
+ getCleanedTags(tagPrefix: string | undefined): Promise<string[]>;
281
+ /**
282
+ * Get the highest semver version from git tags. This will return the highest
283
+ * semver version found for the given tag prefix, regardless of the commit date.
284
+ *
285
+ * @example
286
+ * ```ts
287
+ * await git.getHighestSemverVersionFromTags("v"); // "1.2.3"
288
+ * ```
289
+ */
290
+ getHighestSemverVersionFromTags(tagPrefix: string | undefined): Promise<string | undefined>;
291
+ /**
292
+ * Get commit history in a parsable format
293
+ *
294
+ * An array of strings with commit details is returned in the following format:
295
+ * ```txt
296
+ * subject
297
+ * body
298
+ * hash
299
+ * committer date
300
+ * committer name
301
+ * committer email
302
+ * ```
303
+ *
304
+ * @example
305
+ * ```ts
306
+ * await git.getCommits("v1.0.0", "HEAD", "src/utils");
307
+ * ```
308
+ */
309
+ getCommits(from?: string, to?: string, ...paths: string[]): Promise<string[]>;
310
+ }
311
+
312
+ declare function inspectTag(config: ForkConfig, git: Git): Promise<void>;
111
313
 
112
314
  declare class Logger {
113
315
  private config;
114
316
  disableLogs: boolean;
115
- constructor(config: Pick<ForkConfig, "silent" | "debug" | "inspectVersion">);
317
+ constructor(config: Pick<ForkConfig, "silent" | "debug">);
116
318
  log(...messages: any[]): void;
117
319
  warn(...messages: any[]): void;
118
320
  error(...messages: any[]): void;
119
321
  debug(...messages: any[]): void;
120
322
  }
121
323
 
324
+ interface FileState {
325
+ name: string;
326
+ path: string;
327
+ version: string;
328
+ [other: string]: unknown;
329
+ }
330
+ interface IFileManager {
331
+ read(fileName: string): FileState | undefined;
332
+ write(fileState: FileState, newVersion: string): void;
333
+ isSupportedFile(fileName: string): boolean;
334
+ }
335
+ declare class FileManager {
336
+ private config;
337
+ private logger;
338
+ private JSONPackage;
339
+ private YAMLPackage;
340
+ private PlainText;
341
+ private MSBuildProject;
342
+ private ARMBicep;
343
+ constructor(config: ForkConfig, logger: Logger);
344
+ /**
345
+ * Get the state from the given file name.
346
+ *
347
+ * @example
348
+ * ```ts
349
+ * fileManager.read("package.json");
350
+ * ```
351
+ *
352
+ * @returns
353
+ * ```json
354
+ * { "name": "package.json", "path": "/path/to/package.json", "version": "1.2.3", "isPrivate": true }
355
+ * ```
356
+ */
357
+ read(fileName: string): FileState | undefined;
358
+ /**
359
+ * Write the new version to the given file.
360
+ *
361
+ * @example
362
+ * ```ts
363
+ * fileManager.write(
364
+ * { name: "package.json", path: "/path/to/package.json", version: "1.2.2" },
365
+ * "1.2.3"
366
+ * );
367
+ * ```
368
+ */
369
+ write(fileState: FileState, newVersion: string): void;
370
+ }
371
+
372
+ declare function inspectVersion(config: ForkConfig, logger: Logger, fileManager: FileManager, git: Git): Promise<void>;
373
+
122
374
  interface CommitMerge {
123
375
  id: string;
124
376
  source: string;
@@ -144,29 +396,166 @@ interface Commit {
144
396
  body: string;
145
397
  hash: string;
146
398
  /**
147
- * Committer date in ISO 8601 format
148
- * @example
149
- * "2024-12-22T17:36:50Z"
399
+ * Committer date in ISO 8601 format
400
+ * @example
401
+ * "2024-12-22T17:36:50Z"
402
+ */
403
+ date: string;
404
+ /**
405
+ * Committer name (respects .mailmap)
406
+ */
407
+ name: string;
408
+ /**
409
+ * Committer email (respects .mailmap)
410
+ */
411
+ email: string;
412
+ type: string;
413
+ scope: string;
414
+ breakingChange: string;
415
+ title: string;
416
+ merge: CommitMerge | null;
417
+ revert: CommitRevert | null;
418
+ mentions: string[];
419
+ references: CommitReference[];
420
+ notes: CommitNote[];
421
+ }
422
+
423
+ interface NextVersion {
424
+ version: string;
425
+ releaseType?: ReleaseType;
426
+ preMajor?: boolean;
427
+ changes?: {
428
+ major: number;
429
+ minor: number;
430
+ patch: number;
431
+ };
432
+ }
433
+ declare function getNextVersion(config: ForkConfig, logger: Logger, commits: Commit[], currentVersion: string): Promise<NextVersion>;
434
+
435
+ interface CurrentVersion {
436
+ version: string;
437
+ files: FileState[];
438
+ }
439
+ declare function getCurrentVersion(config: ForkConfig, logger: Logger, git: Git, fileManager: FileManager, filesToUpdate: string[]): Promise<CurrentVersion>;
440
+
441
+ interface CommitsSinceTag {
442
+ latestTag: string | undefined;
443
+ commits: Commit[];
444
+ }
445
+ declare function getCommitsSinceTag(config: ForkConfig, logger: Logger, git: Git): Promise<CommitsSinceTag>;
446
+
447
+ declare function main(config: ForkConfig, logger: Logger, fileManager: FileManager, git: Git): Promise<{
448
+ config: {
449
+ command: "main" | "inspect-version" | "inspect-tag" | "validate-config";
450
+ files: string[];
451
+ path: string;
452
+ changelog: string;
453
+ header: string;
454
+ tagPrefix: string;
455
+ allowMultipleVersions: boolean;
456
+ commitAll: boolean;
457
+ changelogAll: boolean;
458
+ debug: boolean;
459
+ dryRun: boolean;
460
+ silent: boolean;
461
+ gitTagFallback: boolean;
462
+ sign: boolean;
463
+ verify: boolean;
464
+ skipBump: boolean;
465
+ skipChangelog: boolean;
466
+ skipCommit: boolean;
467
+ skipTag: boolean;
468
+ changelogPresetConfig: {
469
+ types?: {
470
+ type: string;
471
+ scope?: string | undefined;
472
+ section?: string | undefined;
473
+ hidden?: boolean | undefined;
474
+ }[] | undefined;
475
+ commitUrlFormat?: string | undefined;
476
+ compareUrlFormat?: string | undefined;
477
+ issueUrlFormat?: string | undefined;
478
+ userUrlFormat?: string | undefined;
479
+ releaseCommitMessageFormat?: string | undefined;
480
+ issuePrefixes?: string[] | undefined;
481
+ };
482
+ inspectVersion?: boolean | undefined;
483
+ glob?: string | undefined;
484
+ preRelease?: string | boolean | undefined;
485
+ currentVersion?: string | undefined;
486
+ nextVersion?: string | undefined;
487
+ releaseAs?: "major" | "minor" | "patch" | undefined;
488
+ releaseMessageSuffix?: string | undefined;
489
+ };
490
+ commits: CommitsSinceTag;
491
+ current: CurrentVersion;
492
+ next: NextVersion;
493
+ }>;
494
+
495
+ declare function validateConfig(config: ForkConfig): void;
496
+
497
+ interface ParserOptions {
498
+ /**
499
+ * Pattern to match commit subjects
500
+ * - Expected capture groups: `type` `title`
501
+ * - Optional capture groups: `scope`, `breakingChange`
502
+ */
503
+ subjectPattern: RegExp | undefined;
504
+ /**
505
+ * Pattern to match merge commits
506
+ * - Expected capture groups: `id`, `source`
507
+ */
508
+ mergePattern: RegExp | undefined;
509
+ /**
510
+ * Pattern to match revert commits
511
+ * - Expected capture groups: `subject`, `hash`
512
+ */
513
+ revertPattern: RegExp | undefined;
514
+ /**
515
+ * Pattern to match commented out lines which will be trimmed
516
+ */
517
+ commentPattern: RegExp | undefined;
518
+ /**
519
+ * Pattern to match mentions
520
+ * - Expected capture groups: `username`
521
+ */
522
+ mentionPattern: RegExp | undefined;
523
+ /**
524
+ * List of action labels to match reference sections
525
+ * @default
526
+ * ["close", "closes", "closed", "fix", "fixes", "fixed", "resolve", "resolves", "resolved"]
527
+ */
528
+ referenceActions?: string[];
529
+ /**
530
+ * Pattern to match reference sections
531
+ * - Expected capture groups: `action`, `reference`
532
+ */
533
+ referenceActionPattern: RegExp | undefined;
534
+ /**
535
+ * List of issue prefixes to match issue ids
536
+ * @default
537
+ * ["#"]
538
+ */
539
+ issuePrefixes?: string[];
540
+ /**
541
+ * Pattern to match issue references
542
+ * - Expected capture groups: `repository`, `prefix`, `issue`
150
543
  */
151
- date: string;
544
+ issuePattern: RegExp | undefined;
152
545
  /**
153
- * Committer name (respects .mailmap)
546
+ * List of keywords to match note titles
547
+ * @default
548
+ * ["BREAKING CHANGE", "BREAKING-CHANGE"]
154
549
  */
155
- name: string;
550
+ noteKeywords?: string[];
156
551
  /**
157
- * Committer email (respects .mailmap)
552
+ * Pattern to match note sections
553
+ * - Expected capture groups: `title`
554
+ * - Optional capture groups: `text`
158
555
  */
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[];
556
+ notePattern: RegExp | undefined;
169
557
  }
558
+ declare function createParserOptions(userOptions?: Partial<ParserOptions>): ParserOptions;
170
559
 
171
560
  declare class CommitParser {
172
561
  #private;
@@ -294,266 +683,7 @@ declare function filterRevertedCommits(parsedCommits: Commit[]): Commit[];
294
683
  */
295
684
  declare function defineConfig(config: Config): Config;
296
685
 
297
- declare function getCliArguments(): {
298
- inspectVersion: boolean | undefined;
299
- files: string[] | undefined;
300
- glob: string | undefined;
301
- path: string | undefined;
302
- changelog: string | undefined;
303
- header: string | undefined;
304
- tagPrefix: string | undefined;
305
- preRelease: boolean | undefined;
306
- preReleaseTag: string | undefined;
307
- currentVersion: string | undefined;
308
- nextVersion: string | undefined;
309
- releaseAs: string | undefined;
310
- allowMultipleVersions: boolean | undefined;
311
- commitAll: boolean | undefined;
312
- changelogAll: boolean | undefined;
313
- debug: boolean | undefined;
314
- dryRun: boolean | undefined;
315
- silent: boolean | undefined;
316
- gitTagFallback: boolean | undefined;
317
- sign: boolean | undefined;
318
- verify: boolean | undefined;
319
- skipBump: boolean | undefined;
320
- skipChangelog: boolean | undefined;
321
- skipCommit: boolean | undefined;
322
- skipTag: boolean | undefined;
323
- commitUrlFormat: string | undefined;
324
- compareUrlFormat: string | undefined;
325
- issueUrlFormat: string | undefined;
326
- userUrlFormat: string | undefined;
327
- releaseCommitMessageFormat: string | undefined;
328
- releaseMessageSuffix: string | undefined;
329
- } & Record<string, unknown>;
330
-
331
- declare function getUserConfig(cliArguments: Partial<ReturnType<typeof getCliArguments>>): Promise<ForkConfig>;
332
-
333
- declare class Git {
334
- #private;
335
- private config;
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[]>;
484
- }
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
-
492
- interface FileState {
493
- name: string;
494
- path: string;
495
- version: string;
496
- [other: string]: unknown;
497
- }
498
- interface IFileManager {
499
- read(fileName: string): FileState | undefined;
500
- write(fileState: FileState, newVersion: string): void;
501
- isSupportedFile(fileName: string): boolean;
502
- }
503
- declare class FileManager {
504
- private config;
505
- private logger;
506
- private JSONPackage;
507
- private YAMLPackage;
508
- private PlainText;
509
- private MSBuildProject;
510
- private ARMBicep;
511
- constructor(config: ForkConfig, logger: Logger);
512
- /**
513
- * Get the state from the given file name.
514
- *
515
- * @example
516
- * ```ts
517
- * fileManager.read("package.json");
518
- * ```
519
- *
520
- * @returns
521
- * ```json
522
- * { "name": "package.json", "path": "/path/to/package.json", "version": "1.2.3", "isPrivate": true }
523
- * ```
524
- */
525
- read(fileName: string): FileState | undefined;
526
- /**
527
- * Write the new version to the given file.
528
- *
529
- * @example
530
- * ```ts
531
- * fileManager.write(
532
- * { name: "package.json", path: "/path/to/package.json", version: "1.2.2" },
533
- * "1.2.3"
534
- * );
535
- * ```
536
- */
537
- write(fileState: FileState, newVersion: string): void;
538
- }
539
-
540
- interface CurrentVersion {
541
- version: string;
542
- files: FileState[];
543
- }
544
- declare function getCurrentVersion(config: ForkConfig, logger: Logger, git: Git, fileManager: FileManager, filesToUpdate: string[]): Promise<CurrentVersion>;
545
-
546
- interface NextVersion {
547
- version: string;
548
- releaseType?: ReleaseType;
549
- preMajor?: boolean;
550
- changes?: {
551
- major: number;
552
- minor: number;
553
- patch: number;
554
- };
555
- }
556
- declare function getNextVersion(config: ForkConfig, logger: Logger, commits: Commit[], currentVersion: string): Promise<NextVersion>;
686
+ declare function getUserConfig(cliArguments: ForkVersionCLIArgs): Promise<ForkConfig>;
557
687
 
558
688
  declare function updateChangelog(config: ForkConfig, logger: Logger, nextVersion: string): Promise<void>;
559
689
 
@@ -561,4 +691,4 @@ declare function commitChanges(config: ForkConfig, logger: Logger, git: Git, fil
561
691
 
562
692
  declare function tagChanges(config: ForkConfig, logger: Logger, git: Git, nextVersion: string): Promise<void>;
563
693
 
564
- 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 };
694
+ 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, inspectTag, inspectVersion, main, tagChanges, updateChangelog, validateConfig };