import { r as ux } from "./cli-B86kvKcR.mjs";
import { n as runReleaseCheckCommand } from "./check-NyDIOUkU.mjs";
import { i as prepareReleaseSummary, r as isGitWorkingTreeClean, s as syncBlockPackageVersions } from "./release-C3xNWdlR.mjs";
import process from "node:process";
import { defineCommand } from "citty";
import { execa } from "execa";
//#region src/commands/release/prepare.ts
async function runReleasePrepareCommand() {
	try {
		const cwd = process.cwd();
		if (!await isGitWorkingTreeClean(cwd)) throw new Error("Release prepare requires a clean working tree.");
		await runReleaseCheckCommand();
		if (process.exitCode) return;
		await ux.running("Applying changeset versioning", async () => {
			await execa("pnpm", ["changeset", "version"], {
				cwd,
				stdio: "inherit"
			});
		});
		await ux.running("Syncing block package versions", async () => {
			await syncBlockPackageVersions(cwd);
		});
		const prepared = await ux.running("Preparing release summary", async () => prepareReleaseSummary(cwd));
		if (prepared.packageCount > 0) ux.log.success(`Prepared release ${prepared.marker.releaseTitle} for ${prepared.packageCount} package${prepared.packageCount === 1 ? "" : "s"}. Review @state/releases/changelog.md and compose @state/releases/active.md before publish.`);
		else ux.log.success(`Prepared repo-only release ${prepared.marker.releaseTitle}. Compose @state/releases/active.md before publish.`);
	} catch (error) {
		ux.handleError(error);
	}
}
var prepare_default = defineCommand({
	meta: {
		name: "prepare",
		description: "Apply versioning and generate the repo release summary"
	},
	async run() {
		await runReleasePrepareCommand();
		if (!process.exitCode) process.exit(0);
	}
});
//#endregion
export { prepare_default as default };

//# sourceMappingURL=prepare-CUNxdY6b.mjs.map