Skip to content

Commit 7465634

Browse files
committed
Merge remote-tracking branch 'upsteam/main' into feat/parse-js-yaml
2 parents 0313956 + 8acf5ca commit 7465634

17 files changed

Lines changed: 893 additions & 594 deletions

File tree

.changeset/pink-animals-heal.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@changesets/assemble-release-plan": patch
3+
---
4+
5+
fix: Throw a descriptive error if there is an issue with a package name in a changeset
File renamed without changes.

.changeset/wise-turkeys-behave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@changesets/config": patch
3+
---
4+
5+
Fixed log error link mismatch to remove dot at the end

.codesandbox/ci.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,7 @@ jobs:
6161
runs-on: ubuntu-latest
6262
if: always()
6363
needs: [test, typecheck, lint]
64-
env:
65-
FAILURE: ${{ contains(join(needs.*.result, ','), 'failure') }}
6664
steps:
67-
- name: Check for failure
68-
run: |
69-
echo $FAILURE
70-
if [ "$FAILURE" = "false" ]; then
71-
exit 0
72-
else
73-
exit 1
74-
fi
65+
- name: Exit with error if some jobs are not successful
66+
run: exit 1
67+
if: ${{ always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped') || contains(needs.*.result, 'cancelled')) }}

docs/adding-a-changeset.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ A changeset is a piece of information about changes made in a branch or commit.
1212

1313
## I am in a multi-package repository (a mono-repo)
1414

15-
1. Run the command line script `yarn changeset` or `npx @changesets/cli`.
15+
1. Run the command line script `yarn changeset` or `pnpm changeset` or `npx @changesets/cli`.
1616
2. Select the packages you want to include in the changeset using <kbd>↑</kbd> and <kbd>↓</kbd> to navigate to packages, and <kbd>space</kbd> to select a package. Hit enter when all desired packages are selected.
1717
3. You will be prompted to select a bump type for each selected package. Select an appropriate bump type for the changes made. See [here](https://semver.org/) for information on semver versioning
1818
4. Your final prompt will be to provide a message to go alongside the changeset. This will be written into the changelog when the next release occurs.
@@ -36,7 +36,7 @@ While not every changeset is going to need a huge amount of detail, a good idea
3636

3737
## I am in a single-package repository
3838

39-
1. Run the command line script `yarn changeset` or `npx @changesets/cli`.
39+
1. Run the command line script `yarn changeset` or `pnpm changeset` or `npx @changesets/cli`.
4040
2. Select an appropriate bump type for the changes made. See [here](https://semver.org/) for information on semver versioning.
4141
3. Your final prompt will be to provide a message to go alongside the changeset. This will be written into the changelog when the next release occurs.
4242

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"dependencies": {
3737
"@babel/cli": "^7.27.0",
3838
"@babel/core": "^7.26.10",
39-
"@babel/preset-env": "^7.26.9",
39+
"@babel/preset-env": "^7.28.5",
4040
"@babel/preset-typescript": "^7.27.0",
4141
"@manypkg/cli": "^0.22.0",
4242
"@preconstruct/cli": "^2.8.12",

packages/assemble-release-plan/src/flatten-releases.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { shouldSkipPackage } from "@changesets/should-skip-package";
55
import { Config, NewChangeset } from "@changesets/types";
66
import { Package } from "@manypkg/get-packages";
77
import { InternalRelease } from "./types";
8+
import { getPackageIfExists } from "./utils";
89

910
export default function flattenReleases(
1011
changesets: NewChangeset[],
@@ -19,19 +20,17 @@ export default function flattenReleases(
1920
// If their dependencies need updates, they will be added to releases by `determineDependents()` with release type `none`
2021
.filter(
2122
({ name }) =>
22-
!shouldSkipPackage(packagesByName.get(name)!, {
23-
ignore: config.ignore,
24-
allowPrivatePackages: config.privatePackages.version,
25-
})
23+
!shouldSkipPackage(
24+
getPackageIfExists(packagesByName, name, changeset),
25+
{
26+
ignore: config.ignore,
27+
allowPrivatePackages: config.privatePackages.version,
28+
}
29+
)
2630
)
2731
.forEach(({ name, type }) => {
2832
let release = releases.get(name);
29-
let pkg = packagesByName.get(name);
30-
if (!pkg) {
31-
throw new Error(
32-
`"${changeset.id}" changeset mentions a release for a package "${name}" but such a package could not be found.`
33-
);
34-
}
33+
const pkg = getPackageIfExists(packagesByName, name, changeset);
3534
if (!release) {
3635
release = {
3736
name,

packages/assemble-release-plan/src/index.test.ts

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -535,11 +535,29 @@ describe("assemble-release-plan", () => {
535535
undefined
536536
)
537537
).toThrowErrorMatchingInlineSnapshot(`
538-
"Found mixed changeset big-cats-delight
539-
Found ignored packages: pkg-b
540-
Found not ignored packages: pkg-a
541-
Mixed changesets that contain both ignored and not ignored packages are not allowed"
542-
`);
538+
"Found mixed changeset big-cats-delight
539+
Found ignored packages: pkg-b
540+
Found not ignored packages: pkg-a
541+
Mixed changesets that contain both ignored and not ignored packages are not allowed"
542+
`);
543+
});
544+
545+
it("should throw for packages not present in the project", () => {
546+
setup.addChangeset({
547+
id: "big-cats-delight",
548+
releases: [{ name: "impossible-package", type: "major" }],
549+
});
550+
551+
expect(() =>
552+
assembleReleasePlan(
553+
setup.changesets,
554+
setup.packages,
555+
defaultConfig,
556+
undefined
557+
)
558+
).toThrowErrorMatchingInlineSnapshot(
559+
`""big-cats-delight" changeset mentions a release for a package "impossible-package" but such a package could not be found."`
560+
);
543561
});
544562

545563
it("should not bump a dev dependent nor its dependent when a package gets bumped", () => {
@@ -560,28 +578,6 @@ Mixed changesets that contain both ignored and not ignored packages are not allo
560578
expect(releases[1].newVersion).toEqual("1.0.0");
561579
});
562580

563-
it("should throw an error when a changeset contains a package that is not in the workspace", () => {
564-
setup.addChangeset({
565-
id: "big-cats-delight",
566-
releases: [{ name: "pkg-a", type: "major" }],
567-
});
568-
setup.addChangeset({
569-
id: "small-dogs-sad",
570-
releases: [{ name: "pkg-z", type: "minor" }],
571-
});
572-
573-
expect(() =>
574-
assembleReleasePlan(
575-
setup.changesets,
576-
setup.packages,
577-
defaultConfig,
578-
undefined
579-
)
580-
).toThrow(
581-
"Found changeset small-dogs-sad for package pkg-z which is not in the workspace"
582-
);
583-
});
584-
585581
describe("fixed packages", () => {
586582
it("should assemble release plan for fixed packages", () => {
587583
setup.addChangeset({
@@ -634,7 +630,7 @@ Mixed changesets that contain both ignored and not ignored packages are not allo
634630
// Expected events:
635631
// - dependencies are checked, nothing leaves semver, nothing changes
636632
// - fixed are checked, pkg-a is aligned with pkg-b
637-
// - depencencies are checked, in pkg-c the dependency range for pkg-a is not satisfied, so a patch bump is given to it
633+
// - dependencies are checked, in pkg-c the dependency range for pkg-a is not satisfied, so a patch bump is given to it
638634
// - fixed are checked, pkg-c is aligned with pkg-d
639635
setup.addChangeset({
640636
id: "just-some-umbrellas",

packages/assemble-release-plan/src/index.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import flattenReleases from "./flatten-releases";
1616
import { incrementVersion } from "./increment";
1717
import matchFixedConstraint from "./match-fixed-constraint";
1818
import { InternalRelease, PreInfo } from "./types";
19+
import { getPackageIfExists } from "./utils";
1920

2021
type SnapshotReleaseParameters = {
2122
tag?: string | undefined;
@@ -126,7 +127,7 @@ function assembleReleasePlan(
126127
config: OptionalProp<Config, "snapshot">,
127128
// intentionally not using an optional parameter here so the result of `readPreState` has to be passed in here
128129
preState: PreState | undefined,
129-
// snapshot: undefined -> not using snaphot
130+
// snapshot: undefined -> not using snapshot
130131
// snapshot: { tag: undefined } -> --snapshot (empty tag)
131132
// snapshot: { tag: "canary" } -> --snapshot canary
132133
snapshot?: SnapshotReleaseParameters | string | boolean
@@ -276,19 +277,14 @@ function getRelevantChangesets(
276277
const skippedPackages = [];
277278
const notSkippedPackages = [];
278279
for (const release of changeset.releases) {
279-
const packageByName = packagesByName.get(release.name);
280-
281-
if (!packageByName) {
282-
throw new Error(
283-
`Found changeset ${changeset.id} for package ${release.name} which is not in the workspace`
284-
);
285-
}
286-
287280
if (
288-
shouldSkipPackage(packageByName, {
289-
ignore: config.ignore,
290-
allowPrivatePackages: config.privatePackages.version,
291-
})
281+
shouldSkipPackage(
282+
getPackageIfExists(packagesByName, release.name, changeset),
283+
{
284+
ignore: config.ignore,
285+
allowPrivatePackages: config.privatePackages.version,
286+
}
287+
)
292288
) {
293289
skippedPackages.push(release.name);
294290
} else {

0 commit comments

Comments
 (0)