mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
Validate that projects use Changesets CLI v3 and direct Changesets CLI v2 users to changesets/action@v1 (#699)
* Validate that projects use Changesets CLI v3 and direct Changesets CLI v2 users to `changesets/action@v1` * better spy/mocking * fmt * shuffle
This commit is contained in:
+53
-1
@@ -1,5 +1,11 @@
|
||||
import { createFixture } from "fs-fixture";
|
||||
import { expect, test } from "vitest";
|
||||
import { BumpLevels, getChangelogEntry, sortTheThings } from "./utils.ts";
|
||||
import {
|
||||
BumpLevels,
|
||||
getChangelogEntry,
|
||||
sortTheThings,
|
||||
validateChangesetsCliVersion,
|
||||
} from "./utils.ts";
|
||||
|
||||
let changelog = `# @keystone-alpha/email
|
||||
|
||||
@@ -100,3 +106,49 @@ test("it sorts the things right", () => {
|
||||
];
|
||||
expect(things.sort(sortTheThings)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test("throws when the project declares Changesets CLI v2", async () => {
|
||||
await using fixture = await createFixture({
|
||||
"package.json": JSON.stringify({
|
||||
name: "project",
|
||||
devDependencies: { "@changesets/cli": "^2.29.7" },
|
||||
}),
|
||||
"package-lock.json": "",
|
||||
});
|
||||
|
||||
await expect(validateChangesetsCliVersion(fixture.path)).rejects.toThrow(
|
||||
"This version of the Changesets action is designed to work with Changesets CLI v3. Changesets CLI v2 is not supported; use Changesets action v1 instead, which is compatible with CLI v2.",
|
||||
);
|
||||
});
|
||||
|
||||
test("accepts a Changesets CLI v3 contract without an installed CLI", async () => {
|
||||
await using fixture = await createFixture({
|
||||
"package.json": JSON.stringify({
|
||||
name: "project",
|
||||
devDependencies: { "@changesets/cli": "^3.0.0" },
|
||||
}),
|
||||
"package-lock.json": "",
|
||||
});
|
||||
|
||||
await expect(
|
||||
validateChangesetsCliVersion(fixture.path),
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
test("throws when the project has Changesets CLI v2 installed", async () => {
|
||||
await using fixture = await createFixture({
|
||||
"package.json": JSON.stringify({
|
||||
name: "project",
|
||||
devDependencies: { "@changesets/cli": "^3.0.0" },
|
||||
}),
|
||||
"package-lock.json": "",
|
||||
"node_modules/@changesets/cli/package.json": JSON.stringify({
|
||||
name: "@changesets/cli",
|
||||
version: "2.29.7",
|
||||
}),
|
||||
});
|
||||
|
||||
await expect(validateChangesetsCliVersion(fixture.path)).rejects.toThrow(
|
||||
"This version of the Changesets action is designed to work with Changesets CLI v3. Changesets CLI v2 is not supported; use Changesets action v1 instead, which is compatible with CLI v2.",
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user