-
Notifications
You must be signed in to change notification settings - Fork 569
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed a crash when using tag versions of workspace packages (#1047)
* fix: Invalid comparator semver error when using tag versions * test: add testing scenario for versioning with tags * chore: typo * fix: changelog entry dependency information * chore: apply cr suggestion, move semver check earlier in the process * fix: update changelog entry for workspace range, test to cover that case * chore: move test case and adjust assertions * make one of the calls lazy * make the other one lazier too * tweak tests * tweak test title * Apply suggestions from code review --------- Co-authored-by: Mateusz Burzyński <[email protected]>
- Loading branch information
Showing
5 changed files
with
304 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@changesets/cli": patch | ||
"@changesets/apply-release-plan": patch | ||
--- | ||
|
||
Fixed a crash that could occur when depending on a tagged version of another workspace package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1081,6 +1081,63 @@ describe("workspace range", () => { | |
}, | ||
]); | ||
}); | ||
|
||
it("should update dependant CHANGELOGs with 'Dependency update' information", async () => { | ||
const cwd = await testdir({ | ||
"package.json": JSON.stringify({ | ||
private: true, | ||
workspaces: ["packages/*"], | ||
}), | ||
"packages/pkg-a/package.json": JSON.stringify({ | ||
name: "pkg-a", | ||
version: "1.0.0", | ||
}), | ||
"packages/pkg-b/package.json": JSON.stringify({ | ||
name: "pkg-b", | ||
version: "1.0.0", | ||
dependencies: { "pkg-a": "workspace:*" }, | ||
}), | ||
}); | ||
|
||
const spy = jest.spyOn(fs, "writeFile"); | ||
await writeChangeset( | ||
{ | ||
summary: "This is a summary", | ||
releases: [{ name: "pkg-a", type: "minor" }], | ||
}, | ||
cwd | ||
); | ||
await version(cwd, defaultOptions, { | ||
...modifiedDefaultConfig, | ||
___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH: { | ||
...defaultConfig.___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH, | ||
updateInternalDependents: "always", | ||
}, | ||
}); | ||
|
||
expect(getChangelog("pkg-a", spy.mock.calls)).toMatchInlineSnapshot(` | ||
"# pkg-a | ||
## 1.1.0 | ||
### Minor Changes | ||
- g1th4sh: This is a summary | ||
" | ||
`); | ||
|
||
expect(getChangelog("pkg-b", spy.mock.calls)).toMatchInlineSnapshot(` | ||
"# pkg-b | ||
## 1.0.1 | ||
### Patch Changes | ||
- Updated dependencies [g1th4sh] | ||
- [email protected] | ||
" | ||
`); | ||
}); | ||
}); | ||
|
||
describe("same package in different dependency types", () => { | ||
|
@@ -1839,6 +1896,141 @@ describe("updateInternalDependents: always", () => { | |
expect(() => getChangelog("pkg-b", spy.mock.calls)).toThrowError(); | ||
expect(() => getChangelog("pkg-c", spy.mock.calls)).toThrowError(); | ||
}); | ||
|
||
it("should not bump dependant when it depends on an npm tag of a bumped dependency", async () => { | ||
const cwd = await testdir({ | ||
"package.json": JSON.stringify({ | ||
private: true, | ||
workspaces: ["packages/*"], | ||
}), | ||
"packages/pkg-a/package.json": JSON.stringify({ | ||
name: "pkg-a", | ||
version: "1.0.0", | ||
}), | ||
"packages/pkg-b/package.json": JSON.stringify({ | ||
name: "pkg-b", | ||
version: "1.0.0", | ||
dependencies: { "pkg-a": "bulbasaur" }, // using tag version from npm | ||
}), | ||
}); | ||
|
||
const spy = jest.spyOn(fs, "writeFile"); | ||
|
||
await writeChangeset( | ||
{ | ||
summary: "This is some fix", | ||
releases: [{ name: "pkg-b", type: "patch" }], | ||
}, | ||
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)).toThrow(); | ||
|
||
expect(getPkgJSON("pkg-b", spy.mock.calls)).toEqual( | ||
expect.objectContaining({ | ||
name: "pkg-b", | ||
version: "1.0.1", | ||
dependencies: { "pkg-a": "bulbasaur" }, | ||
}) | ||
); | ||
|
||
expect(() => getChangelog("pkg-a", spy.mock.calls)).toThrow(); | ||
|
||
expect(getChangelog("pkg-b", spy.mock.calls)).toMatchInlineSnapshot(` | ||
"# pkg-b | ||
## 1.0.1 | ||
### Patch Changes | ||
- g1th4sh: This is some fix | ||
" | ||
`); | ||
}); | ||
|
||
it("should bump dependant when it depend on an npm tag of a bumped dependency when it has its own changeset", async () => { | ||
const cwd = await testdir({ | ||
"package.json": JSON.stringify({ | ||
private: true, | ||
workspaces: ["packages/*"], | ||
}), | ||
"packages/pkg-a/package.json": JSON.stringify({ | ||
name: "pkg-a", | ||
version: "1.0.0", | ||
}), | ||
"packages/pkg-b/package.json": JSON.stringify({ | ||
name: "pkg-b", | ||
version: "1.0.0", | ||
dependencies: { "pkg-a": "bulbasaur" }, // using tag version from npm | ||
}), | ||
}); | ||
|
||
const spy = jest.spyOn(fs, "writeFile"); | ||
await writeChangeset( | ||
{ | ||
summary: "This is a summary", | ||
releases: [{ name: "pkg-a", type: "minor" }], | ||
}, | ||
cwd | ||
); | ||
await writeChangeset( | ||
{ | ||
summary: "This is some fix", | ||
releases: [{ name: "pkg-b", type: "patch" }], | ||
}, | ||
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.1", | ||
dependencies: { "pkg-a": "bulbasaur" }, | ||
}) | ||
); | ||
|
||
expect(getChangelog("pkg-a", spy.mock.calls)).toMatchInlineSnapshot(` | ||
"# pkg-a | ||
## 1.1.0 | ||
### Minor Changes | ||
- g1th4sh: This is a summary | ||
" | ||
`); | ||
|
||
expect(getChangelog("pkg-b", spy.mock.calls)).toMatchInlineSnapshot(` | ||
"# pkg-b | ||
## 1.0.1 | ||
### Patch Changes | ||
- g1th4sh: This is some fix | ||
" | ||
`); | ||
}); | ||
}); | ||
|
||
describe("pre", () => { | ||
|