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:
Mateusz Burzyński
2026-07-23 09:34:32 +00:00
committed by GitHub
parent 84d78c68f9
commit 5b307d3df2
9 changed files with 143 additions and 23 deletions
+7 -5
View File
@@ -4,7 +4,7 @@ import path from "node:path";
import artifact from "@actions/artifact";
import * as core from "@actions/core";
import readChangesetState from "../readChangesetState.ts";
import { execChangesetsCli } from "../utils.ts";
import { execChangesetsCli, validateChangesetsCliVersion } from "../utils.ts";
type ModeResult =
| {
@@ -27,7 +27,10 @@ try {
}
async function main() {
const result = await getMode();
const cwd = process.cwd();
await validateChangesetsCliVersion(cwd);
const result = await getMode(cwd);
core.setOutput("mode", result.mode);
if (result.mode === "publish") {
const publishPlanArtifact = await artifact.uploadArtifact(
@@ -48,8 +51,8 @@ async function main() {
}
}
async function getMode(): Promise<ModeResult> {
const { changesets } = await readChangesetState();
async function getMode(cwd: string): Promise<ModeResult> {
const { changesets } = await readChangesetState(cwd);
if (changesets.length > 0) {
const hasNonEmptyChangesets = changesets.some(
@@ -61,7 +64,6 @@ async function getMode(): Promise<ModeResult> {
return { mode: "none" };
}
const cwd = process.cwd();
const publishPlanPath = path.join(
process.env.RUNNER_TEMP ?? (await fs.realpath(os.tmpdir())),
`changeset-publish-plan-${Date.now()}`,