Files
at-mintel/scripts/sync-versions.ts
Marc Mintel cc3ec8f0c2
Some checks failed
Code Quality / lint-and-build (push) Has been cancelled
Release Packages / release (push) Has been cancelled
feat: extract Directus sync/branding and optimize Gitea CI with Next.js lint support
2026-02-03 01:28:36 +01:00

53 lines
1.5 KiB
TypeScript

import * as fs from "fs";
import * as path from "path";
const tag = process.env.GITHUB_REF_NAME || process.env.TAG;
if (!tag || !tag.startsWith("v")) {
console.error("❌ No valid tag found (must start with v, e.g., v1.0.0)");
process.exit(1);
}
const version = tag.replace(/^v/, "");
console.log(`🚀 Syncing all packages to version: ${version}`);
const rootPkg = JSON.parse(fs.readFileSync("package.json", "utf-8"));
const packagesDir = "packages";
const appsDir = "apps";
function updatePkg(pkgPath: string) {
if (!fs.existsSync(pkgPath)) return;
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
pkg.version = version;
// Also update workspace dependencies if they match our packages
if (pkg.dependencies) {
for (const dep in pkg.dependencies) {
if (pkg.dependencies[dep].startsWith("workspace:")) {
pkg.dependencies[dep] = "workspace:*"; // Keep workspace protocol
}
}
}
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
console.log(`✅ Updated ${pkg.name} to ${version}`);
}
// Update root
rootPkg.version = version;
fs.writeFileSync("package.json", JSON.stringify(rootPkg, null, 2) + "\n");
// Update all packages
const packages = fs.readdirSync(packagesDir);
for (const p of packages) {
updatePkg(path.join(packagesDir, p, "package.json"));
}
// Update all apps
const apps = fs.readdirSync(appsDir);
for (const a of apps) {
updatePkg(path.join(appsDir, a, "package.json"));
}
console.log("✨ All versions synced!");