-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathbeachball.config.js
71 lines (65 loc) · 2.23 KB
/
beachball.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
const { execSync } = require("child_process");
/** @type {import("beachball").BeachballConfig } */
module.exports = {
bumpDeps: false,
access: "public",
tag: "latest",
scope: ["packages/itwin/*", "!packages/itwin/map-layers"],
ignorePatterns: [
".nycrc",
"eslint.config.js",
".mocharc.json",
".*ignore",
".github/**",
".vscode/**",
"**/test/**",
"**/e2e-tests/**",
"pnpm-lock.yaml",
"playwright.config.ts",
],
changehint: "Run 'pnpm change' to generate a change file",
changelog: {
customRenderers: {
renderEntry: (entry) => {
return `- ${entry.comment}${getPRLink(entry.commit)}`;
},
},
},
publish: true,
};
const remoteUrl = execSync("git remote get-url origin", { encoding: "utf-8" }).trim();
const prPrefix = getPRPrefix(remoteUrl);
const prRegex = prPrefix.startsWith("https://github.com") ? /#([0-9]+)/ : /^Merged PR ([0-9]+):/;
/** @type {(a:string) => string | undefined} */
function getPRPrefix(url) {
if (url.startsWith("https://github.com"))
// GitHub HTTPS
return url.replace(/\.git$/, "") + "/pull/";
if (url.includes("@github.com"))
// GitHub SSH
return `https://${url.split("@")[1]}/pull/`;
}
/** @type {(a: string) => string | undefined} */
function getPRNumber(commitHash) {
// beachball might not find commit and uses `not available` string as commit hash. Do not try to look up PR number if there is no valid commit hash.
if (commitHash === "not available") {
return undefined;
}
// %s = subject
const commitMessage = execSync(`git log -1 --pretty=format:%s ${commitHash}`, { encoding: "utf-8" });
// match PR links
const match = commitMessage.match(prRegex);
return match?.[1];
}
/** @type {(a: string) => string | undefined} */
function getPRLink(commitHash) {
const pr = getPRNumber(commitHash);
if (prPrefix && pr) {
return ` ([#${pr}](${prPrefix}${pr}))`;
}
return "";
}