yarn-version 8.3.1 → 8.4.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/CHANGELOG.md +10 -0
- package/dist/index-node.mjs +48 -46
- package/dist/index-node.mjs.map +1 -1
- package/package.json +13 -14
- package/src/commands/version.ts +27 -14
- package/src/missing-types.d.ts +10 -6
- package/src/utils/conventionalChangelogUtils.test.ts +761 -0
- package/src/utils/conventionalChangelogUtils.ts +40 -48
- package/vitest.config.js +9 -0
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { text } from "node:stream/consumers";
|
|
3
|
-
import conventionalChangelogCore from "conventional-changelog-core";
|
|
4
|
-
import type { Commit } from "conventional-commits-parser";
|
|
1
|
+
import { writeChangelogString } from "conventional-changelog-writer";
|
|
5
2
|
import type { BumperRecommendation } from "conventional-recommended-bump";
|
|
6
3
|
import type { PackageJson } from "type-fest";
|
|
7
4
|
import type { ConventionalChangelogConfig } from "./conventionalCommitConfigUtils.ts";
|
|
@@ -12,73 +9,68 @@ const versions: BumperRecommendation["releaseType"][] = [
|
|
|
12
9
|
"minor",
|
|
13
10
|
"patch",
|
|
14
11
|
];
|
|
12
|
+
|
|
15
13
|
export const recommendBump = async (
|
|
16
|
-
commits:
|
|
14
|
+
commits: Parameters<ConventionalChangelogConfig["whatBump"]>[0],
|
|
17
15
|
config: ConventionalChangelogConfig,
|
|
18
|
-
): Promise<BumperRecommendation
|
|
16
|
+
): Promise<Partial<BumperRecommendation>> => {
|
|
19
17
|
const whatBump = config.whatBump;
|
|
20
18
|
if (!whatBump) {
|
|
21
19
|
throw new Error("whatBump method is missing in config");
|
|
22
20
|
}
|
|
23
|
-
|
|
24
|
-
if (result.level != null) {
|
|
25
|
-
result.releaseType = versions[result.level];
|
|
26
|
-
} else if (result == null) {
|
|
27
|
-
result = {};
|
|
28
|
-
}
|
|
21
|
+
const result = { ...(await whatBump(commits)) };
|
|
29
22
|
|
|
30
|
-
return
|
|
23
|
+
return {
|
|
24
|
+
...result,
|
|
25
|
+
releaseType: result.level != null ? versions[result.level] : undefined,
|
|
26
|
+
};
|
|
31
27
|
};
|
|
32
28
|
|
|
29
|
+
export type Commits = Parameters<ConventionalChangelogConfig["whatBump"]>[0];
|
|
30
|
+
|
|
33
31
|
export const generateChangelog = (
|
|
34
32
|
workspace: Workspace,
|
|
35
33
|
pkg: PackageJson,
|
|
36
34
|
config: ConventionalChangelogConfig,
|
|
35
|
+
previousTag: string | null,
|
|
37
36
|
newTag: string | null,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
verbose = false,
|
|
41
|
-
tagPrefix = "v",
|
|
42
|
-
path = "",
|
|
43
|
-
lernaPackage,
|
|
44
|
-
}: {
|
|
45
|
-
previousTag?: string;
|
|
46
|
-
verbose?: boolean;
|
|
47
|
-
tagPrefix?: string;
|
|
48
|
-
path?: string;
|
|
49
|
-
lernaPackage?: string;
|
|
50
|
-
} = {},
|
|
37
|
+
commits: Commits | undefined,
|
|
38
|
+
date: string,
|
|
51
39
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
52
40
|
): Promise<string> => {
|
|
53
41
|
if (!newTag) {
|
|
54
42
|
throw new Error(`Missing new tag for package "${pkg.name ?? ""}"`);
|
|
55
43
|
}
|
|
56
|
-
|
|
44
|
+
|
|
45
|
+
const originUrl =
|
|
46
|
+
typeof pkg.repository === "string" ? pkg.repository : pkg.repository?.url;
|
|
47
|
+
const match =
|
|
48
|
+
originUrl &&
|
|
49
|
+
typeof originUrl === "string" &&
|
|
50
|
+
/^(?:git@|https?:\/\/)(?:([^./:]+(?:\.com)?)[/:])?([^/:]+)\/([^./:]+)(?:.git)?/.exec(
|
|
51
|
+
originUrl,
|
|
52
|
+
);
|
|
53
|
+
const [, gitHost, gitAccount, repoName] = match || [
|
|
54
|
+
undefined,
|
|
55
|
+
undefined,
|
|
56
|
+
undefined,
|
|
57
|
+
undefined,
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
return writeChangelogString(
|
|
61
|
+
commits ?? [],
|
|
57
62
|
{
|
|
58
|
-
|
|
59
|
-
config,
|
|
60
|
-
pkg,
|
|
61
|
-
path,
|
|
62
|
-
append: !!previousTag,
|
|
63
|
-
releaseCount: !previousTag ? 0 : 1,
|
|
64
|
-
skipUnstable: true,
|
|
65
|
-
lernaPackage,
|
|
66
|
-
tagPrefix,
|
|
67
|
-
verbose,
|
|
63
|
+
// @ts-expect-error - missing types
|
|
68
64
|
previousTag,
|
|
69
65
|
currentTag: newTag,
|
|
70
|
-
|
|
71
|
-
{
|
|
66
|
+
linkCompare: previousTag != null,
|
|
72
67
|
version: pkg.version,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
{
|
|
78
|
-
from: previousTag,
|
|
79
|
-
path,
|
|
68
|
+
host: gitHost ? `https://${gitHost}` : undefined,
|
|
69
|
+
owner: gitAccount,
|
|
70
|
+
repository: repoName,
|
|
71
|
+
date,
|
|
80
72
|
},
|
|
73
|
+
// @ts-expect-error - missing types
|
|
74
|
+
config.writer,
|
|
81
75
|
);
|
|
82
|
-
|
|
83
|
-
return text(stream);
|
|
84
76
|
};
|