fix: reconcile latest.json version compare node script

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Macbook
2026-06-14 11:51:14 +09:00
parent a3fb92f72c
commit 122c84931f
+16 -6
View File
@@ -15,12 +15,22 @@ fi
VERSION="$(node -p "require('$CONF').version" 2>/dev/null || echo '0.1.0')" VERSION="$(node -p "require('$CONF').version" 2>/dev/null || echo '0.1.0')"
LATEST_JSON="$UPDATES_DIR/latest.json" LATEST_JSON="$UPDATES_DIR/latest.json"
if [[ -f "$LATEST_JSON" ]]; then if [[ -f "$LATEST_JSON" ]]; then
EXISTING="$(node -p " EXISTING="$(node <<NODE
const fs=require('fs'); const v=require('$LATEST_JSON').version||'0.0.0'; const fs = require('fs');
const c='$VERSION'.split('.').map(Number); const e=v.split('.').map(Number); const confV = '$VERSION';
for (let i=0;i<3;i++){ if((e[i]||0)>(c[i]||0)){ console.log(v); process.exit(0);} if((e[i]||0)<(c[i]||0)) break;} let existing = '0.0.0';
console.log('$VERSION'); try { existing = JSON.parse(fs.readFileSync('$LATEST_JSON', 'utf8')).version || '0.0.0'; } catch {}
" 2>/dev/null || echo "$VERSION")" const cmp = (a, b) => {
const pa = a.split('.').map(Number), pb = b.split('.').map(Number);
for (let i = 0; i < 3; i++) {
const d = (pa[i] || 0) - (pb[i] || 0);
if (d !== 0) return d;
}
return 0;
};
console.log(cmp(existing, confV) > 0 ? existing : confV);
NODE
)"
VERSION="$EXISTING" VERSION="$EXISTING"
fi fi
NOTES="${DESKTOP_RELEASE_NOTES:-GoldenChart Desktop $VERSION}" NOTES="${DESKTOP_RELEASE_NOTES:-GoldenChart Desktop $VERSION}"