fix: Mac desktop updater — platform-aware errors, HTTPS latest.json
Show Mac-specific update errors on macOS (not Windows message). Force HTTPS bundle URLs, fix reconcile version from bundle filenames, bump to 0.1.4. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@goldenchart/desktop",
|
"name": "@goldenchart/desktop",
|
||||||
"version": "0.1.3",
|
"version": "0.1.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "GoldenChart",
|
"productName": "GoldenChart",
|
||||||
"version": "0.1.3",
|
"version": "0.1.4",
|
||||||
"identifier": "com.goldenchart.desktop",
|
"identifier": "com.goldenchart.desktop",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "npm run dev",
|
"beforeDevCommand": "npm run dev",
|
||||||
|
|||||||
@@ -33,33 +33,76 @@ function emit(onProgress: ((p: DesktopUpdateProgress) => void) | undefined, p: D
|
|||||||
onProgress?.(p);
|
onProgress?.(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatUpdateError(e: unknown): string {
|
function isMacOs(): boolean {
|
||||||
|
if (typeof navigator !== 'undefined' && /mac/i.test(navigator.userAgent)) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isWindowsOs(): boolean {
|
||||||
|
if (typeof navigator !== 'undefined' && /win/i.test(navigator.userAgent)) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function formatUpdateError(e: unknown): Promise<string> {
|
||||||
const msg = e instanceof Error ? e.message : String(e ?? '');
|
const msg = e instanceof Error ? e.message : String(e ?? '');
|
||||||
const lower = msg.toLowerCase();
|
const lower = msg.toLowerCase();
|
||||||
|
const onMac = isMacOs();
|
||||||
|
const onWin = isWindowsOs();
|
||||||
|
|
||||||
if (!msg.trim()) return '업데이트 확인에 실패했습니다.';
|
if (!msg.trim()) return '업데이트 확인에 실패했습니다.';
|
||||||
if (/could not fetch a valid release json|release not found/.test(lower)) {
|
if (/could not fetch a valid release json|release not found/.test(lower)) {
|
||||||
return '업데이트 서버 응답을 처리하지 못했습니다. 잠시 후 다시 시도하거나 PC 프로그램 탭에서 dmg를 새로 설치해 주세요.';
|
return onMac
|
||||||
|
? '업데이트 서버 응답을 처리하지 못했습니다. PC 프로그램 탭에서 dmg를 새로 설치해 주세요.'
|
||||||
|
: '업데이트 서버 응답을 처리하지 못했습니다. PC 프로그램 탭에서 exe를 새로 설치해 주세요.';
|
||||||
}
|
}
|
||||||
if (/json|parse|unexpected end|eof|empty|deserialize|invalid value for/.test(lower)) {
|
if (/json|parse|unexpected end|eof|empty|deserialize|invalid value for/.test(lower)) {
|
||||||
return '서버 업데이트 정보(latest.json) 형식 오류입니다. PC 프로그램 탭에서 새 dmg를 받아 주세요.';
|
return onMac
|
||||||
|
? '서버 업데이트 정보(latest.json) 형식 오류입니다. PC 프로그램 탭에서 dmg를 받아 주세요.'
|
||||||
|
: '서버 업데이트 정보(latest.json) 형식 오류입니다. PC 프로그램 탭에서 exe를 받아 주세요.';
|
||||||
|
}
|
||||||
|
if (/insecuretransport|insecure transport|http url|https/.test(lower)) {
|
||||||
|
return '업데이트 URL 보안(HTTPS) 설정 오류입니다. 잠시 후 다시 시도해 주세요.';
|
||||||
}
|
}
|
||||||
if (/signature|pubkey|verify|minisign|invalid key/.test(lower)) {
|
if (/signature|pubkey|verify|minisign|invalid key/.test(lower)) {
|
||||||
return '업데이트 서명 검증에 실패했습니다. 웹 PC 프로그램 탭에서 설치 파일을 다시 받아 주세요.';
|
return onMac
|
||||||
|
? '업데이트 서명 검증에 실패했습니다. PC 프로그램 탭에서 dmg를 다시 받아 주세요.'
|
||||||
|
: '업데이트 서명 검증에 실패했습니다. PC 프로그램 탭에서 exe를 다시 받아 주세요.';
|
||||||
}
|
}
|
||||||
if (/invalid symbol|offset \d+|replace_with/.test(lower)) {
|
if (/invalid symbol|offset \d+|replace_with/.test(lower)) {
|
||||||
return '이 버전(v0.1.1 이전/초기 dmg)에는 자동 업데이트 키가 없습니다. 웹 PC 프로그램 탭에서 최신 dmg를 받아 Applications에 다시 설치해 주세요. 이후부터는 자동 업데이트가 됩니다.';
|
return '이 버전(v0.1.1 이전/초기 dmg)에는 자동 업데이트 키가 없습니다. 웹 PC 프로그램 탭에서 최신 dmg를 받아 Applications에 다시 설치해 주세요. 이후부터는 자동 업데이트가 됩니다.';
|
||||||
}
|
}
|
||||||
if (/404|not found/.test(lower)) {
|
if (/404|not found/.test(lower)) {
|
||||||
return '업데이트 파일을 찾을 수 없습니다. 관리자에게 문의하거나 dmg를 직접 다운로드해 주세요.';
|
return onMac
|
||||||
|
? 'Mac용 업데이트 파일을 찾을 수 없습니다. PC 프로그램 탭에서 dmg를 직접 다운로드해 주세요.'
|
||||||
|
: 'Windows용 업데이트 파일을 찾을 수 없습니다. PC 프로그램 탭에서 exe를 직접 다운로드해 주세요.';
|
||||||
}
|
}
|
||||||
if (/network|fetch|connect|timeout|dns|offline|failed to send/.test(lower)) {
|
if (/network|fetch|connect|timeout|dns|offline|failed to send/.test(lower)) {
|
||||||
return `네트워크 오류로 업데이트를 확인하지 못했습니다. (${msg})`;
|
return `네트워크 오류로 업데이트를 확인하지 못했습니다. (${msg})`;
|
||||||
}
|
}
|
||||||
if (/fallback platforms|platforms object|windows-x86_64/.test(lower)) {
|
if (/darwin-x86_64|x86_64.*darwin|intel mac/.test(lower) && onMac) {
|
||||||
return 'Windows용 업데이트 패키지가 서버에 없습니다. 웹 PC 프로그램 탭에서 exe 설치 파일을 받아 다시 설치해 주세요.';
|
return 'Intel Mac용 업데이트 패키지(darwin-x86_64)가 서버에 없습니다. PC 프로그램 탭에서 dmg를 받아 다시 설치해 주세요.';
|
||||||
|
}
|
||||||
|
if (/darwin-aarch64|aarch64.*darwin/.test(lower) && onMac) {
|
||||||
|
return 'Apple Silicon Mac용 업데이트 패키지(darwin-aarch64)가 서버에 없습니다. PC 프로그램 탭에서 dmg를 받아 다시 설치해 주세요.';
|
||||||
|
}
|
||||||
|
if (/windows-x86_64/.test(lower) && onWin) {
|
||||||
|
return 'Windows용 업데이트 패키지가 서버에 없습니다. PC 프로그램 탭에서 exe 설치 파일을 받아 다시 설치해 주세요.';
|
||||||
|
}
|
||||||
|
if (/fallback platforms|platforms object|platform.*not found|missing platform/.test(lower)) {
|
||||||
|
if (onMac) {
|
||||||
|
const hint = /darwin-x86_64|x86_64/.test(lower)
|
||||||
|
? 'Intel Mac(darwin-x86_64)'
|
||||||
|
: 'Apple Silicon Mac(darwin-aarch64)';
|
||||||
|
return `Mac용 업데이트 패키지가 서버에 없습니다 (${hint}). PC 프로그램 탭에서 dmg를 받아 다시 설치해 주세요.`;
|
||||||
|
}
|
||||||
|
if (onWin) {
|
||||||
|
return 'Windows용 업데이트 패키지가 서버에 없습니다. PC 프로그램 탭에서 exe 설치 파일을 받아 다시 설치해 주세요.';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (/platform|darwin|arch|target/.test(lower)) {
|
if (/platform|darwin|arch|target/.test(lower)) {
|
||||||
return `이 PC용 업데이트 패키지가 없습니다. 웹 PC 프로그램 탭에서 설치 파일을 다시 받아 주세요.`;
|
return onMac
|
||||||
|
? 'Mac용 업데이트 패키지가 없습니다. PC 프로그램 탭에서 dmg를 받아 다시 설치해 주세요.'
|
||||||
|
: '이 PC용 업데이트 패키지가 없습니다. PC 프로그램 탭에서 설치 파일을 다시 받아 주세요.';
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
@@ -86,7 +129,7 @@ export async function checkForUpdates(): Promise<{
|
|||||||
message: `새 버전 v${update.version}을(를) 사용할 수 있습니다. (현재 v${currentVersion})`,
|
message: `새 버전 v${update.version}을(를) 사용할 수 있습니다. (현재 v${currentVersion})`,
|
||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return { available: false, message: formatUpdateError(e) };
|
return { available: false, message: await formatUpdateError(e) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +235,7 @@ export async function runDesktopUpdate(
|
|||||||
newVersion: update.version,
|
newVersion: update.version,
|
||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const message = formatUpdateError(e);
|
const message = await formatUpdateError(e);
|
||||||
emit(onProgress, { phase: 'error', message, currentVersion });
|
emit(onProgress, { phase: 'error', message, currentVersion });
|
||||||
return { ok: false, phase: 'error', message, currentVersion };
|
return { ok: false, phase: 'error', message, currentVersion };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ function arg(name, fallback) {
|
|||||||
|
|
||||||
const version = arg('--version', '0.1.0');
|
const version = arg('--version', '0.1.0');
|
||||||
const dir = path.resolve(arg('--dir', 'dist-desktop/updates'));
|
const dir = path.resolve(arg('--dir', 'dist-desktop/updates'));
|
||||||
const baseUrl = (arg('--base-url', 'https://exdev.co.kr/desktop/updates')).replace(/\/$/, '');
|
const rawBaseUrl = arg('--base-url', 'https://exdev.co.kr/desktop/updates');
|
||||||
|
const baseUrl = rawBaseUrl.replace(/\/$/, '').replace(/^http:\/\//i, 'https://');
|
||||||
const notes = arg('--notes', `GoldenChart Desktop ${version}`);
|
const notes = arg('--notes', `GoldenChart Desktop ${version}`);
|
||||||
|
|
||||||
if (!fs.existsSync(dir)) {
|
if (!fs.existsSync(dir)) {
|
||||||
@@ -82,13 +83,18 @@ for (const f of files) {
|
|||||||
} else if (lower.endsWith('-setup.exe') || (lower.includes('setup') && lower.endsWith('.exe'))) {
|
} else if (lower.endsWith('-setup.exe') || (lower.includes('setup') && lower.endsWith('.exe'))) {
|
||||||
addPlatform('windows-x86_64', f);
|
addPlatform('windows-x86_64', f);
|
||||||
} else if (lower.endsWith('.app.tar.gz')) {
|
} else if (lower.endsWith('.app.tar.gz')) {
|
||||||
// universal mac fallback
|
addPlatform('darwin-aarch64', f);
|
||||||
if (!platforms['darwin-aarch64']) addPlatform('darwin-aarch64', f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bundleMaxVersion = Object.values(platforms).reduce(
|
||||||
|
(max, p) => (cmpSemver(p.bundleVersion, max) > 0 ? p.bundleVersion : max),
|
||||||
|
'0.0.0',
|
||||||
|
);
|
||||||
|
const manifestVersion = cmpSemver(bundleMaxVersion, version) > 0 ? bundleMaxVersion : version;
|
||||||
|
|
||||||
const manifest = {
|
const manifest = {
|
||||||
version,
|
version: manifestVersion,
|
||||||
notes,
|
notes,
|
||||||
pub_date: new Date().toISOString(),
|
pub_date: new Date().toISOString(),
|
||||||
platforms: Object.fromEntries(
|
platforms: Object.fromEntries(
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ UPDATES_SRC="${UPDATES_SRC:-$ARTIFACT_DIR/updates}"
|
|||||||
UPDATES_DIR="${UPDATES_DIR:-${WORK_TREE:-$ROOT}/frontend/public/desktop/updates}"
|
UPDATES_DIR="${UPDATES_DIR:-${WORK_TREE:-$ROOT}/frontend/public/desktop/updates}"
|
||||||
WEB_STATIC_DIR="${WEB_STATIC_DIR:-$UPDATES_DIR}"
|
WEB_STATIC_DIR="${WEB_STATIC_DIR:-$UPDATES_DIR}"
|
||||||
BASE_URL="${DESKTOP_UPDATE_BASE_URL:-https://exdev.co.kr/desktop/updates}"
|
BASE_URL="${DESKTOP_UPDATE_BASE_URL:-https://exdev.co.kr/desktop/updates}"
|
||||||
|
BASE_URL="${BASE_URL/http:\/\//https:\/\/}"
|
||||||
DESKTOP_RELEASE_DIR="${GC_DESKTOP_APP_RELEASE_DIR:-$ROOT/data/desktop-releases}"
|
DESKTOP_RELEASE_DIR="${GC_DESKTOP_APP_RELEASE_DIR:-$ROOT/data/desktop-releases}"
|
||||||
KEY_PATH="${TAURI_SIGNER_KEY:-$HOME/.tauri/goldenchart.key}"
|
KEY_PATH="${TAURI_SIGNER_KEY:-$HOME/.tauri/goldenchart.key}"
|
||||||
DESKTOP_DIR="$ROOT/desktop"
|
DESKTOP_DIR="$ROOT/desktop"
|
||||||
@@ -64,6 +65,11 @@ fi
|
|||||||
# build-info 복사
|
# build-info 복사
|
||||||
if [[ -f "$BUILD_INFO" ]]; then
|
if [[ -f "$BUILD_INFO" ]]; then
|
||||||
cp -f "$BUILD_INFO" "$PUBLISH_UPDATES/build-info.json"
|
cp -f "$BUILD_INFO" "$PUBLISH_UPDATES/build-info.json"
|
||||||
|
node -e "
|
||||||
|
const fs=require('fs'); const p=process.argv[1]; const v=process.argv[2];
|
||||||
|
const j=JSON.parse(fs.readFileSync(p,'utf8')); j.version=v;
|
||||||
|
fs.writeFileSync(p, JSON.stringify(j,null,2)+'\n');
|
||||||
|
" "$PUBLISH_UPDATES/build-info.json" "$VERSION"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# latest.json
|
# latest.json
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH:-/usr/bin:/bin}"
|
|||||||
UPDATES_DIR="${UPDATES_DIR:-${WORK_TREE:-$ROOT}/frontend/public/desktop/updates}"
|
UPDATES_DIR="${UPDATES_DIR:-${WORK_TREE:-$ROOT}/frontend/public/desktop/updates}"
|
||||||
CONF="$ROOT/desktop/src-tauri/tauri.conf.json"
|
CONF="$ROOT/desktop/src-tauri/tauri.conf.json"
|
||||||
BASE_URL="${DESKTOP_UPDATE_BASE_URL:-https://exdev.co.kr/desktop/updates}"
|
BASE_URL="${DESKTOP_UPDATE_BASE_URL:-https://exdev.co.kr/desktop/updates}"
|
||||||
|
BASE_URL="${BASE_URL/http:\/\//https:\/\/}"
|
||||||
|
|
||||||
if [[ ! -d "$UPDATES_DIR" ]]; then
|
if [[ ! -d "$UPDATES_DIR" ]]; then
|
||||||
echo "[reconcile-latest] skip — no $UPDATES_DIR"
|
echo "[reconcile-latest] skip — no $UPDATES_DIR"
|
||||||
@@ -16,45 +17,38 @@ 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"
|
||||||
BUILD_INFO="$UPDATES_DIR/build-info.json"
|
BUILD_INFO="$UPDATES_DIR/build-info.json"
|
||||||
if [[ -f "$BUILD_INFO" ]]; then
|
|
||||||
BI_VER="$(node -p "require('$BUILD_INFO').version || ''" 2>/dev/null || true)"
|
# bundle 파일명·build-info·기존 manifest 중 최고 버전 사용 (build-info stale 방지)
|
||||||
if [[ -n "$BI_VER" ]]; then
|
VERSION="$(node <<NODE
|
||||||
VERSION="$(node <<NODE
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
const cmp = (a, b) => {
|
const cmp = (a, b) => {
|
||||||
const pa = a.split('.').map(Number), pb = b.split('.').map(Number);
|
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) return d; }
|
for (let i = 0; i < 3; i++) { const d = (pa[i]||0)-(pb[i]||0); if (d) return d; }
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
console.log(cmp('$BI_VER', '$VERSION') > 0 ? '$BI_VER' : '$VERSION');
|
const maxV = (a, b) => (cmp(a, b) >= 0 ? a : b);
|
||||||
NODE
|
let version = '$VERSION';
|
||||||
)"
|
const dir = '$UPDATES_DIR';
|
||||||
fi
|
try {
|
||||||
fi
|
const bi = JSON.parse(fs.readFileSync('$BUILD_INFO', 'utf8'));
|
||||||
if [[ -f "$LATEST_JSON" ]]; then
|
if (bi.version) version = maxV(version, bi.version);
|
||||||
EXISTING="$(node <<NODE
|
} catch {}
|
||||||
const fs = require('fs');
|
|
||||||
const confV = '$VERSION';
|
|
||||||
let existing = '0.0.0';
|
|
||||||
let hasPlatforms = false;
|
|
||||||
try {
|
try {
|
||||||
const j = JSON.parse(fs.readFileSync('$LATEST_JSON', 'utf8'));
|
const j = JSON.parse(fs.readFileSync('$LATEST_JSON', 'utf8'));
|
||||||
existing = j.version || '0.0.0';
|
if (j.version && j.platforms && Object.keys(j.platforms).length > 0) {
|
||||||
hasPlatforms = j.platforms && Object.keys(j.platforms).length > 0;
|
version = maxV(version, j.version);
|
||||||
} catch {}
|
|
||||||
if (!hasPlatforms) { console.log(confV); process.exit(0); }
|
|
||||||
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;
|
} catch {}
|
||||||
};
|
try {
|
||||||
console.log(cmp(existing, confV) > 0 ? existing : confV);
|
for (const f of fs.readdirSync(dir)) {
|
||||||
|
const m = f.match(/(\\d+\\.\\d+\\.\\d+)/);
|
||||||
|
if (m) version = maxV(version, m[1]);
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
console.log(version);
|
||||||
NODE
|
NODE
|
||||||
)"
|
)"
|
||||||
VERSION="$EXISTING"
|
|
||||||
fi
|
|
||||||
NOTES="${DESKTOP_RELEASE_NOTES:-GoldenChart Desktop $VERSION}"
|
NOTES="${DESKTOP_RELEASE_NOTES:-GoldenChart Desktop $VERSION}"
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
|
|||||||
Reference in New Issue
Block a user