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
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets).

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md).
133 changes: 133 additions & 0 deletions .changeset/changelog-generator.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import { getInfo, getInfoFromPullRequest } from "@changesets/get-github-info";

/** @typedef {import("@changesets/types").ChangelogFunctions} ChangelogFunctions */

/**
* @returns {{ GITHUB_SERVER_URL: string }} value
*/
function readEnv() {
const GITHUB_SERVER_URL =
process.env.GITHUB_SERVER_URL || "https://github.com";
return { GITHUB_SERVER_URL };
}

/** @type {ChangelogFunctions} */
const changelogFunctions = {
getDependencyReleaseLine: async (
changesets,
dependenciesUpdated,
options
) => {
if (!options.repo) {
throw new Error(
'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]'
);
}
if (dependenciesUpdated.length === 0) return "";

const changesetLink = `- Updated dependencies [${(
await Promise.all(
changesets.map(async (cs) => {
if (cs.commit) {
const { links } = await getInfo({
repo: options.repo,
commit: cs.commit
});
return links.commit;
}
})
)
)
.filter(Boolean)
.join(", ")}]:`;

const updatedDependenciesList = dependenciesUpdated.map(
(dependency) => ` - ${dependency.name}@${dependency.newVersion}`
);

return [changesetLink, ...updatedDependenciesList].join("\n");
},
getReleaseLine: async (changeset, type, options) => {
const { GITHUB_SERVER_URL } = readEnv();
if (!options || !options.repo) {
throw new Error(
'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]'
);
}

/** @type {number | undefined} */
let prFromSummary;
/** @type {string | undefined} */
let commitFromSummary;
/** @type {string[]} */
const usersFromSummary = [];

const replacedChangelog = changeset.summary
.replace(/^\s*(?:pr|pull|pull\s+request):\s*#?(\d+)/im, (_, pr) => {
const num = Number(pr);
if (!Number.isNaN(num)) prFromSummary = num;
return "";
})
.replace(/^\s*commit:\s*([^\s]+)/im, (_, commit) => {
commitFromSummary = commit;
return "";
})
.replaceAll(/^\s*(?:author|user):\s*@?([^\s]+)/gim, (_, user) => {
usersFromSummary.push(user);
return "";
})
.trim();

const [firstLine, ...futureLines] = replacedChangelog
.split("\n")
.map((l) => l.trimEnd());

const links = await (async () => {
if (prFromSummary !== undefined) {
let { links } = await getInfoFromPullRequest({
repo: options.repo,
pull: prFromSummary
});
if (commitFromSummary) {
const shortCommitId = commitFromSummary.slice(0, 7);
links = {
...links,
commit: `[\`${shortCommitId}\`](${GITHUB_SERVER_URL}/${options.repo}/commit/${commitFromSummary})`
};
}
return links;
}
const commitToFetchFrom = commitFromSummary || changeset.commit;
if (commitToFetchFrom) {
const { links } = await getInfo({
repo: options.repo,
commit: commitToFetchFrom
});
return links;
}
return {
commit: null,
pull: null,
user: null
};
})();

const users = usersFromSummary.length
? usersFromSummary
.map(
(userFromSummary) =>
`[@${userFromSummary}](${GITHUB_SERVER_URL}/${userFromSummary})`
)
.join(", ")
: links.user;

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

return `\n\n- ${firstLine} ${suffix}\n${futureLines.map((l) => ` ${l}`).join("\n")}`;
}
};

export default changelogFunctions;
10 changes: 10 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.1.2/schema.json",
"changelog": ["./changelog-generator.mjs", { "repo": "webpack/tapable" }],
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
5 changes: 5 additions & 0 deletions .changeset/fast-mangos-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tapable": patch
---

Ignore invalid `before` values.
5 changes: 5 additions & 0 deletions .changeset/some-bags-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tapable": patch
---

Trim the `name` option when options is an object.
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Release

on:
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

permissions:
id-token: write # Required for OIDC
contents: write
pull-requests: write

jobs:
release:
if: github.repository == 'webpack/tapable'
name: Release
runs-on: ubuntu-latest
outputs:
published: ${{ steps.changesets.outputs.published }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Use Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: lts/*
cache: npm

- run: npm ci

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@6a0a831ff30acef54f2c6aa1cbbc1096b066edaf # v1.7.0
with:
version: npm run version
publish: npm run release
commit: "chore(release): new release"
title: "chore(release): new release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: "" # https://github.com/changesets/changesets/issues/1152#issuecomment-3190884868
3 changes: 3 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { defineConfig } from "eslint/config";
import config from "eslint-config-webpack";

export default defineConfig([
{
ignores: [".changeset/"]
},
{
extends: [config],
rules: {
Expand Down
Loading