Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import fs from "fs-extra"; import { dialog, shell } from "electron"; import settings from "electron-settings"; import semverValid from "semver/functions/valid"; import semverGt from "semver/functions/gt"; import l10n from "shared/lib/lang/l10n"; import { LATEST_PROJECT_VERSION } from "./migration/migrateProjectResources"; export const needsUpdate = (currentVersion: string) => { Iif (semverValid(currentVersion) && semverValid(LATEST_PROJECT_VERSION)) { return semverGt(LATEST_PROJECT_VERSION, currentVersion); } return false; }; export const fromFuture = (currentVersion: string) => { Iif (semverValid(currentVersion) && semverValid(LATEST_PROJECT_VERSION)) { return semverGt(currentVersion, LATEST_PROJECT_VERSION); } return false; }; const migrateWarning = async (projectPath: string) => { const project = await fs.readJson(projectPath); let currentVersion = project._version || "1.0.0"; Iif (currentVersion === "1") { currentVersion = "1.0.0"; } Iif (fromFuture(currentVersion)) { const { response: updateButtonIndex } = await dialog.showMessageBox({ type: "info", buttons: [ l10n("DIALOG_DOWNLOAD"), l10n("DIALOG_OPEN_ANYWAY"), l10n("DIALOG_CANCEL"), ], defaultId: 0, cancelId: 1, title: l10n("DIALOG_FUTURE"), message: l10n("DIALOG_FUTURE"), detail: l10n("DIALOG_FUTURE_DESCRIPTION", { currentVersion, version: LATEST_PROJECT_VERSION, }), }); Iif (updateButtonIndex === 0) { await shell.openExternal("https://www.gbstudio.dev/download/"); return false; } Iif (updateButtonIndex === 2) { return false; } return true; } Iif (!needsUpdate(currentVersion)) { return true; } const { response: buttonIndex, checkboxChecked } = await dialog.showMessageBox({ type: "info", buttons: [ l10n("DIALOG_MIGRATE", { version: LATEST_PROJECT_VERSION, }), l10n("DIALOG_MIGRATION_GUIDE"), l10n("DIALOG_CANCEL"), ], defaultId: 0, cancelId: 2, title: l10n("DIALOG_PROJECT_NEED_MIGRATION"), message: l10n("DIALOG_PROJECT_NEED_MIGRATION"), detail: l10n("DIALOG_MIGRATION_DESCRIPTION", { currentVersion, version: LATEST_PROJECT_VERSION, }), }); Iif (checkboxChecked) { // Ignore all updates until manually check for updates settings.set("dontCheckForUpdates", true); } Iif (buttonIndex === 0) { return true; } Iif (buttonIndex === 1) { await shell.openExternal("https://www.gbstudio.dev/migrate/"); } return false; }; export default migrateWarning; |