@modern-js/plugin-changeset 2.22.1-beta.0 → 2.22.1-beta.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.
@@ -83,20 +83,26 @@ function getCommitType(message) {
83
83
  }
84
84
  return CommitType.Other;
85
85
  }
86
- async function getReleaseInfo(commit, commitObj) {
86
+ const AuthorMap = /* @__PURE__ */ new Map();
87
+ async function getReleaseInfo(commit, commitObj, authToken) {
87
88
  const commitRegex = /(.*)\(#(\d*)\)/;
88
- const [commitId, message] = commit.split("--");
89
- const AuthToken = process.env.GITHUB_AUTH_TOKEN;
90
- if (AuthToken) {
89
+ const [commitId, message, email] = commit.split("--");
90
+ const author = AuthorMap.get(email);
91
+ const token = authToken || process.env.GITHUB_AUTH_TOKEN;
92
+ if (author) {
93
+ commitObj.author = author;
94
+ } else if (token) {
91
95
  try {
92
96
  const res = await _axios.default.get(`https://api.github.com/repos/web-infra-dev/modern.js/commits/${commitId}`, {
93
97
  method: "GET",
94
98
  headers: {
95
99
  "Content-Type": "application/json",
96
- Authorization: AuthToken
100
+ Authorization: token
97
101
  }
98
102
  });
99
- commitObj.author = res.data.author.login;
103
+ const author2 = res.data.author.login;
104
+ commitObj.author = author2;
105
+ AuthorMap.set(email, author2);
100
106
  } catch (e) {
101
107
  console.warn(e);
102
108
  }
@@ -189,7 +195,7 @@ async function genReleaseNote(options) {
189
195
  if (customReleaseNoteFunction === null || customReleaseNoteFunction === void 0 ? void 0 : customReleaseNoteFunction.getReleaseInfo) {
190
196
  commitObj = await customReleaseNoteFunction.getReleaseInfo(stdout, commitObj);
191
197
  } else {
192
- commitObj = await getReleaseInfo(stdout, commitObj);
198
+ commitObj = await getReleaseInfo(stdout, commitObj, options.authToken);
193
199
  }
194
200
  releaseNote[commitObj.type].en.push(commitObj);
195
201
  if (commitObj.summary_zh) {
@@ -42,20 +42,26 @@ export function getCommitType(message) {
42
42
  }
43
43
  return CommitType.Other;
44
44
  }
45
- export async function getReleaseInfo(commit, commitObj) {
45
+ const AuthorMap = /* @__PURE__ */ new Map();
46
+ export async function getReleaseInfo(commit, commitObj, authToken) {
46
47
  const commitRegex = /(.*)\(#(\d*)\)/;
47
- const [commitId, message] = commit.split("--");
48
- const AuthToken = process.env.GITHUB_AUTH_TOKEN;
49
- if (AuthToken) {
48
+ const [commitId, message, email] = commit.split("--");
49
+ const author = AuthorMap.get(email);
50
+ const token = authToken || process.env.GITHUB_AUTH_TOKEN;
51
+ if (author) {
52
+ commitObj.author = author;
53
+ } else if (token) {
50
54
  try {
51
55
  const res = await axios.get(`https://api.github.com/repos/web-infra-dev/modern.js/commits/${commitId}`, {
52
56
  method: "GET",
53
57
  headers: {
54
58
  "Content-Type": "application/json",
55
- Authorization: AuthToken
59
+ Authorization: token
56
60
  }
57
61
  });
58
- commitObj.author = res.data.author.login;
62
+ const author2 = res.data.author.login;
63
+ commitObj.author = author2;
64
+ AuthorMap.set(email, author2);
59
65
  } catch (e) {
60
66
  console.warn(e);
61
67
  }
@@ -148,7 +154,7 @@ export async function genReleaseNote(options) {
148
154
  if (customReleaseNoteFunction === null || customReleaseNoteFunction === void 0 ? void 0 : customReleaseNoteFunction.getReleaseInfo) {
149
155
  commitObj = await customReleaseNoteFunction.getReleaseInfo(stdout, commitObj);
150
156
  } else {
151
- commitObj = await getReleaseInfo(stdout, commitObj);
157
+ commitObj = await getReleaseInfo(stdout, commitObj, options.authToken);
152
158
  }
153
159
  releaseNote[commitObj.type].en.push(commitObj);
154
160
  if (commitObj.summary_zh) {
@@ -24,6 +24,7 @@ export type ReleaseNote = Record<CommitType, Changes>;
24
24
  interface ReleaseNoteOptions {
25
25
  repo?: string;
26
26
  custom?: string;
27
+ authToken?: string;
27
28
  }
28
29
  export type CustomReleaseNoteFunction = {
29
30
  getReleaseInfo?: (commit: string, commitObj: Commit) => Commit | Promise<Commit>;
@@ -46,7 +47,7 @@ export declare const CommitTypeZhTitle: {
46
47
  other: string;
47
48
  };
48
49
  export declare function getCommitType(message: string): CommitType;
49
- export declare function getReleaseInfo(commit: string, commitObj: Commit): Promise<Commit>;
50
+ export declare function getReleaseInfo(commit: string, commitObj: Commit, authToken?: string): Promise<Commit>;
50
51
  export declare function getReleaseNoteLine(commit: Commit, customReleaseNoteFunction?: CustomReleaseNoteFunction, lang?: 'en' | 'zh'): string | Promise<string>;
51
52
  export declare function genReleaseNote(options: ReleaseNoteOptions): Promise<string>;
52
53
  export {};
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.22.1-beta.0",
18
+ "version": "2.22.1-beta.2",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",