UNPKG

@scaleway/changesets-renovate

Version:

Automatically create changesets for Renovate and pnpm catalogs

37 lines (36 loc) 1.42 kB
#!/usr/bin/env node import { handleCatalogChanges } from "./handle-catalog.js"; import { handlePackageChanges } from "./handle-packages.js"; import { env } from "node:process"; import { simpleGit } from "simple-git"; async function run() { const branch = await simpleGit().branch(); const branchPrefix = env["BRANCH_PREFIX"] ?? "renovate/"; console.log("Detected branch:", branch); if (!(branch.current.startsWith(branchPrefix) || env["SKIP_BRANCH_CHECK"])) { console.log("Not a renovate branch, skipping"); return; } const diffFiles = (await simpleGit().diffSummary(["--name-only", "HEAD~1"])).files.map((file) => file.file); console.log("Found changed files:", diffFiles); if (diffFiles.find((f) => f.startsWith(".changeset"))) { console.log("Changeset already exists, skipping"); return; } const hasPackageChanges = diffFiles.some((file) => file.includes("package.json")); const hasWorkspaceChanges = diffFiles.some((file) => file.includes("pnpm-workspace.yaml")); if (!(hasPackageChanges || hasWorkspaceChanges)) { console.log("No relevant changes detected, skipping"); return; } if (hasWorkspaceChanges) { console.log("📚 Processing pnpm workspace catalog changes..."); await handleCatalogChanges(diffFiles); } if (hasPackageChanges) { console.log("📦 Processing package.json changes..."); await handlePackageChanges(diffFiles); } } run().catch(console.error); export { run };