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.
@@ -1,7 +1,4 @@
1
- import type { Readable } from "node:stream";
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: Commit[],
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
- let result: BumperRecommendation = { ...(await whatBump(commits)) };
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 result;
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
- previousTag = "",
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
- const stream: Readable = conventionalChangelogCore(
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
- cwd: workspace.cwd,
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
- currentTag: newTag,
74
- previousTag,
75
- },
76
- // @ts-expect-error -- path is required to filter commits by path. It does not work if it is only provided in options.
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
  };
@@ -0,0 +1,9 @@
1
+ import { defineConfig } from "vitest/config";
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ globals: true,
6
+ environment: "node",
7
+ include: ["src/**/*.test.ts"],
8
+ },
9
+ });