Skip to content

Commit f3423c3

Browse files
chore: integrate changeset and trusted publisher
1 parent fcc44f9 commit f3423c3

32 files changed

+9921
-16875
lines changed

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/changelog-generator.mjs

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
import { getInfo, getInfoFromPullRequest } from "@changesets/get-github-info";
2+
3+
/** @typedef {import("@changesets/types").ChangelogFunctions} ChangelogFunctions */
4+
5+
/**
6+
* @returns {{ GITHUB_SERVER_URL: string }} value
7+
*/
8+
function readEnv() {
9+
const GITHUB_SERVER_URL = process.env.GITHUB_SERVER_URL || "https://github.com";
10+
return { GITHUB_SERVER_URL };
11+
}
12+
13+
/** @type {ChangelogFunctions} */
14+
const changelogFunctions = {
15+
getDependencyReleaseLine: async (changesets, dependenciesUpdated, options) => {
16+
if (!options.repo) {
17+
throw new Error(
18+
'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]',
19+
);
20+
}
21+
if (dependenciesUpdated.length === 0) return "";
22+
23+
const changesetLink = `- Updated dependencies [${(
24+
await Promise.all(
25+
changesets.map(async (cs) => {
26+
if (cs.commit) {
27+
const { links } = await getInfo({
28+
repo: options.repo,
29+
commit: cs.commit,
30+
});
31+
return links.commit;
32+
}
33+
}),
34+
)
35+
)
36+
.filter(Boolean)
37+
.join(", ")}]:`;
38+
39+
const updatedDependenciesList = dependenciesUpdated.map(
40+
(dependency) => ` - ${dependency.name}@${dependency.newVersion}`,
41+
);
42+
43+
return [changesetLink, ...updatedDependenciesList].join("\n");
44+
},
45+
getReleaseLine: async (changeset, type, options) => {
46+
const { GITHUB_SERVER_URL } = readEnv();
47+
if (!options || !options.repo) {
48+
throw new Error(
49+
'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]',
50+
);
51+
}
52+
53+
/** @type {number | undefined} */
54+
let prFromSummary;
55+
/** @type {string | undefined} */
56+
let commitFromSummary;
57+
/** @type {string[]} */
58+
const usersFromSummary = [];
59+
60+
const replacedChangelog = changeset.summary
61+
.replace(/^\s*(?:pr|pull|pull\s+request):\s*#?(\d+)/im, (_, pr) => {
62+
const num = Number(pr);
63+
if (!Number.isNaN(num)) prFromSummary = num;
64+
return "";
65+
})
66+
.replace(/^\s*commit:\s*([^\s]+)/im, (_, commit) => {
67+
commitFromSummary = commit;
68+
return "";
69+
})
70+
.replaceAll(/^\s*(?:author|user):\s*@?([^\s]+)/gim, (_, user) => {
71+
usersFromSummary.push(user);
72+
return "";
73+
})
74+
.trim();
75+
76+
const [firstLine, ...futureLines] = replacedChangelog.split("\n").map((l) => l.trimEnd());
77+
78+
const links = await (async () => {
79+
if (prFromSummary !== undefined) {
80+
let { links } = await getInfoFromPullRequest({
81+
repo: options.repo,
82+
pull: prFromSummary,
83+
});
84+
if (commitFromSummary) {
85+
const shortCommitId = commitFromSummary.slice(0, 7);
86+
links = {
87+
...links,
88+
commit: `[\`${shortCommitId}\`](${GITHUB_SERVER_URL}/${options.repo}/commit/${commitFromSummary})`,
89+
};
90+
}
91+
return links;
92+
}
93+
const commitToFetchFrom = commitFromSummary || changeset.commit;
94+
if (commitToFetchFrom) {
95+
const { links } = await getInfo({
96+
repo: options.repo,
97+
commit: commitToFetchFrom,
98+
});
99+
return links;
100+
}
101+
return {
102+
commit: null,
103+
pull: null,
104+
user: null,
105+
};
106+
})();
107+
108+
const users = usersFromSummary.length
109+
? usersFromSummary
110+
.map(
111+
(userFromSummary) => `[@${userFromSummary}](${GITHUB_SERVER_URL}/${userFromSummary})`,
112+
)
113+
.join(", ")
114+
: links.user;
115+
116+
let suffix = "";
117+
if (links.pull || links.commit || users) {
118+
suffix = `(${users ? `by ${users} ` : ""}in ${links.pull || links.commit})`;
119+
}
120+
121+
return `\n\n- ${firstLine} ${suffix}\n${futureLines.map((l) => ` ${l}`).join("\n")}`;
122+
},
123+
};
124+
125+
export default changelogFunctions;

.changeset/cold-swans-build.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack-cli": patch
3+
---
4+
5+
Allow configuration freezing.

.changeset/config.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@3.1.2/schema.json",
3+
"changelog": ["./changelog-generator.mjs", { "repo": "webpack/webpack-cli" }],
4+
"fixed": [],
5+
"linked": [],
6+
"access": "public",
7+
"baseBranch": "main",
8+
"updateInternalDependencies": "patch",
9+
"ignore": []
10+
}

.changeset/cuddly-hands-refuse.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack-cli": major
3+
---
4+
5+
The minimum supported version of Node.js is `20.9.0`.

.changeset/dark-pugs-heal.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack-cli": patch
3+
---
4+
5+
Use graceful shutdown when file system cache is enabled.

.changeset/fair-results-warn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack-cli": major
3+
---
4+
5+
Use dynamic import to load `webpack.config.js`, fallback to interpret only when configuration can't be load by dynamic import. Using dynamic imports allows you to take advantage of Node.js's built-in TypeScript support.

.changeset/lazy-bars-stay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack-cli": major
3+
---
4+
5+
Removed the `--node-env` argument in favor of the `--config-node-env` argument.

.changeset/nice-lemons-play.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack-cli": major
3+
---
4+
5+
The `version` command only output versions right now.

.changeset/smart-coats-battle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-new-webpack-app": major
3+
---
4+
5+
The minimum supported version of Node.js is `20.9.0`.

0 commit comments

Comments
 (0)