From e0df7e9d20c6328a3d14be6c736efa9b64f3fc9e Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Fri, 13 May 2022 14:18:50 -0400 Subject: [PATCH 1/2] Change update default to update on quit (#5390) --- src/main/app-updater.ts | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/main/app-updater.ts b/src/main/app-updater.ts index 0b7a5609b8..363575e4d3 100644 --- a/src/main/app-updater.ts +++ b/src/main/app-updater.ts @@ -28,10 +28,9 @@ function handleAutoUpdateBackChannel(event: Electron.IpcMainEvent, ...[arg]: Upd autoUpdater.quitAndInstall(true, true); } else { logger.info(`${AutoUpdateLogPrefix}: User chose to update on quit`); - autoUpdater.autoInstallOnAppQuit = true; } } else { - logger.info(`${AutoUpdateLogPrefix}: User chose not to update`); + logger.info(`${AutoUpdateLogPrefix}: User chose not to update, will update on quit anyway`); } } @@ -44,9 +43,9 @@ autoUpdater.logger = { /** * starts the automatic update checking - * @param interval milliseconds between interval to check on, defaults to 24h + * @param interval milliseconds between interval to check on, defaults to 2h */ -export const startUpdateChecking = once(function (interval = 1000 * 60 * 60 * 24): void { +export const startUpdateChecking = once(function (interval = 1000 * 60 * 60 * 2): void { if (!isAutoUpdateEnabled() || isTestEnv) { return; } @@ -54,26 +53,17 @@ export const startUpdateChecking = once(function (interval = 1000 * 60 * 60 * 24 const userStore = UserStore.getInstance(); autoUpdater.autoDownload = false; - autoUpdater.autoInstallOnAppQuit = false; + autoUpdater.autoInstallOnAppQuit = true; autoUpdater.channel = userStore.updateChannel; autoUpdater.allowDowngrade = userStore.isAllowedToDowngrade; autoUpdater .on("update-available", (info: UpdateInfo) => { - if (autoUpdater.autoInstallOnAppQuit) { - // a previous auto-update loop was completed with YES+LATER, check if same version - if (installVersion === info.version) { - // same version, don't broadcast - return; - } + if (installVersion === info.version) { + // same version, don't broadcast + return; } - /** - * This should be always set to false here because it is the reasonable - * default. Namely, if a don't auto update to a version that the user - * didn't ask for. - */ - autoUpdater.autoInstallOnAppQuit = false; installVersion = info.version; autoUpdater.downloadUpdate() From 381d77c63344cbe985af480442eec6ca928e7a8e Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 13 May 2022 23:14:37 +0300 Subject: [PATCH 2/2] Refactoring extension-app compatibility checks (#5389) --- .../__tests__/is-compatible-extension.test.ts | 119 ++++++------------ 1 file changed, 36 insertions(+), 83 deletions(-) diff --git a/src/extensions/__tests__/is-compatible-extension.test.ts b/src/extensions/__tests__/is-compatible-extension.test.ts index 2580b509dd..b5c731b4b7 100644 --- a/src/extensions/__tests__/is-compatible-extension.test.ts +++ b/src/extensions/__tests__/is-compatible-extension.test.ts @@ -9,108 +9,61 @@ import { } from "../extension-discovery/is-compatible-extension/is-compatible-extension"; import type { LensExtensionManifest } from "../lens-extension"; -describe("Extension/App versions compatibility check", () => { +describe("Extension/App versions compatibility checks", () => { it("is compatible with exact version matching", () => { - expect(isCompatibleExtension({ - appSemVer: semver.coerce("5.5.0"), - })(getExtensionManifestMock({ - lensEngine: "5.5.0", - }))).toBeTruthy(); + expect(isCompatible({ extLensEngineVersion: "5.5.0", appVersion: "5.5.0" })).toBeTruthy(); }); it("is compatible with upper %PATCH versions of base app", () => { - expect(isCompatibleExtension({ - appSemVer: semver.coerce("5.5.5"), - })(getExtensionManifestMock({ - lensEngine: "5.5.0", - }))).toBeTruthy(); + expect(isCompatible({ extLensEngineVersion: "5.5.0", appVersion: "5.5.5" })).toBeTruthy(); }); - it("is compatible with upper %MINOR version of base app", () => { - expect(isCompatibleExtension({ - appSemVer: semver.coerce("5.6.0"), - })(getExtensionManifestMock({ - lensEngine: "5.5.0", - }))).toBeTruthy(); - - expect(isCompatibleExtension({ - appSemVer: semver.coerce("5.5.0-alpha.0"), - })(getExtensionManifestMock({ - lensEngine: "^5.5.0", - }))).toBeTruthy(); - - expect(isCompatibleExtension({ - appSemVer: semver.coerce("5.5"), - })(getExtensionManifestMock({ - lensEngine: "^5.6.0", - }))).toBeFalsy(); + it("is compatible with higher %MINOR version of base app", () => { + expect(isCompatible({ extLensEngineVersion: "5.5.0", appVersion: "5.6.0" })).toBeTruthy(); }); - it("is not compatible with upper %MAJOR version of base app", () => { - expect(isCompatibleExtension({ - appSemVer: semver.coerce("5.5.0"), // current lens-version - })(getExtensionManifestMock({ - lensEngine: "6.0.0", - }))).toBeFalsy(); // extension with lens@6.0 is not compatible with app@5.5 - - expect(isCompatibleExtension({ - appSemVer: semver.coerce("6.0.0"), // current lens-version - })(getExtensionManifestMock({ - lensEngine: "5.5.0", - }))).toBeFalsy(); // extension with lens@5.5 is not compatible with app@6.0 + it("is not compatible with higher %MAJOR version of base app", () => { + expect(isCompatible({ extLensEngineVersion: "5.6.0", appVersion: "6.0.0" })).toBeFalsy(); // extension for lens@5 not compatible with lens@6 + expect(isCompatible({ extLensEngineVersion: "6.0.0", appVersion: "5.6.0" })).toBeFalsy(); }); it("is compatible with lensEngine with prerelease", () => { - expect(isCompatibleExtension({ - appSemVer: semver.parse("5.5.0-alpha.0"), - })(getExtensionManifestMock({ - lensEngine: "^5.4.0-alpha.0", - }))).toBeTruthy(); + expect(isCompatible({ + extLensEngineVersion: "^5.4.0-alpha.0", + appVersion: "5.5.0-alpha.0", + })).toBeTruthy(); }); - describe("supported formats for manifest.engines.lens", () => { - it("short version format for engines.lens", () => { - expect(isCompatibleExtension({ - appSemVer: semver.coerce("5.5.0"), - })(getExtensionManifestMock({ - lensEngine: "5.5", - }))).toBeTruthy(); - }); + it("supports short version format for manifest.engines.lens", () => { + expect(isCompatible({ extLensEngineVersion: "5.5", appVersion: "5.5.1" })).toBeTruthy(); + }); - it("validates version and throws if incorrect format", () => { - expect(() => isCompatibleExtension({ - appSemVer: semver.coerce("1.0.0"), - })(getExtensionManifestMock({ - lensEngine: "1.0", - }))).not.toThrow(); + it("throws for incorrect or not supported version format", () => { + expect(() => isCompatible({ + extLensEngineVersion: ">=2.0", + appVersion: "2.0", + })).toThrow(/Invalid format/i); - expect(() => isCompatibleExtension({ - appSemVer: semver.coerce("1.0.0"), - })(getExtensionManifestMock({ - lensEngine: "^1.0", - }))).not.toThrow(); + expect(() => isCompatible({ + extLensEngineVersion: "~2.0", + appVersion: "2.0", + })).toThrow(/Invalid format/i); - expect(() => isCompatibleExtension({ - appSemVer: semver.coerce("1.0.0"), - })(getExtensionManifestMock({ - lensEngine: ">=2.0", - }))).toThrow(/Invalid format/i); - }); - - it("'*' cannot be used for any version matching (at least in the prefix)", () => { - expect(() => isCompatibleExtension({ - appSemVer: semver.coerce("1.0.0"), - })(getExtensionManifestMock({ - lensEngine: "*", - }))).toThrowError(/Invalid format/i); - }); + expect(() => isCompatible({ + extLensEngineVersion: "*", + appVersion: "1.0", + })).toThrow(/Invalid format/i); }); }); -function getExtensionManifestMock( - { - lensEngine = "1.0", - } = {}): LensExtensionManifest { +function isCompatible({ extLensEngineVersion = "^1.0", appVersion = "1.0" } = {}): boolean { + const appSemVer = semver.coerce(appVersion); + const extensionManifestMock = getExtensionManifestMock(extLensEngineVersion); + + return isCompatibleExtension({ appSemVer })(extensionManifestMock); +} + +function getExtensionManifestMock(lensEngine = "1.0"): LensExtensionManifest { return { name: "some-extension", version: "1.0",