#!/usr/bin/env node const fs = require("fs"); const path = require("path"); const { execSync } = require("child_process"); /** * 릴리즈 버전 업데이트 스크립트 * Semantic Release에 의해 package.json이 업데이트된 후 실행됩니다. */ const projectRoot = path.join(__dirname, ".."); // Semantic Release가 업데이트한 package.json에서 새 버전 읽기 const packageJsonPath = path.join(projectRoot, "package.json"); const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8")); const newVersion = packageJson.version; console.log(`🚀 Post-release version sync for ${newVersion}...`); // 버전을 숫자로 변환 (예: "1.2.3" -> 10203) function versionToCode(version) { const parts = version.split(".").map(Number); return parts[0] * 10000 + parts[1] * 100 + parts[2]; } const versionCode = versionToCode(newVersion); // 모바일 플랫폼 버전 동기화 try { console.log("🔄 Running version sync..."); execSync("npm run version:sync", { stdio: "inherit", cwd: projectRoot }); console.log("📱 Running mobile sync..."); execSync("npm run mobile:sync", { stdio: "inherit", cwd: projectRoot }); console.log("✅ Release version sync completed successfully!"); console.log(`📦 Released Version: ${newVersion}`); console.log(`🔢 Build Code: ${versionCode}`); } catch (error) { console.error("❌ Release version sync failed:", error.message); process.exit(1); }