#!/usr/bin/env node const { execSync } = require("child_process"); const fs = require("fs"); const path = require("path"); /** * 릴리즈 시스템 테스트 스크립트 * Semantic Release 동작을 시뮬레이션합니다. */ console.log("🧪 Testing release system...\n"); const projectRoot = path.join(__dirname, ".."); try { // 1. Git 상태 확인 console.log("1️⃣ Checking git status..."); const gitStatus = execSync("git status --porcelain", { cwd: projectRoot, encoding: "utf8", }); if (gitStatus.trim()) { console.log("⚠️ Warning: Working directory has uncommitted changes"); console.log(gitStatus); } else { console.log("✅ Working directory is clean"); } // 2. 현재 버전 확인 console.log("\n2️⃣ Checking current version..."); const packageJson = JSON.parse( fs.readFileSync(path.join(projectRoot, "package.json"), "utf8") ); console.log(`📦 Current version: ${packageJson.version}`); // 3. 커밋 메시지 분석 console.log("\n3️⃣ Analyzing recent commits..."); const commits = execSync('git log --oneline --since="1 day ago"', { cwd: projectRoot, encoding: "utf8", }); if (commits.trim()) { console.log("Recent commits:"); console.log(commits); } else { console.log("📝 No recent commits found"); } // 4. Semantic Release 드라이런 console.log("\n4️⃣ Running semantic-release dry run..."); try { const dryRunOutput = execSync("npx semantic-release --dry-run", { cwd: projectRoot, encoding: "utf8", env: { ...process.env, GITHUB_TOKEN: "dummy" }, }); console.log("🎯 Semantic release analysis:"); console.log(dryRunOutput); } catch (error) { console.log("ℹ️ Semantic release dry run output:"); console.log(error.stdout || error.message); } // 5. 버전 동기화 테스트 console.log("\n5️⃣ Testing version synchronization..."); execSync("npm run version:check", { stdio: "inherit", cwd: projectRoot }); // 6. 빌드 테스트 console.log("\n6️⃣ Testing build process..."); execSync("npm run build:prod", { stdio: "inherit", cwd: projectRoot }); console.log("✅ Build completed successfully"); console.log("\n🎉 Release system test completed successfully!"); console.log("\n📋 Test Summary:"); console.log("- Git status: ✅"); console.log("- Version consistency: ✅"); console.log("- Semantic release: ✅"); console.log("- Build process: ✅"); } catch (error) { console.error("\n❌ Test failed:", error.message); process.exit(1); }