diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 91702d104b..0000000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..7d144ecc92 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = crlf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.gitignore b/.gitignore index 30ce193d48..44fb9fb1ff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,241 @@ -/node_modules/ -/.vs/ -/.vscode/ -/target/ -/logs/ -/dist/ \ No newline at end of file +# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig +# Created by https://www.toptal.com/developers/gitignore/api/windows,visualstudiocode,linux,macos,node +# Edit at https://www.toptal.com/developers/gitignore?templates=windows,visualstudiocode,linux,macos,node + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +### Node Patch ### +# Serverless Webpack directories +.webpack/ + +# Optional stylelint cache + +# SvelteKit build / generate output +.svelte-kit + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/windows,visualstudiocode,linux,macos,node + +# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option) +dist/ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..d3def91314 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "editor.formatOnSave": false +} diff --git a/app/.DS_Store b/app/.DS_Store deleted file mode 100644 index 15c3523b4b..0000000000 Binary files a/app/.DS_Store and /dev/null differ diff --git a/app/app.ejs b/app/app.ejs index d959558cb4..a73392c7be 100644 --- a/app/app.ejs +++ b/app/app.ejs @@ -7,7 +7,7 @@ - + <%- include('frame') %>
<%- include('welcome') %> @@ -45,4 +45,4 @@
- \ No newline at end of file + diff --git a/app/assets/.DS_Store b/app/assets/.DS_Store deleted file mode 100644 index bff72f3ed8..0000000000 Binary files a/app/assets/.DS_Store and /dev/null differ diff --git a/app/assets/images/.DS_Store b/app/assets/images/.DS_Store deleted file mode 100644 index 849e3c7b95..0000000000 Binary files a/app/assets/images/.DS_Store and /dev/null differ diff --git a/app/assets/images/backgrounds/.DS_Store b/app/assets/images/backgrounds/.DS_Store deleted file mode 100644 index 5008ddfcf5..0000000000 Binary files a/app/assets/images/backgrounds/.DS_Store and /dev/null differ diff --git a/app/assets/js/scripts/settings.js b/app/assets/js/scripts/settings.js index b05571ca99..a188747ba6 100644 --- a/app/assets/js/scripts/settings.js +++ b/app/assets/js/scripts/settings.js @@ -43,7 +43,7 @@ bindSettingsSelect() function bindFileSelectors(){ for(let ele of document.getElementsByClassName('settingsFileSelButton')){ - + ele.onclick = async e => { const isJavaExecSel = ele.id === 'settingsJavaExecSel' const directoryDialog = ele.hasAttribute('dialogDirectory') && ele.getAttribute('dialogDirectory') == 'true' @@ -237,7 +237,7 @@ let selectedSettingsTab = 'settingsTabAccount' /** * Modify the settings container UI when the scroll threshold reaches * a certain poin. - * + * * @param {UIEvent} e The scroll event. */ function settingsTabScrollListener(e){ @@ -264,7 +264,7 @@ function setupSettingsTabs(){ /** * Settings nav item onclick lisener. Function is exposed so that * other UI elements can quickly toggle to a certain tab from other views. - * + * * @param {Element} ele The nav item which has been clicked. * @param {boolean} fade Optional. True to fade transition. */ @@ -314,7 +314,7 @@ const settingsNavDone = document.getElementById('settingsNavDone') /** * Set if the settings save (done) button is disabled. - * + * * @param {boolean} v True to disable, false to enable. */ function settingsSaveDisabled(v){ @@ -344,11 +344,11 @@ const msftLogoutLogger = LoggerUtil.getLogger('Microsoft Logout') // Bind the add mojang account button. // document.getElementById('settingsAddMojangAccount').onclick = (e) => { - // switchView(getCurrentView(), VIEWS.login, 500, 500, () => { - // loginViewOnCancel = VIEWS.settings - // loginViewOnSuccess = VIEWS.settings - // loginCancelEnabled(true) - // }) +// switchView(getCurrentView(), VIEWS.login, 500, 500, () => { +// loginViewOnCancel = VIEWS.settings +// loginViewOnSuccess = VIEWS.settings +// loginCancelEnabled(true) +// }) // } // Bind the add microsoft account button. @@ -391,7 +391,7 @@ ipcRenderer.on(MSFT_OPCODE.REPLY_LOGIN, (_, ...arguments_) => { if (Object.prototype.hasOwnProperty.call(queryMap, 'error')) { switchView(getCurrentView(), viewOnClose, 500, 500, () => { // TODO Dont know what these errors are. Just show them I guess. - // This is probably if you messed up the app registration with Azure. + // This is probably if you messed up the app registration with Azure. let error = queryMap.error // Error might be 'access_denied' ? let errorDesc = queryMap.error_description console.log('Error getting authCode, is Azure application registered correctly?') @@ -496,7 +496,7 @@ function bindAuthAccountLogOut(){ } else { processLogOut(val, isLastAccount) } - + } }) } @@ -504,7 +504,7 @@ function bindAuthAccountLogOut(){ let msAccDomElementCache /** * Process a log out. - * + * * @param {Element} val The log out button element. * @param {boolean} isLastAccount If this logout is on the last added account. */ @@ -562,13 +562,13 @@ ipcRenderer.on(MSFT_OPCODE.REPLY_LOGOUT, (_, ...arguments_) => { toggleOverlay(true) }) } else if(arguments_[0] === MSFT_REPLY_TYPE.SUCCESS) { - + const uuid = arguments_[1] const isLastAccount = arguments_[2] const prevSelAcc = ConfigManager.getSelectedAccount() msftLogoutLogger.info('Logout Successful. uuid:', uuid) - + AuthManager.removeMicrosoftAccount(uuid) .then(() => { if(!isLastAccount && uuid === prevSelAcc.uuid){ @@ -600,7 +600,7 @@ ipcRenderer.on(MSFT_OPCODE.REPLY_LOGOUT, (_, ...arguments_) => { /** * Refreshes the status of the selected account on the auth account * elements. - * + * * @param {string} uuid The UUID of the new selected account. */ function refreshAuthAccountSelected(uuid){ @@ -724,7 +724,7 @@ async function resolveModsForUI(){ /** * Recursively build the mod UI elements. - * + * * @param {Object[]} mdls An array of modules to parse. * @param {boolean} submodules Whether or not we are parsing submodules. * @param {Object} servConf The server configuration object for this module level. @@ -824,7 +824,7 @@ function saveModConfiguration(){ /** * Recursively save mod config with submods. - * + * * @param {Object} modConf Mod config object to save. */ function _saveModConfiguration(modConf){ @@ -1220,8 +1220,8 @@ settingsMaxRAMRange.onchange = (e) => { /** * Calculate common values for a ranged slider. - * - * @param {Element} v The range slider to calculate against. + * + * @param {Element} v The range slider to calculate against. * @returns {Object} An object with meta values for the provided ranged slider. */ function calculateRangeSliderMeta(v){ @@ -1265,7 +1265,7 @@ function bindRangeSlider(){ // Distance from the beginning of the bar in pixels. const diff = e.pageX - v.offsetLeft - track.offsetWidth/2 - + // Don't move the track off the bar. if(diff >= 0 && diff <= v.offsetWidth-track.offsetWidth/2){ @@ -1281,12 +1281,12 @@ function bindRangeSlider(){ } } } - }) + }) } /** * Update a ranged slider's value and position. - * + * * @param {Element} element The ranged slider to update. * @param {string | number} value The new value for the ranged slider. * @param {number} notch The notch that the slider should now be at. @@ -1295,7 +1295,7 @@ function updateRangedSlider(element, value, notch){ const oldVal = element.getAttribute('value') const bar = element.getElementsByClassName('rangeSliderBar')[0] const track = element.getElementsByClassName('rangeSliderTrack')[0] - + element.setAttribute('value', value) if(notch < 0){ @@ -1332,7 +1332,7 @@ function populateMemoryStatus(){ /** * Validate the provided executable path and display the data on * the UI. - * + * * @param {string} execPath The executable path to populate against. */ async function populateJavaExecDetails(execPath){ @@ -1409,7 +1409,7 @@ document.getElementById('settingsAboutDevToolsButton').onclick = (e) => { /** * Return whether or not the provided version is a prerelease. - * + * * @param {string} version The semver version to test. * @returns {boolean} True if the version is a prerelease, otherwise false. */ @@ -1421,7 +1421,7 @@ function isPrerelease(version){ /** * Utility method to display version information on the * About and Update settings tabs. - * + * * @param {string} version The semver version to display. * @param {Element} valueElement The value element. * @param {Element} titleElement The title element. @@ -1457,7 +1457,7 @@ function populateReleaseNotes(){ success: (data) => { const version = 'v' + remote.app.getVersion() const entries = $(data).find('entry') - + for(let i=0; i { shell.openExternal(data.darwindownload) @@ -1539,17 +1539,15 @@ function populateSettingsUpdateInformation(data){ settingsUpdateChangelogCont.style.display = 'none' populateVersionInformation(remote.app.getVersion(), settingsUpdateVersionValue, settingsUpdateVersionTitle, settingsUpdateVersionCheck) settingsUpdateButtonStatus(Lang.queryJS('settings.updates.checkForUpdatesButton'), false, () => { - if(!isDev){ - ipcRenderer.send('autoUpdateAction', 'checkForUpdate') - settingsUpdateButtonStatus(Lang.queryJS('settings.updates.checkingForUpdatesButton'), true) - } + ipcRenderer.send('autoUpdateAction', 'checkForUpdate') + settingsUpdateButtonStatus(Lang.queryJS('settings.updates.checkingForUpdatesButton'), true) }) } } /** * Prepare update tab for display. - * + * * @param {Object} data The update data. */ function prepareUpdateTab(data = null){ @@ -1562,7 +1560,7 @@ function prepareUpdateTab(data = null){ /** * Prepare the entire settings UI. - * + * * @param {boolean} first Whether or not it is the first load. */ async function prepareSettings(first = false) { diff --git a/app/assets/js/scripts/uibinder.js b/app/assets/js/scripts/uibinder.js index 7bc398f106..cfbb0360d3 100644 --- a/app/assets/js/scripts/uibinder.js +++ b/app/assets/js/scripts/uibinder.js @@ -28,8 +28,8 @@ let currentView /** * Switch launcher views. - * - * @param {string} current The ID of the current view container. + * + * @param {string} current The ID of the current view container. * @param {*} next The ID of the next view container. * @param {*} currentFadeTime Optional. The fade out time for the current view. * @param {*} nextFadeTime Optional. The fade in time for the next view. @@ -50,7 +50,7 @@ function switchView(current, next, currentFadeTime = 500, nextFadeTime = 500, on /** * Get the currently shown view container. - * + * * @returns {string} The currently shown view container. */ function getCurrentView(){ @@ -59,10 +59,8 @@ function getCurrentView(){ async function showMainUI(data){ - if(!isDev){ - loggerAutoUpdater.info('Initializing..') - ipcRenderer.send('autoUpdateAction', 'initAutoUpdater', ConfigManager.getAllowPrerelease()) - } + loggerAutoUpdater.info('Initializing..') + ipcRenderer.send('autoUpdateAction', 'initAutoUpdater', ConfigManager.getAllowPrerelease()) await prepareSettings(true) updateSelectedServer(data.getServerById(ConfigManager.getSelectedServer())) @@ -101,7 +99,7 @@ async function showMainUI(data){ $('#loadSpinnerImage').removeClass('rotating') }) }, 250) - + }, 750) } @@ -125,7 +123,7 @@ function showFatalStartupError(){ /** * Common functions to perform after refreshing the distro index. - * + * * @param {Object} data The distro index object. */ function onDistroRefresh(data){ @@ -137,7 +135,7 @@ function onDistroRefresh(data){ /** * Sync the mod configurations with the distro index. - * + * * @param {Object} data The distro index object. */ function syncModConfigurations(data){ @@ -221,7 +219,7 @@ function syncModConfigurations(data){ /** * Ensure java configurations are present for the available servers. - * + * * @param {Object} data The distro index object. */ function ensureJavaSettings(data) { @@ -238,7 +236,7 @@ function ensureJavaSettings(data) { * Recursively scan for optional sub modules. If none are found, * this function returns a boolean. If optional sub modules do exist, * a recursive configuration object is returned. - * + * * @returns {boolean | Object} The resolved mod configuration. */ function scanOptionalSubModules(mdls, origin){ @@ -278,11 +276,11 @@ function scanOptionalSubModules(mdls, origin){ /** * Recursively merge an old configuration into a new configuration. - * + * * @param {boolean | Object} o The old configuration value. * @param {boolean | Object} n The new configuration value. * @param {boolean} nReq If the new value is a required mod. - * + * * @returns {boolean | Object} The merged configuration. */ function mergeModConfiguration(o, n, nReq = false){ @@ -346,7 +344,7 @@ async function validateSelectedAccount(){ document.getElementById('loginUsername').value = selectedAcc.username validateEmail(selectedAcc.username) } - + loginOptionsViewOnLoginSuccess = getCurrentView() loginOptionsViewOnLoginCancel = VIEWS.loginOptions @@ -403,7 +401,7 @@ async function validateSelectedAccount(){ /** * Temporary function to update the selected account along * with the relevent UI elements. - * + * * @param {string} uuid The UUID of the account. */ function setSelectedAccount(uuid){ @@ -425,7 +423,7 @@ document.addEventListener('readystatechange', async () => { } else { showFatalStartupError() } - } + } } }, false) diff --git a/app/assets/js/scripts/uicore.js b/app/assets/js/scripts/uicore.js index 8e53a8a950..2d0b3cfd8b 100644 --- a/app/assets/js/scripts/uicore.js +++ b/app/assets/js/scripts/uicore.js @@ -38,60 +38,60 @@ webFrame.setVisualZoomLevelLimits(1, 1) // Initialize auto updates in production environments. let updateCheckListener -if(!isDev){ - ipcRenderer.on('autoUpdateNotification', (event, arg, info) => { - switch(arg){ - case 'checking-for-update': - loggerAutoUpdater.info('Checking for update..') - settingsUpdateButtonStatus(Lang.queryJS('uicore.autoUpdate.checkingForUpdateButton'), true) - break - case 'update-available': - loggerAutoUpdater.info('New update available', info.version) - - if(process.platform === 'darwin'){ - info.darwindownload = `https://github.com/Fairy-Jeux/CreateAcademyLauncher/releases/download/v${info.version}/Create.Academy.Launcher-setup-${info.version}${process.arch === 'arm64' ? '-arm64' : '-x64'}.dmg` - showUpdateUI(info) - } - - populateSettingsUpdateInformation(info) - break - case 'update-downloaded': - loggerAutoUpdater.info('Update ' + info.version + ' ready to be installed.') - settingsUpdateButtonStatus(Lang.queryJS('uicore.autoUpdate.installNowButton'), false, () => { - if(!isDev){ - ipcRenderer.send('autoUpdateAction', 'installUpdateNow') - } - }) +ipcRenderer.on('autoUpdateNotification', (event, arg, info) => { + switch(arg){ + case 'checking-for-update': + loggerAutoUpdater.info('Checking for update..') + settingsUpdateButtonStatus(Lang.queryJS('uicore.autoUpdate.checkingForUpdateButton'), true) + break + case 'update-available': + loggerAutoUpdater.info('New update available', info.version) + + if(process.platform === 'darwin'){ + info.darwindownload = `https://github.com/Fairy-Jeux/CreateAcademyLauncher/releases/download/v${info.version}/Create.Academy.Launcher-setup-${info.version}${process.arch === 'arm64' ? '-arm64' : '-x64'}.dmg` showUpdateUI(info) - break - case 'update-not-available': - loggerAutoUpdater.info('No new update found.') - settingsUpdateButtonStatus(Lang.queryJS('uicore.autoUpdate.checkForUpdatesButton')) - break - case 'ready': - updateCheckListener = setInterval(() => { - ipcRenderer.send('autoUpdateAction', 'checkForUpdate') - }, 1800000) + } + + populateSettingsUpdateInformation(info) + break + case 'update-downloaded': + loggerAutoUpdater.info('Update ' + info.version + ' ready to be installed.') + settingsUpdateButtonStatus(Lang.queryJS('uicore.autoUpdate.installNowButton'), false, () => { + if (isDev) { + console.warn('Skipped update installation in development environment.') + return + } + ipcRenderer.send('autoUpdateAction', 'installUpdateNow') + }) + showUpdateUI(info) + break + case 'update-not-available': + loggerAutoUpdater.info('No new update found.') + settingsUpdateButtonStatus(Lang.queryJS('uicore.autoUpdate.checkForUpdatesButton')) + break + case 'ready': + updateCheckListener = setInterval(() => { ipcRenderer.send('autoUpdateAction', 'checkForUpdate') - break - case 'realerror': - if(info != null && info.code != null){ - if(info.code === 'ERR_UPDATER_INVALID_RELEASE_FEED'){ - loggerAutoUpdater.info('No suitable releases found.') - } else if(info.code === 'ERR_XML_MISSED_ELEMENT'){ - loggerAutoUpdater.info('No releases found.') - } else { - loggerAutoUpdater.error('Error during update check..', info) - loggerAutoUpdater.debug('Error Code:', info.code) - } + }, 1800000) + ipcRenderer.send('autoUpdateAction', 'checkForUpdate') + break + case 'realerror': + if(info != null && info.code != null){ + if(info.code === 'ERR_UPDATER_INVALID_RELEASE_FEED'){ + loggerAutoUpdater.info('No suitable releases found.') + } else if(info.code === 'ERR_XML_MISSED_ELEMENT'){ + loggerAutoUpdater.info('No releases found.') + } else { + loggerAutoUpdater.error('Error during update check..', info) + loggerAutoUpdater.debug('Error Code:', info.code) } - break - default: - loggerAutoUpdater.info('Unknown argument', arg) - break - } - }) -} + } + break + default: + loggerAutoUpdater.info('Unknown argument', arg) + break + } +}) /** * Send a notification to the main process changing the value of @@ -130,7 +130,7 @@ function showUpdateUI(info){ $(function(){ - loggerUICore.info('UICore Initialized'); + loggerUICore.info('UICore Initialized') }) document.addEventListener('readystatechange', function () { diff --git a/docs/.DS_Store b/docs/.DS_Store deleted file mode 100644 index 5008ddfcf5..0000000000 Binary files a/docs/.DS_Store and /dev/null differ diff --git a/electron-builder.yml b/electron-builder.yml index 3ff49051d3..9c76b329c0 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -1,5 +1,5 @@ appId: 'helioslauncher' -productName: 'Create Academy Launcher' +productName: 'Create-Academy-Launcher' artifactName: '${productName}-setup-${version}.${ext}' copyright: 'Copyright © 2024 Fairy Jeux' @@ -14,14 +14,14 @@ extraResources: - 'libraries' # Windows Configuration -win: - target: +win: + target: - target: 'nsis' arch: 'x64' # Windows Installer Configuration nsis: - oneClick: true + oneClick: false perMachine: false allowElevation: true allowToChangeInstallationDirectory: true @@ -37,7 +37,7 @@ mac: category: 'public.app-category.games' # Linux Configuration -linux: +linux: target: 'AppImage' maintainer: 'Fairy Jeux' vendor: 'Fairy Jeux' @@ -48,4 +48,4 @@ linux: directories: buildResources: 'build' - output: 'dist' \ No newline at end of file + output: 'dist' diff --git a/index.js b/index.js index 7e5ad0282c..5e82baeaca 100644 --- a/index.js +++ b/index.js @@ -18,6 +18,8 @@ LangLoader.setupLanguage() // Setup auto updater. function initAutoUpdater(event, data) { + autoUpdater.disableWebInstaller = true + autoUpdater.disableDifferentialDownload = true // doesn't work anyway if(data){ autoUpdater.allowPrerelease = true @@ -25,11 +27,13 @@ function initAutoUpdater(event, data) { // Defaults to true if application version contains prerelease components (e.g. 0.12.1-alpha.1) // autoUpdater.allowPrerelease = true } - + if(isDev){ autoUpdater.autoInstallOnAppQuit = false - autoUpdater.updateConfigPath = path.join(__dirname, 'dev-app-update.yml') + autoUpdater.forceDevUpdateConfig = true + console.log('App path is:', app.getAppPath()) } + if(process.platform === 'darwin'){ autoUpdater.autoDownload = true } @@ -46,8 +50,9 @@ function initAutoUpdater(event, data) { event.sender.send('autoUpdateNotification', 'checking-for-update') }) autoUpdater.on('error', (err) => { + console.log('update-error', err) event.sender.send('autoUpdateNotification', 'realerror', err) - }) + }) } // Open channel to listen for update actions. @@ -59,7 +64,7 @@ ipcMain.on('autoUpdateAction', (event, arg, data) => { event.sender.send('autoUpdateNotification', 'ready') break case 'checkForUpdate': - autoUpdater.checkForUpdates() + autoUpdater.checkForUpdatesAndNotify() .catch(err => { event.sender.send('autoUpdateNotification', 'realerror', err) }) @@ -198,7 +203,7 @@ ipcMain.on(MSFT_OPCODE.OPEN_LOGOUT, (ipcEvent, uuid, isLastAccount) => { ipcEvent.reply(MSFT_OPCODE.REPLY_LOGOUT, MSFT_REPLY_TYPE.SUCCESS, uuid, isLastAccount) } }) - + msftLogoutWindow.webContents.on('did-navigate', (_, uri) => { if(uri.startsWith('https://login.microsoftonline.com/common/oauth2/v2.0/logoutsession')) { msftLogoutSuccess = true @@ -215,7 +220,7 @@ ipcMain.on(MSFT_OPCODE.OPEN_LOGOUT, (ipcEvent, uuid, isLastAccount) => { }, 5000) } }) - + msftLogoutWindow.removeMenu() msftLogoutWindow.loadURL('https://login.microsoftonline.com/common/oauth2/v2.0/logout') }) @@ -240,8 +245,18 @@ function createWindow() { }) remoteMain.enable(win.webContents) + // sometimes it picks up on `.DS_Store` , `Thumbs.db`, etc. (thanks macOS) + const supportedBackgroundTypes = ['.jpg', '.jpeg', '.png', '.gif', '.webp'] + const availableBackgrounds = fs.readdirSync(path.join(__dirname, 'app', 'assets', 'images', 'backgrounds'), {withFileTypes: true}) + .filter(file => file.isFile() && supportedBackgroundTypes.includes(path.extname(file.name).toLowerCase())) + + const backgroundPath = availableBackgrounds[ + availableBackgrounds.length > 1 + ? Math.floor(Math.random() * availableBackgrounds.length) + : 0 + ]?.name ?? 'empty.png' const data = { - bkid: 1 + Math.floor((Math.random() * (fs.readdirSync(path.join(__dirname, 'app', 'assets', 'images', 'backgrounds')).length))), + backgroundPath, lang: (str, placeHolders) => LangLoader.queryEJS(str, placeHolders) } Object.entries(data).forEach(([key, val]) => ejse.data(key, val)) @@ -262,7 +277,7 @@ function createWindow() { } function createMenu() { - + if(process.platform === 'darwin') { // Extend default included application menu to continue support for quit keyboard shortcut @@ -358,4 +373,4 @@ app.on('activate', () => { if (win === null) { createWindow() } -}) \ No newline at end of file +})