Skip to content
Open
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
5 changes: 1 addition & 4 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"changelog": [
"@changesets/changelog-github",
{ "repo": "changesets/changesets" }
],
"changelog": "@abizzle/changesets-cli/changelog",
"baseBranch": "main",
"commit": false,
"access": "public",
Expand Down
26 changes: 26 additions & 0 deletions .changeset/forty-trains-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
"@abizzle/changesets-assemble-release-plan": minor
"@abizzle/changesets-apply-release-plan": minor
"@abizzle/changesets-changelog-github": minor
"@abizzle/changesets-changelog-git": minor
"@abizzle/changesets-config": minor
"@abizzle/changesets-types": minor
---

Add support for single changelog fixed package groups.

Optionally supply an object as a fixed package group entry like so:

```json
{
"fixed": [
{
"group": ["@changesets/button", "@changesets/theme"],
"changelog": "CHANGELOG.md",
"name": "UI Packages"
}
]
}
```

This will create/update a single changelog at `<projectRoot>/CHANGELOG.md` with changelog entries for `@changesets/button` and `@changesets/theme` under the title "UI Packages".
6 changes: 6 additions & 0 deletions .changeset/good-flies-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@abizzle/changesets-types": minor
"@abizzle/changesets-apply-release-plan": patch
---

Fix logic to write a single changelog entry for fixed groups
33 changes: 33 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"mode": "pre",
"tag": "next",
"initialVersions": {
"@abizzle/changesets-apply-release-plan": "6.1.3",
"@abizzle/changesets-assemble-release-plan": "5.2.3",
"@abizzle/changesets-changelog-git": "0.1.14",
"@abizzle/changesets-changelog-github": "0.4.8",
"@abizzle/changesets-cli": "2.26.0",
"@abizzle/changesets-config": "2.3.0",
"@changesets/errors": "0.1.4",
"@changesets/get-dependents-graph": "1.3.5",
"@changesets/get-github-info": "0.5.2",
"@abizzle/changesets-get-release-plan": "3.0.16",
"@changesets/get-version-range-type": "0.3.2",
"get-workspaces": "1.0.10",
"@changesets/git": "2.0.0",
"@changesets/logger": "0.0.5",
"@changesets/parse": "0.3.16",
"@changesets/pre": "1.0.14",
"@changesets/read": "0.5.9",
"@changesets/release-utils": "0.1.12",
"@abizzle/changesets-types": "5.2.1",
"@changesets/write": "0.2.3",
"@changesets/test-utils": "0.0.5"
},
"changesets": [
"forty-trains-accept",
"good-flies-do",
"shy-singers-turn",
"strange-jars-nail"
]
}
9 changes: 9 additions & 0 deletions .changeset/shy-singers-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@abizzle/changesets-assemble-release-plan": patch
"@abizzle/changesets-apply-release-plan": patch
"@abizzle/changesets-get-release-plan": patch
"@abizzle/changesets-types": patch
"@abizzle/changesets-cli": patch
---

Fixes dist files
8 changes: 8 additions & 0 deletions .changeset/strange-jars-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@abizzle/changesets-assemble-release-plan": major
"@abizzle/changesets-apply-release-plan": major
"@abizzle/changesets-types": major
"@abizzle/changesets-cli": minor
---

Fixes single changelog fixed groups.
16 changes: 15 additions & 1 deletion docs/config-file-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ These restrictions exist to ensure your repository or published code do not end

> NOTE: you can also provide glob expressions to match the packages, according to the [micromatch](https://www.npmjs.com/package/micromatch) format.

## `fixed` (array of arrays of package names)
## `fixed` (array of either arrays of package names or objects with `group` (array of package names), `changelog` (filepath relative to project root), and `name` properties)

This option can be used to declare that packages should be version-bumped and published together. As an example, if you have a `@changesets/button` component and a `@changesets/theme` component and you want to make sure that when one gets bumped to `1.1.0`, the other is also bumped to `1.1.0` regardless if it has any change or not. To achieve this you would have the config:

Expand All @@ -82,6 +82,20 @@ This option can be used to declare that packages should be version-bumped and pu
}
```

If you want to produce/update a single changelog for the group, you would have a config like so:

```json
{
"fixed": [
{
"group": ["@changesets/button", "@changesets/theme"],
"changelog": "CHANGELOG.md",
"name": "UI Packages"
}
]
}
```

If you want to use this option, you should read the documentation on [fixed packages](./fixed-packages.md) to fully understand the implementation and implications.

## `linked` (array of arrays of package names)
Expand Down
46 changes: 46 additions & 0 deletions docs/fixed-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,49 @@ For example:
It will match all packages starting with `pkg-`.

**The glob expressions must be defined according to the [micromatch](https://www.npmjs.com/package/micromatch) format.**

## Single Changelog Group

If you want to produce a single changelog for a fixed package group, use an object in your configuration like so:

```json
{
"fixed": [
{
"group": ["pkg-a", "pkg-b", "pkg-c"],
"changelog": "CHANGELOG.md",
"name": "My Stuff"
}
]
}
```

For example, if I have a changeset with a patch for pkg-a, a second changeset with a minor for pkg-b, and third changeset with a major for pkg-a and pkg-c and I do a release, the resulting changelog will be:

```
# My Stuff

## 2.0.0

### Major Changes

- [1234567] **(pkg-a, pkg-c)** Lorem ipsum.

### Minor Changes

- [2345678] **(pkg-b)** Blah blah.

### Patch Changes

- [3456789] **(pkg-a)** Something something.
```

Should I have another changeset that mixes packages and version types, such as a changeset for a patch for pkg-a and a major for pkg-b, the highest version type will win, resulting in a changelog entry like:

```
## 3.0.0

### Major Changes

- [4567890] **(pkg-a, pkg-b)** Lorem ipsum.
```
58 changes: 57 additions & 1 deletion packages/apply-release-plan/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,60 @@
# @changesets/apply-release-plan
# @abizzle/changesets-apply-release-plan

## 7.0.0-next.3

### Patch Changes

- c5a83f9: Fix logic to write a single changelog entry for fixed groups
- Updated dependencies [c5a83f9]
- @abizzle/changesets-types@6.0.0-next.3
- @abizzle/changesets-config@2.4.0-next.1

## 7.0.0-next.2

### Patch Changes

- Fixes dist files
- Updated dependencies
- @abizzle/changesets-types@6.0.0-next.2

## 7.0.0-next.1

### Major Changes

- efd8c06: Fixes single changelog fixed groups.

### Patch Changes

- Updated dependencies [efd8c06]
- @abizzle/changesets-types@6.0.0-next.1

## 6.2.0-next.0

### Minor Changes

- 850b82e: Add support for single changelog fixed package groups.

Optionally supply an object as a fixed package group entry like so:

```json
{
"fixed": [
{
"group": ["@changesets/button", "@changesets/theme"],
"changelog": "CHANGELOG.md",
"name": "UI Packages"
}
]
}
```

This will create/update a single changelog at `<projectRoot>/CHANGELOG.md` with changelog entries for `@changesets/button` and `@changesets/theme` under the title "UI Packages".

### Patch Changes

- Updated dependencies [850b82e]
- @abizzle/changesets-config@2.4.0-next.0
- @abizzle/changesets-types@5.3.0-next.0

## 6.1.3

Expand Down
12 changes: 6 additions & 6 deletions packages/apply-release-plan/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "@changesets/apply-release-plan",
"version": "6.1.3",
"name": "@abizzle/changesets-apply-release-plan",
"version": "7.0.0-next.3",
"description": "Takes a release plan and applies it to packages",
"main": "dist/apply-release-plan.cjs.js",
"module": "dist/apply-release-plan.esm.js",
"main": "dist/changesets-apply-release-plan.cjs.js",
"module": "dist/changesets-apply-release-plan.esm.js",
"license": "MIT",
"repository": "https://github.com/changesets/changesets/tree/main/packages/apply-release-plan",
"dependencies": {
"@abizzle/changesets-config": "^2.4.0-next.1",
"@abizzle/changesets-types": "^6.0.0-next.3",
"@babel/runtime": "^7.20.1",
"@changesets/config": "^2.3.0",
"@changesets/get-version-range-type": "^0.3.2",
"@changesets/git": "^2.0.0",
"@changesets/types": "^5.2.1",
"@manypkg/get-packages": "^1.1.3",
"detect-indent": "^6.0.0",
"fs-extra": "^7.0.1",
Expand Down
49 changes: 46 additions & 3 deletions packages/apply-release-plan/src/get-changelog-entry.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { ChangelogFunctions, NewChangesetWithCommit } from "@changesets/types";
import {
ChangelogFunctions,
ModCompGroupWithPackage,
NewChangesetWithCommit,
} from "@abizzle/changesets-types";

import { ModCompWithPackage } from "@changesets/types";
import { ModCompWithPackage } from "@abizzle/changesets-types";
import startCase from "lodash.startcase";
import { shouldUpdateDependencyBasedOnConfig } from "./utils";

Expand All @@ -22,7 +26,7 @@ async function generateChangesForVersionTypeMarkdown(
}

// release is the package and version we are releasing
export default async function getChangelogEntry(
export async function getChangelogEntryForIndividualRelease(
release: ModCompWithPackage,
releases: ModCompWithPackage[],
changesets: NewChangesetWithCommit[],
Expand Down Expand Up @@ -107,3 +111,42 @@ export default async function getChangelogEntry(
.filter((line) => line)
.join("\n");
}

export async function getChangelogEntryForGroupRelease(
release: ModCompGroupWithPackage,
changesets: NewChangesetWithCommit[],
changelogFuncs: ChangelogFunctions,
changelogOpts: any
) {
if (release.projects.every((p) => p.type === "none")) return null;

const changelogLines: ChangelogLines = {
major: [],
minor: [],
patch: [],
};

changesets.forEach((cs) => {
const rls = cs.releases.find((r) =>
release.projects.some((p) => p.name === r.name)
);
if (rls && rls.type !== "none") {
changelogLines[rls.type].push(
changelogFuncs.getReleaseLine(
{ ...cs, groupedChangelog: true },
rls.type,
changelogOpts
)
);
}
});

return [
`## ${release.newVersion}`,
await generateChangesForVersionTypeMarkdown(changelogLines, "major"),
await generateChangesForVersionTypeMarkdown(changelogLines, "minor"),
await generateChangesForVersionTypeMarkdown(changelogLines, "patch"),
]
.filter((line) => line)
.join("\n");
}
Loading