erp-platform/ui/scripts/write-version.js
2025-09-22 21:11:08 +03:00

46 lines
No EOL
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import fs from "fs"
import { execSync } from "child_process"
function safeExec(cmd) {
try {
return execSync(cmd, { stdio: ["pipe", "pipe", "ignore"] }).toString().trim()
} catch {
return null
}
}
// Tüm tag isimlerini al
const rawTags = safeExec("git tag --list --sort=creatordate")
if (!rawTags) {
console.log("> No git tags found, skipping version.json")
process.exit(0)
}
const tags = rawTags
.split("\n")
.filter(Boolean)
.map((tag) => {
const date = safeExec(`git log -1 --format=%ad --date=short ${tag}`)
const messageRaw = safeExec(`git tag -l --format="%(contents)" ${tag}`)
const changeLog = messageRaw
? messageRaw.split("\n").map((s) => s.trim()).filter(Boolean)
: []
return {
version: tag.replace(/^v/, ""), // v1.0.5 → 1.0.5
buildDate: date,
changeLog
}
})
const commit = safeExec("git rev-parse --short HEAD")
const versionInfo = {
commit,
releases: tags.reverse()
}
fs.writeFileSync("public/version.json", JSON.stringify(versionInfo, null, 2))
console.log("> version.json yazıldı:", versionInfo)