diff --git a/electron-builder.yml b/electron-builder.yml index cba19e4e..21442ce5 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -2,6 +2,8 @@ directories: output: dist buildResources: buildResources +artifactName: '${productName}.${ext}' + files: - packages/**/dist/** diff --git a/packages/main/src/backend/import/downloadChromium.ts b/packages/main/src/backend/import/downloadChromium.ts index 51d409b1..0fd8eed4 100644 --- a/packages/main/src/backend/import/downloadChromium.ts +++ b/packages/main/src/backend/import/downloadChromium.ts @@ -1,10 +1,13 @@ -import { Browser, install } from '@puppeteer/browsers'; +import { Browser, detectBrowserPlatform, install, resolveBuildId } from '@puppeteer/browsers'; +import os from 'os'; import logger from '/@/logging/logger'; type PuppeteerProgressCallback = (downloadBytes: number, totalBytes: number) => void; type PercentCallback = (percent: number) => void; +let isCached = true; const getIntegerPercent = (callback: PercentCallback): PuppeteerProgressCallback => { + isCached = false; let prevPercent = -1; return (downloadBytes: number, totalBytes: number) => { @@ -16,8 +19,6 @@ const getIntegerPercent = (callback: PercentCallback): PuppeteerProgressCallback }; }; -const revision = '1364960'; // getPuppeteerConfig().chromiumRevision; see https://github.com/puppeteer/puppeteer/issues/8203#issuecomment-1535088987 - let downloadProm: ReturnType | null = null; export default async function downloadChromium(installPath: string, onProgress?: PercentCallback): Promise { @@ -25,14 +26,27 @@ export default async function downloadChromium(installPath: string, onProgress?: const progressCallback = onProgress && getIntegerPercent(onProgress); + const platform = detectBrowserPlatform(); + if (!platform) { + throw new Error(`Cannot download a binary for the provided platform: ${os.platform()} (${os.arch()})`); + } + const buildId = await resolveBuildId(Browser.CHROMIUM, platform, 'latest'); + + logger.log(`Browser: ${Browser.CHROMIUM}, Platform: ${platform}, Tag: stable, BuildId: ${buildId}`); + downloadProm = install({ cacheDir: installPath, browser: Browser.CHROMIUM, - buildId: revision, + buildId, downloadProgressCallback: progressCallback, }).then(({ executablePath }) => { downloadProm = null; - logger.log('Chromium downloaded to', executablePath); + if (!isCached) { + logger.log('Chromium downloaded to', executablePath); + } else { + logger.log('Chromium cached at', executablePath); + } + isCached = true; return executablePath; }); diff --git a/packages/main/src/backend/import/importTransactions.ts b/packages/main/src/backend/import/importTransactions.ts index e0f067b5..e0b6c5e5 100644 --- a/packages/main/src/backend/import/importTransactions.ts +++ b/packages/main/src/backend/import/importTransactions.ts @@ -36,13 +36,13 @@ export async function scrapeFinancialAccountsAndFetchTransactions( ) { let chromiumPath: string; - console.log('Scraping financial accounts and fetching transactions'); + logger.log('Scraping financial accounts and fetching transactions'); if (scrapingConfig.chromiumPath) { - console.log('Using provided chromium path', scrapingConfig.chromiumPath); + logger.log('Using provided chromium path', scrapingConfig.chromiumPath); chromiumPath = scrapingConfig.chromiumPath; } else { - console.log('Downloading chromium'); + logger.log('Downloading chromium'); chromiumPath = await getChrome(userDataPath, (percent) => emitChromeDownload(eventPublisher, percent)); } diff --git a/packages/main/src/handlers/updater.ts b/packages/main/src/handlers/updater.ts index 92e7adcc..cb02950d 100644 --- a/packages/main/src/handlers/updater.ts +++ b/packages/main/src/handlers/updater.ts @@ -26,5 +26,6 @@ export const downloadUpdate = async () => }); export const quitAndInstall = () => { + logger.info('Quitting and installing update'); setImmediate(() => autoUpdater.quitAndInstall()); }; diff --git a/packages/preload/src/eventsBridge.ts b/packages/preload/src/eventsBridge.ts index df9771d5..d11af647 100644 --- a/packages/preload/src/eventsBridge.ts +++ b/packages/preload/src/eventsBridge.ts @@ -74,6 +74,7 @@ export async function showSaveDialog() { } export async function quitAndInstall() { + console.log('preload invoking quitAndInstall'); return electron.ipcRenderer.invoke('quitAndInstall'); }