Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue with incorrect dependent updates on none changesets with updateInternalDependents: "always" #949

Merged
merged 9 commits into from Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,3 @@
# We just want a file in here so git collects it

For this we have deliberately not included a config file, as we want to test the defaults
11 changes: 11 additions & 0 deletions __fixtures__/simplest-transitive-devdependent/package.json
@@ -0,0 +1,11 @@
{
"private": true,
"name": "simple-project",
"description": "three projects, each depending on one other",
"version": "1.0.0",
"bolt": {
"workspaces": [
"packages/*"
]
}
}
@@ -0,0 +1,4 @@
{
"name": "pkg-a",
"version": "1.0.0"
}
@@ -0,0 +1,5 @@
{
"name": "pkg-b",
"version": "1.0.0",
"devDependencies": { "pkg-a": "1.0.0" }
}
@@ -0,0 +1,5 @@
{
"name": "pkg-c",
"version": "1.0.0",
"dependencies": { "pkg-b": "1.0.0" }
}
25 changes: 25 additions & 0 deletions packages/assemble-release-plan/src/index.test.ts
Expand Up @@ -1387,6 +1387,31 @@ describe("bumping peerDeps", () => {
expect(releases[2].name).toEqual("pkg-c");
expect(releases[2].newVersion).toEqual("1.0.1");
});

it("should not bump a transitive dependent when a devDependency package gets bumped", () => {
setup.addPackage("pkg-c", "1.0.0");
setup.updateDevDependency("pkg-b", "pkg-a", "^1.0.0");
setup.updateDependency("pkg-c", "pkg-b", "^1.0.0");

let { releases } = assembleReleasePlan(
setup.changesets,
setup.packages,
{
...defaultConfig,
___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: {
...defaultConfig.___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH,
updateInternalDependents: "always",
},
},
undefined
);

expect(releases.length).toBe(2);
expect(releases[0].name).toEqual("pkg-a");
expect(releases[0].newVersion).toEqual("1.0.1");
expect(releases[1].name).toEqual("pkg-b");
expect(releases[1].newVersion).toEqual("1.0.0");
});
});

it("should major bump dependent when leaving range", () => {
Expand Down
53 changes: 53 additions & 0 deletions packages/cli/src/commands/version/version.test.ts
Expand Up @@ -1066,6 +1066,59 @@ describe("updateInternalDependents: always", () => {
"
`);
});

it("should not bump a devDependency or any of its dependants when a dependency package gets bumped", async () => {
const cwd = await f.copy("simplest-transitive-devdependent");
const spy = jest.spyOn(fs, "writeFile");
await writeChangeset(simpleChangeset, cwd);
await version(cwd, defaultOptions, {
...modifiedDefaultConfig,
___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: {
...defaultConfig.___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH,
updateInternalDependents: "always",
},
});

expect(getPkgJSON("pkg-a", spy.mock.calls)).toEqual(
expect.objectContaining({
name: "pkg-a",
version: "1.1.0",
})
);
expect(getPkgJSON("pkg-b", spy.mock.calls)).toEqual(
expect.objectContaining({
name: "pkg-b",
version: "1.0.0",
devDependencies: {
"pkg-a": "1.1.0",
},
})
);
expect(getPkgJSON("pkg-c", spy.mock.calls)).toEqual(
expect.objectContaining({
name: "pkg-c",
version: "1.0.0",
dependencies: {
"pkg-b": "1.0.0",
},
})
);
Copy link
Member

Choose a reason for hiding this comment

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

Correct me if I'm wrong but this one should not be part of the valid expectation, right? In this situation the pkg-c should be left untouched

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're correct - pkg-c's package.json should be untouched. I didn't spot that getPkgJSON behaves in the same way as getChangelog and throws an error if it wasn't touched.

expect(getChangelog("pkg-a", spy.mock.calls)).toMatchInlineSnapshot(`
"# pkg-a

## 1.1.0

### Minor Changes

- g1th4sh: This is a summary
"
`);

// pkg-b and - pkg-c are not being released so changelogs should not be
// generated for them
expect(() => getChangelog("pkg-b", spy.mock.calls)).toThrowError();
expect(() => getChangelog("pkg-c", spy.mock.calls)).toThrowError();
});
});

describe("pre", () => {
Expand Down