2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-11-11 15:51:06 +00:00

Old build detection: bump to 90 days, let packagers customize message

This commit is contained in:
Ronan Jouchet 2021-04-11 20:40:41 -04:00
parent d0ab749bd6
commit da06d933df
2 changed files with 11 additions and 3 deletions

View File

@ -29,7 +29,7 @@ if (require('electron-squirrel-startup')) {
const appArgs = JSON.parse(fs.readFileSync(APP_ARGS_FILE_PATH, 'utf8'));
const OLD_BUILD_WARNING_THRESHOLD_DAYS = 60;
const OLD_BUILD_WARNING_THRESHOLD_DAYS = 90;
const OLD_BUILD_WARNING_THRESHOLD_MS =
OLD_BUILD_WARNING_THRESHOLD_DAYS * 24 * 60 * 60 * 1000;
@ -222,12 +222,14 @@ if (shouldQuit) {
!appArgs.disableOldBuildWarning &&
new Date().getTime() - appArgs.buildDate > OLD_BUILD_WARNING_THRESHOLD_MS
) {
const oldBuildWarningText =
appArgs.oldBuildWarningText ||
'This app was built a long time ago. Nativefier uses the Chrome browser (through Electron), and it is insecure to keep using an old version of it. Please upgrade Nativefier and rebuild this app.';
// eslint-disable-next-line @typescript-eslint/no-floating-promises
dialog.showMessageBox(null, {
type: 'warning',
message: 'Old build detected',
detail:
'This app was built a long time ago. Nativefier uses the Chrome browser (through Electron), and it is insecure to keep using an old version of it. Please upgrade Nativefier and rebuild this app.',
detail: oldBuildWarningText,
});
}
});

View File

@ -69,6 +69,12 @@ function pickElectronAppArgs(options: AppOptions): any {
y: options.nativefier.y,
zoom: options.nativefier.zoom,
buildDate: new Date().getTime(),
// OLD_BUILD_WARNING_TEXT is an undocumented env. var to let *packagers*
// tweak the message shown on warning about an old build, to something
// more tailored to their audience (who might not even know Nativefier).
// See https://github.com/kelyvin/Google-Messages-For-Desktop/issues/34#issuecomment-812731144
// and https://github.com/nativefier/nativefier/issues/1131#issuecomment-812646988
oldBuildWarningText: process.env.OLD_BUILD_WARNING_TEXT || '',
};
}