#!/usr/bin/env bash # published latest.json·설치 파일·tauri.conf 중 최대 버전 +1 patch → tauri.conf.json set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" WORK_TREE="${WORK_TREE:-$ROOT}" CONF="${WORK_TREE}/desktop/src-tauri/tauri.conf.json" LATEST="${WORK_TREE}/frontend/public/desktop/updates/latest.json" UPDATES_DIR="${WORK_TREE}/frontend/public/desktop/updates" BUILD_INFO="${WORK_TREE}/dist-desktop/build-info.json" node -e " const fs = require('fs'); const path = require('path'); const confPath = process.argv[1]; const latestPath = process.argv[2]; const updatesDir = process.argv[3]; const buildInfoPath = process.argv[4]; const parse = v => String(v || '0.0.0').trim().replace(/^v/i, '').split('.').map(n => parseInt(n, 10) || 0); const cmp = (a, b) => { const pa = parse(a), pb = parse(b); const len = Math.max(pa.length, pb.length, 3); for (let i = 0; i < len; i++) { const d = (pa[i] || 0) - (pb[i] || 0); if (d) return d; } return 0; }; const maxVer = (cur, next) => (cmp(next, cur) > 0 ? next : cur); const conf = JSON.parse(fs.readFileSync(confPath, 'utf8')); let base = conf.version || '0.1.0'; if (fs.existsSync(latestPath)) { try { const pub = JSON.parse(fs.readFileSync(latestPath, 'utf8')); if (pub.version) base = maxVer(base, pub.version); } catch { /* ignore */ } } if (fs.existsSync(buildInfoPath)) { try { const bi = JSON.parse(fs.readFileSync(buildInfoPath, 'utf8')); if (bi.version) base = maxVer(base, bi.version); } catch { /* ignore */ } } if (fs.existsSync(updatesDir)) { for (const name of fs.readdirSync(updatesDir)) { const m = name.match(/[_-](\\d+\\.\\d+\\.\\d+)[_-]/); if (m) base = maxVer(base, m[1]); const m2 = name.match(/GoldenChart_(\\d+\\.\\d+\\.\\d+)/); if (m2) base = maxVer(base, m2[1]); } } const parts = parse(base); while (parts.length < 3) parts.push(0); parts[2] += 1; const nv = parts.join('.'); conf.version = nv; fs.writeFileSync(confPath, JSON.stringify(conf, null, 2) + '\n'); console.log(nv); " "$CONF" "$LATEST" "$UPDATES_DIR" "$BUILD_INFO"