Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 59 additions & 17 deletions .changeset/changelog-generator.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { getInfo, getInfoFromPullRequest } from "@changesets/get-github-info";
import { getCommitInfo, getPullRequestInfo } from "@changesets/get-github-info";

/** @typedef {import("@changesets/types").ChangelogFunctions} ChangelogFunctions */
/** @typedef {import("@changesets/get-github-info").CommitInfo} CommitInfo */
/** @typedef {import("@changesets/get-github-info").PullRequestInfo} PullRequestInfo */

/**
* @typedef {object} Links
* @property {string | null} commit markdown link to the commit
* @property {string | null} pull markdown link to the pull request
* @property {string | null} user markdown link to the author
*/

/**
* @returns {{ GITHUB_SERVER_URL: string }} value
Expand All @@ -11,6 +20,24 @@ function readEnv() {
return { GITHUB_SERVER_URL };
}

/**
* Flattens what GitHub reported into the three links a changelog line uses.
* Every field is null when the lookup found nothing.
* @param {CommitInfo | PullRequestInfo | undefined} info what GitHub reported
* @returns {Links} links
*/
function toLinks(info) {
if (!info) {
return { commit: null, pull: null, user: null };
}

return {
commit: info.commit ? info.commit.markdownLink : null,
pull: info.pull ? info.pull.markdownLink : null,
user: info.author ? info.author.markdownLink : null,
};
}

/** @type {ChangelogFunctions} */
const changelogFunctions = {
getDependencyReleaseLine: async (
Expand All @@ -29,12 +56,15 @@ const changelogFunctions = {
await Promise.all(
changesets.map(async (cs) => {
if (cs.commit) {
const { links } = await getInfo({
const info = await getCommitInfo({
repo: options.repo,
commit: cs.commit,
});
return links.commit;

return info ? info.commit.markdownLink : undefined;
}

return undefined;
}),
)
)
Expand Down Expand Up @@ -84,26 +114,32 @@ const changelogFunctions = {

const links = await (async () => {
if (prFromSummary !== undefined) {
let { links } = await getInfoFromPullRequest({
repo: options.repo,
pull: prFromSummary,
});
const linksFromPullRequest = toLinks(
await getPullRequestInfo({
repo: options.repo,
pull: prFromSummary,
}),
);
Comment thread
coderabbitai[bot] marked this conversation as resolved.

if (commitFromSummary) {
const shortCommitId = commitFromSummary.slice(0, 7);
links = {
...links,

return {
...linksFromPullRequest,
commit: `[\`${shortCommitId}\`](${GITHUB_SERVER_URL}/${options.repo}/commit/${commitFromSummary})`,
};
}
return links;

return linksFromPullRequest;
}
const commitToFetchFrom = commitFromSummary || changeset.commit;
if (commitToFetchFrom) {
const { links } = await getInfo({
repo: options.repo,
commit: commitToFetchFrom,
});
return links;
return toLinks(
await getCommitInfo({
repo: options.repo,
commit: commitToFetchFrom,
}),
);
}
return {
commit: null,
Expand All @@ -121,9 +157,15 @@ const changelogFunctions = {
.join(", ")
: links.user;

// 1.0 reports nothing when a commit or pull request is not found, so the
// link half has to be dropped rather than printed as `null`.
const link = links.pull || links.commit;

let suffix = "";
if (links.pull || links.commit || users) {
suffix = `(${users ? `by ${users} ` : ""}in ${links.pull || links.commit})`;
if (link) {
suffix = `(${users ? `by ${users} ` : ""}in ${link})`;
} else if (users) {
suffix = `(by ${users})`;
}

return `\n\n- ${firstLine} ${suffix}\n${futureLines.map((l) => ` ${l}`).join("\n")}`;
Expand Down
5 changes: 5 additions & 0 deletions .changeset/update-changesets-tooling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"webpack-dev-middleware": patch
---

Update the changelog generator to the `@changesets/get-github-info` 1.0 API.
12 changes: 7 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ jobs:

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@a45c4d594aa4e2c509dc14a9f2b3b67ba3780d0d # v1.9.0
uses: changesets/action@198f833dd7d863100ea6e28967bc9a9fdefadb0a # v2.1.0
Comment thread
coderabbitai[bot] marked this conversation as resolved.
with:
version: npm run version
publish: npm run release
commit: "chore(release): new release"
title: "chore(release): new release"
version-script: npm run version
publish-script: npm run release
commit-message: "chore(release): new release"
pr-title: "chore(release): new release"
env:
# v2 no longer reads this for its own auth, but `changeset version`
# runs the changelog generator, which needs it to query GitHub.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: "" # https://github.com/changesets/changesets/issues/1152#issuecomment-3190884868
8 changes: 8 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ export default defineConfig([
"n/hashbang": "off",
},
},
{
// `@changesets/get-github-info` is ESM-only and ships an `exports` map with
// no `main`, which the import resolver cannot follow. Node resolves it.
files: [".changeset/changelog-generator.mjs"],
rules: {
"import/no-unresolved": "off",
},
},
{
files: ["client-src/**/*"],
extends: [configs["browser-outdated-recommended-module"]],
Expand Down
68 changes: 12 additions & 56 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@babel/core": "^7.29.7",
"@babel/preset-env": "^7.29.7",
"@changesets/cli": "^3.0.1",
"@changesets/get-github-info": "^0.8.0",
"@changesets/get-github-info": "^1.0.0",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

🔎 Supported by static analysis

🏁 Script executed:

printf '%s\n' '--- package manifest ---'
sed -n '50,72p' package.json
printf '%s\n' '--- lockfile entries ---'
rg -n -A12 -B3 '"?`@changesets/get-github-info`|node_modules/@changesets/get-github-info|engines' package-lock.json yarn.lock pnpm-lock.yaml 2>/dev/null || true
printf '%s\n' '--- Node 20 baseline declarations ---'
rg -n -i 'node.?20|engines|setup-node|runtime' package.json .nvmrc .node-version .github 2>/dev/null | head -120

Repository: webpack/webpack-dev-middleware

Length of output: 50387


🏁 Script executed:

python3 - <<'PY'
import json
from pathlib import Path

for name in ("package.json", "package-lock.json"):
    p = Path(name)
    if not p.exists():
        continue
    data = json.loads(p.read_text())
    print(f"--- {name} ---")
    if name == "package.json":
        print("engines:", data.get("engines"))
        print("dependency:", data.get("devDependencies", {}).get("`@changesets/get-github-info`"))
        print("scripts:", {k:v for k,v in data.get("scripts", {}).items() if "release" in k or "change" in k})
    else:
        node = data.get("packages", {}).get("node_modules/@changesets/get-github-info")
        root = data.get("packages", {}).get("", {})
        print("root engines:", root.get("engines"))
        print("root devDependency:", root.get("devDependencies", {}).get("`@changesets/get-github-info`"))
        print("package entry:", node)
PY
printf '%s\n' '--- version-control and CI Node declarations ---'
for f in .nvmrc .node-version; do [ -f "$f" ] && { echo "[$f]"; cat "$f"; }; done
rg -n -i -g '!package-lock.json' -g '!node_modules' 'node-version|NODE_VERSION|node: *20|node 20|node\.js *20|engines' package.json .github README.md 2>/dev/null | head -160

Repository: webpack/webpack-dev-middleware

Length of output: 1870


🏁 Script executed:

printf '%s\n' '--- release workflow and install policy ---'
sed -n '1,120p' .github/workflows/release.yml
printf '%s\n' '--- package manager and npm engine policy ---'
for f in .npmrc .yarnrc .yarnrc.yml pnpm-workspace.yaml; do [ -f "$f" ] && { echo "[$f]"; cat "$f"; }; done
rg -n -i 'npm (ci|install)|yarn install|pnpm install|engine-strict|changeset|release' .github package.json . 2>/dev/null | head -180
printf '%s\n' '--- direct package references ---'
rg -n -F '`@changesets/get-github-info`' --glob '!package-lock.json' --glob '!node_modules' .

Repository: webpack/webpack-dev-middleware

Length of output: 12943


🏁 Script executed:

printf '%s\n' '--- changelog generator imports ---'
sed -n '1,100p' .changeset/changelog-generator.mjs
printf '%s\n' '--- package engine and Node 20 workflow context ---'
sed -n '96,114p' package.json
sed -n '55,88p' .github/workflows/nodejs.yml

Repository: webpack/webpack-dev-middleware

Length of output: 4720


Keep @changesets/get-github-info compatible with Node 20.

The repository supports Node >=20.9.0 and tests Node 20.x. The locked @changesets/get-github-info@1.0.0 declares only ^22.11 || ^24 || >=26. Use a Node 20-compatible version or raise the repository and workflow baseline together.

Source: MCP tools

"@fastify/express": "^4.0.7",
"@hapi/hapi": "^21.4.10",
"@hono/node-server": "^2.1.1",
Expand Down