diff options
-rw-r--r-- | package-lock.json | 18 | ||||
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | src/environment.js | 60 | ||||
-rw-r--r-- | src/helpers/userAgent-helpers.js | 14 | ||||
-rw-r--r-- | src/index.js | 9 | ||||
-rw-r--r-- | src/lib/Menu.js | 8 | ||||
-rw-r--r-- | src/stores/AppStore.js | 8 |
7 files changed, 57 insertions, 62 deletions
diff --git a/package-lock.json b/package-lock.json index 6eae814cb..f6d914dfb 100644 --- a/package-lock.json +++ b/package-lock.json | |||
@@ -15866,6 +15866,11 @@ | |||
15866 | "resolved": "https://registry.npmjs.org/electron-find/-/electron-find-1.0.6.tgz", | 15866 | "resolved": "https://registry.npmjs.org/electron-find/-/electron-find-1.0.6.tgz", |
15867 | "integrity": "sha512-RenjzlCCzX7edLywLy+qRYvzds11sBv8+SrJu/3l3eVLt9d9uNqCPk+uFZ525uAhSUaUalgZWDlhQdxIgT1khg==" | 15867 | "integrity": "sha512-RenjzlCCzX7edLywLy+qRYvzds11sBv8+SrJu/3l3eVLt9d9uNqCPk+uFZ525uAhSUaUalgZWDlhQdxIgT1khg==" |
15868 | }, | 15868 | }, |
15869 | "electron-is-dev": { | ||
15870 | "version": "1.2.0", | ||
15871 | "resolved": "https://registry.npmjs.org/electron-is-dev/-/electron-is-dev-1.2.0.tgz", | ||
15872 | "integrity": "sha512-R1oD5gMBPS7PVU8gJwH6CtT0e6VSoD0+SzSnYpNm+dBkcijgA+K7VAMHDfnRq/lkKPZArpzplTW6jfiMYosdzw==" | ||
15873 | }, | ||
15869 | "electron-notarize": { | 15874 | "electron-notarize": { |
15870 | "version": "1.0.0", | 15875 | "version": "1.0.0", |
15871 | "resolved": "https://registry.npmjs.org/electron-notarize/-/electron-notarize-1.0.0.tgz", | 15876 | "resolved": "https://registry.npmjs.org/electron-notarize/-/electron-notarize-1.0.0.tgz", |
@@ -16613,19 +16618,12 @@ | |||
16613 | } | 16618 | } |
16614 | }, | 16619 | }, |
16615 | "electron-util": { | 16620 | "electron-util": { |
16616 | "version": "0.16.0", | 16621 | "version": "0.17.0", |
16617 | "resolved": "https://registry.npmjs.org/electron-util/-/electron-util-0.16.0.tgz", | 16622 | "resolved": "https://registry.npmjs.org/electron-util/-/electron-util-0.17.0.tgz", |
16618 | "integrity": "sha512-r13cauuQ8p8d++ZVdeMDtQ2VlpblJBcpKnK7sf2tGnN8CCWyRGYerS2K5f3FiblFIQkyS0rE4tFVG0IOEc2F3A==", | 16623 | "integrity": "sha512-61+NEPdIN68EBC9XDPNAKs14HlPdc7HsL6lfQ+QTiya+3BMzayBqUsvN1LrT7IoGpPuuZns+iaCKf1N78dEF+w==", |
16619 | "requires": { | 16624 | "requires": { |
16620 | "electron-is-dev": "^1.1.0", | 16625 | "electron-is-dev": "^1.1.0", |
16621 | "new-github-issue-url": "^0.2.1" | 16626 | "new-github-issue-url": "^0.2.1" |
16622 | }, | ||
16623 | "dependencies": { | ||
16624 | "electron-is-dev": { | ||
16625 | "version": "1.2.0", | ||
16626 | "resolved": "https://registry.npmjs.org/electron-is-dev/-/electron-is-dev-1.2.0.tgz", | ||
16627 | "integrity": "sha512-R1oD5gMBPS7PVU8gJwH6CtT0e6VSoD0+SzSnYpNm+dBkcijgA+K7VAMHDfnRq/lkKPZArpzplTW6jfiMYosdzw==" | ||
16628 | } | ||
16629 | } | 16627 | } |
16630 | }, | 16628 | }, |
16631 | "electron-window-state": { | 16629 | "electron-window-state": { |
diff --git a/package.json b/package.json index a15f44d9c..097ddd383 100644 --- a/package.json +++ b/package.json | |||
@@ -84,7 +84,7 @@ | |||
84 | "electron-find": "1.0.6", | 84 | "electron-find": "1.0.6", |
85 | "electron-react-titlebar": "0.8.2", | 85 | "electron-react-titlebar": "0.8.2", |
86 | "electron-updater": "4.3.9", | 86 | "electron-updater": "4.3.9", |
87 | "electron-util": "0.16.0", | 87 | "electron-util": "0.17.0", |
88 | "electron-window-state": "5.0.3", | 88 | "electron-window-state": "5.0.3", |
89 | "fs-extra": "10.0.0", | 89 | "fs-extra": "10.0.0", |
90 | "gulp-csso": "4.0.1", | 90 | "gulp-csso": "4.0.1", |
diff --git a/src/environment.js b/src/environment.js index 6a55045a7..be6dc7176 100644 --- a/src/environment.js +++ b/src/environment.js | |||
@@ -1,5 +1,7 @@ | |||
1 | import path from 'path'; | 1 | import path from 'path'; |
2 | 2 | ||
3 | import { is, api as electronApi } from 'electron-util'; | ||
4 | |||
3 | import { DEFAULT_ACCENT_COLOR } from '@meetfranz/theme'; | 5 | import { DEFAULT_ACCENT_COLOR } from '@meetfranz/theme'; |
4 | 6 | ||
5 | import { | 7 | import { |
@@ -21,12 +23,16 @@ import { | |||
21 | } from './config'; | 23 | } from './config'; |
22 | 24 | ||
23 | import { asarPath } from './helpers/asar-helpers'; | 25 | import { asarPath } from './helpers/asar-helpers'; |
26 | import * as buildInfo from './buildInfo.json'; // eslint-disable-line import/no-unresolved | ||
27 | |||
28 | const osName = require('os-name'); | ||
24 | 29 | ||
25 | // eslint-disable-next-line global-require | 30 | export const { app } = electronApi; |
26 | export const { app } = process.type === 'renderer' ? require('@electron/remote') : require('electron'); | 31 | export const ferdiVersion = app.getVersion(); |
27 | const { nativeTheme } = process.type === 'renderer' ? require('@electron/remote') : require('electron'); | 32 | export const electronVersion = process.versions.electron; |
33 | export const chromeVersion = process.versions.chrome; | ||
34 | export const nodeVersion = process.versions.node; | ||
28 | 35 | ||
29 | // TODO: This seems to be duplicated between here and 'index.js' | ||
30 | // Set app directory before loading user modules | 36 | // Set app directory before loading user modules |
31 | if (process.env.FERDI_APPDATA_DIR != null) { | 37 | if (process.env.FERDI_APPDATA_DIR != null) { |
32 | app.setPath('appData', process.env.FERDI_APPDATA_DIR); | 38 | app.setPath('appData', process.env.FERDI_APPDATA_DIR); |
@@ -34,27 +40,12 @@ if (process.env.FERDI_APPDATA_DIR != null) { | |||
34 | } else if (process.env.PORTABLE_EXECUTABLE_DIR != null) { | 40 | } else if (process.env.PORTABLE_EXECUTABLE_DIR != null) { |
35 | app.setPath('appData', process.env.PORTABLE_EXECUTABLE_DIR, `${app.name}AppData`); | 41 | app.setPath('appData', process.env.PORTABLE_EXECUTABLE_DIR, `${app.name}AppData`); |
36 | app.setPath('userData', path.join(app.getPath('appData'), `${app.name}AppData`)); | 42 | app.setPath('userData', path.join(app.getPath('appData'), `${app.name}AppData`)); |
37 | } else if (process.platform === 'win32') { | 43 | } else if (is.windows) { |
38 | app.setPath('appData', process.env.APPDATA); | 44 | app.setPath('appData', process.env.APPDATA); |
39 | app.setPath('userData', path.join(app.getPath('appData'), app.name)); | 45 | app.setPath('userData', path.join(app.getPath('appData'), app.name)); |
40 | } | 46 | } |
41 | 47 | ||
42 | const ELECTRON_IS_DEV_VAR = 'ELECTRON_IS_DEV'; | 48 | export const isDevMode = is.development; |
43 | const NODE_ENV_VAR = 'NODE_ENV'; | ||
44 | |||
45 | export const isDevMode = (() => { | ||
46 | const isEnvVarSet = name => name in process.env; | ||
47 | if (isEnvVarSet(ELECTRON_IS_DEV_VAR)) { | ||
48 | // Copied from https://github.com/sindresorhus/electron-is-dev/blob/f05330b856782dac7987b10859bfd95ea6a187a6/index.js | ||
49 | // but electron-is-dev breaks in a renderer process, so we use the app import from above instead. | ||
50 | const electronIsDev = process.env[ELECTRON_IS_DEV_VAR]; | ||
51 | return electronIsDev === 'true' || Number.parseInt(electronIsDev, 10) === 1; | ||
52 | } | ||
53 | if (isEnvVarSet(NODE_ENV_VAR)) { | ||
54 | return process.env[NODE_ENV_VAR] === 'development'; | ||
55 | } | ||
56 | return !app.isPackaged; | ||
57 | })(); | ||
58 | if (isDevMode) { | 49 | if (isDevMode) { |
59 | app.setPath('userData', path.join(app.getPath('appData'), `${app.name}Dev`)); | 50 | app.setPath('userData', path.join(app.getPath('appData'), `${app.name}Dev`)); |
60 | } | 51 | } |
@@ -66,14 +57,9 @@ export const RECIPES_PATH = asarPath(path.join(__dirname, 'recipes')); | |||
66 | 57 | ||
67 | export const useLiveAPI = process.env.LIVE_API; | 58 | export const useLiveAPI = process.env.LIVE_API; |
68 | 59 | ||
69 | let { platform } = process; | 60 | export const isMac = is.macos; |
70 | if (process.env.OS_PLATFORM) { | 61 | export const isWindows = is.windows; |
71 | platform = process.env.OS_PLATFORM; | 62 | export const isLinux = is.linux; |
72 | } | ||
73 | |||
74 | export const isMac = platform === 'darwin'; | ||
75 | export const isWindows = platform === 'win32'; | ||
76 | export const isLinux = platform === 'linux'; | ||
77 | 63 | ||
78 | export const ctrlKey = isMac ? '⌘' : 'Ctrl'; | 64 | export const ctrlKey = isMac ? '⌘' : 'Ctrl'; |
79 | export const cmdKey = isMac ? 'Cmd' : 'Ctrl'; | 65 | export const cmdKey = isMac ? 'Cmd' : 'Ctrl'; |
@@ -123,7 +109,7 @@ export const DEFAULT_APP_SETTINGS = { | |||
123 | showDragArea: false, | 109 | showDragArea: false, |
124 | enableSpellchecking: true, | 110 | enableSpellchecking: true, |
125 | spellcheckerLanguage: 'en-us', | 111 | spellcheckerLanguage: 'en-us', |
126 | darkMode: isMac ? nativeTheme.shouldUseDarkColors : false, | 112 | darkMode: isMac && electronApi.nativeTheme.shouldUseDarkColors, |
127 | locale: '', | 113 | locale: '', |
128 | fallbackLocale: 'en-US', | 114 | fallbackLocale: 'en-US', |
129 | beta: false, | 115 | beta: false, |
@@ -165,3 +151,17 @@ export const DEFAULT_APP_SETTINGS = { | |||
165 | export function termsBase() { | 151 | export function termsBase() { |
166 | return window.ferdi.stores.settings.all.app.server !== LIVE_FRANZ_API ? window.ferdi.stores.settings.all.app.server : DEV_API_FRANZ_WEBSITE; | 152 | return window.ferdi.stores.settings.all.app.server !== LIVE_FRANZ_API ? window.ferdi.stores.settings.all.app.server : DEV_API_FRANZ_WEBSITE; |
167 | } | 153 | } |
154 | |||
155 | export function aboutAppDetails() { | ||
156 | return [ | ||
157 | `Version: ${ferdiVersion}`, | ||
158 | `Electron: ${electronVersion}`, | ||
159 | `Chrome: ${chromeVersion}`, | ||
160 | `Node.js: ${nodeVersion}`, | ||
161 | `Platform: ${osName()}`, | ||
162 | `Arch: ${process.arch}`, | ||
163 | `Build date: ${new Date(Number(buildInfo.timestamp))}`, | ||
164 | `Git SHA: ${buildInfo.gitHashShort}`, | ||
165 | `Git branch: ${buildInfo.gitBranch}`, | ||
166 | ].join('\n'); | ||
167 | } | ||
diff --git a/src/helpers/userAgent-helpers.js b/src/helpers/userAgent-helpers.js index 73c454304..fc9a6f507 100644 --- a/src/helpers/userAgent-helpers.js +++ b/src/helpers/userAgent-helpers.js | |||
@@ -1,8 +1,8 @@ | |||
1 | import os from 'os'; | 1 | import os from 'os'; |
2 | import macosVersion from 'macos-version'; | 2 | import macosVersion from 'macos-version'; |
3 | import { app, isMac, isWindows } from '../environment'; | 3 | import { |
4 | 4 | ferdiVersion, electronVersion, chromeVersion, isMac, isWindows, | |
5 | export const ferdiVersion = app.getVersion(); | 5 | } from '../environment'; |
6 | 6 | ||
7 | function macOS() { | 7 | function macOS() { |
8 | const version = macosVersion(); | 8 | const version = macosVersion(); |
@@ -34,17 +34,17 @@ export default function userAgent(removeChromeVersion = false, addFerdiVersion = | |||
34 | platformString = linux(); | 34 | platformString = linux(); |
35 | } | 35 | } |
36 | 36 | ||
37 | let chromeVersion = 'Chrome'; | 37 | let chromeVersionString = 'Chrome'; |
38 | if (!removeChromeVersion) { | 38 | if (!removeChromeVersion) { |
39 | chromeVersion = `Chrome/${process.versions.chrome}`; | 39 | chromeVersionString = `Chrome/${chromeVersion}`; |
40 | } | 40 | } |
41 | 41 | ||
42 | let applicationString = ''; | 42 | let applicationString = ''; |
43 | if (addFerdiVersion) { | 43 | if (addFerdiVersion) { |
44 | applicationString = ` Ferdi/${ferdiVersion} Electron/${process.versions.electron}`; | 44 | applicationString = ` Ferdi/${ferdiVersion} Electron/${electronVersion}`; |
45 | } | 45 | } |
46 | 46 | ||
47 | // Chrome is pinned to WebKit 537.36, the latest version before hard forking to Blink. | 47 | // Chrome is pinned to WebKit 537.36, the latest version before hard forking to Blink. |
48 | return `Mozilla/5.0 (${platformString}) AppleWebKit/537.36 (KHTML, like Gecko) ${chromeVersion} Safari/537.36${applicationString}`; | 48 | return `Mozilla/5.0 (${platformString}) AppleWebKit/537.36 (KHTML, like Gecko) ${chromeVersionString} Safari/537.36${applicationString}`; |
49 | // Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36 Ferdi/5.5.1-nightly.13 Electron/8.2.3 | 49 | // Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36 Ferdi/5.5.1-nightly.13 Electron/8.2.3 |
50 | } | 50 | } |
diff --git a/src/index.js b/src/index.js index d3b996540..8a4283f49 100644 --- a/src/index.js +++ b/src/index.js | |||
@@ -24,6 +24,7 @@ import { | |||
24 | isMac, | 24 | isMac, |
25 | isWindows, | 25 | isWindows, |
26 | isLinux, | 26 | isLinux, |
27 | aboutAppDetails, | ||
27 | } from './environment'; | 28 | } from './environment'; |
28 | 29 | ||
29 | import { mainIpcHandler as basicAuthHandler } from './features/basicAuth'; | 30 | import { mainIpcHandler as basicAuthHandler } from './features/basicAuth'; |
@@ -34,14 +35,12 @@ import Settings from './electron/Settings'; | |||
34 | import handleDeepLink from './electron/deepLinking'; | 35 | import handleDeepLink from './electron/deepLinking'; |
35 | import { isPositionValid } from './electron/windowUtils'; | 36 | import { isPositionValid } from './electron/windowUtils'; |
36 | import { appId } from './package.json'; // eslint-disable-line import/no-unresolved | 37 | import { appId } from './package.json'; // eslint-disable-line import/no-unresolved |
37 | import * as buildInfo from './buildInfo.json'; // eslint-disable-line import/no-unresolved | ||
38 | import './electron/exception'; | 38 | import './electron/exception'; |
39 | 39 | ||
40 | import { asarPath } from './helpers/asar-helpers'; | 40 | import { asarPath } from './helpers/asar-helpers'; |
41 | import { isValidExternalURL } from './helpers/url-helpers'; | 41 | import { isValidExternalURL } from './helpers/url-helpers'; |
42 | import userAgent, { ferdiVersion } from './helpers/userAgent-helpers'; | 42 | import userAgent from './helpers/userAgent-helpers'; |
43 | 43 | ||
44 | const osName = require('os-name'); | ||
45 | const debug = require('debug')('Ferdi:App'); | 44 | const debug = require('debug')('Ferdi:App'); |
46 | 45 | ||
47 | // From Electron 9 onwards, app.allowRendererProcessReuse = true by default. This causes the app to crash on Windows due to the | 46 | // From Electron 9 onwards, app.allowRendererProcessReuse = true by default. This causes the app to crash on Windows due to the |
@@ -147,7 +146,7 @@ if (!settings.get('enableGPUAcceleration')) { | |||
147 | } | 146 | } |
148 | 147 | ||
149 | app.setAboutPanelOptions({ | 148 | app.setAboutPanelOptions({ |
150 | applicationVersion: `Version: ${ferdiVersion}\nElectron: ${process.versions.electron}\nChrome: ${process.versions.chrome}\nNode.js: ${process.versions.node}\nPlatform: ${osName()}\nArch: ${process.arch}\nBuild date: ${new Date(Number(buildInfo.timestamp))}\nGit SHA: ${buildInfo.gitHashShort}\nGit branch: ${buildInfo.gitBranch}`, | 149 | applicationVersion: aboutAppDetails(), |
151 | version: '', | 150 | version: '', |
152 | }); | 151 | }); |
153 | 152 | ||
@@ -156,7 +155,7 @@ const createWindow = () => { | |||
156 | const mainWindowState = windowStateKeeper({ | 155 | const mainWindowState = windowStateKeeper({ |
157 | defaultWidth: DEFAULT_WINDOW_OPTIONS.width, | 156 | defaultWidth: DEFAULT_WINDOW_OPTIONS.width, |
158 | defaultHeight: DEFAULT_WINDOW_OPTIONS.height, | 157 | defaultHeight: DEFAULT_WINDOW_OPTIONS.height, |
159 | maximize: true, // Automatically maximizes the window, if it was last clsoed maximized | 158 | maximize: true, // Automatically maximizes the window, if it was last closed maximized |
160 | fullScreen: true, // Automatically restores the window to full screen, if it was last closed full screen | 159 | fullScreen: true, // Automatically restores the window to full screen, if it was last closed full screen |
161 | }); | 160 | }); |
162 | 161 | ||
diff --git a/src/lib/Menu.js b/src/lib/Menu.js index d66fa009f..c60536f0c 100644 --- a/src/lib/Menu.js +++ b/src/lib/Menu.js | |||
@@ -6,7 +6,7 @@ import { autorun, observable } from 'mobx'; | |||
6 | import { defineMessages } from 'react-intl'; | 6 | import { defineMessages } from 'react-intl'; |
7 | import { CUSTOM_WEBSITE_RECIPE_ID, GITHUB_FERDI_URL, LIVE_API_FERDI_WEBSITE } from '../config'; | 7 | import { CUSTOM_WEBSITE_RECIPE_ID, GITHUB_FERDI_URL, LIVE_API_FERDI_WEBSITE } from '../config'; |
8 | import { | 8 | import { |
9 | cmdKey, ctrlKey, isLinux, isMac, termsBase, | 9 | cmdKey, ctrlKey, isLinux, isMac, aboutAppDetails, termsBase, |
10 | } from '../environment'; | 10 | } from '../environment'; |
11 | import { announcementsStore } from '../features/announcements'; | 11 | import { announcementsStore } from '../features/announcements'; |
12 | import { announcementActions } from '../features/announcements/actions'; | 12 | import { announcementActions } from '../features/announcements/actions'; |
@@ -14,10 +14,6 @@ import { todosStore } from '../features/todos'; | |||
14 | import { todoActions } from '../features/todos/actions'; | 14 | import { todoActions } from '../features/todos/actions'; |
15 | import { workspaceActions } from '../features/workspaces/actions'; | 15 | import { workspaceActions } from '../features/workspaces/actions'; |
16 | import { workspaceStore } from '../features/workspaces/index'; | 16 | import { workspaceStore } from '../features/workspaces/index'; |
17 | import * as buildInfo from '../buildInfo.json'; // eslint-disable-line import/no-unresolved | ||
18 | import { ferdiVersion } from '../helpers/userAgent-helpers'; | ||
19 | |||
20 | const osName = require('os-name'); | ||
21 | 17 | ||
22 | const menuItems = defineMessages({ | 18 | const menuItems = defineMessages({ |
23 | edit: { | 19 | edit: { |
@@ -1025,7 +1021,7 @@ export default class FranzMenu { | |||
1025 | type: 'info', | 1021 | type: 'info', |
1026 | title: 'Franz Ferdinand', | 1022 | title: 'Franz Ferdinand', |
1027 | message: 'Ferdi', | 1023 | message: 'Ferdi', |
1028 | detail: `Version: ${ferdiVersion}\nElectron: ${process.versions.electron}\nChrome: ${process.versions.chrome}\nNode.js: ${process.versions.node}\nPlatform: ${osName()}\nArch: ${process.arch}\nBuild date: ${new Date(Number(buildInfo.timestamp))}\nGit SHA: ${buildInfo.gitHashShort}\nGit branch: ${buildInfo.gitBranch}`, | 1024 | detail: aboutAppDetails(), |
1029 | }); | 1025 | }); |
1030 | }, | 1026 | }, |
1031 | }; | 1027 | }; |
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 3116677c2..bbcf78a43 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -14,7 +14,9 @@ import { readJsonSync } from 'fs-extra'; | |||
14 | import Store from './lib/Store'; | 14 | import Store from './lib/Store'; |
15 | import Request from './lib/Request'; | 15 | import Request from './lib/Request'; |
16 | import { CHECK_INTERVAL } from '../config'; | 16 | import { CHECK_INTERVAL } from '../config'; |
17 | import { DEFAULT_APP_SETTINGS, isMac } from '../environment'; | 17 | import { |
18 | DEFAULT_APP_SETTINGS, isMac, ferdiVersion, electronVersion, | ||
19 | } from '../environment'; | ||
18 | import locales from '../i18n/translations'; | 20 | import locales from '../i18n/translations'; |
19 | import { onVisibilityChange } from '../helpers/visibility-helper'; | 21 | import { onVisibilityChange } from '../helpers/visibility-helper'; |
20 | import { getLocale } from '../helpers/i18n-helpers'; | 22 | import { getLocale } from '../helpers/i18n-helpers'; |
@@ -263,8 +265,8 @@ export default class AppStore extends Store { | |||
263 | screens: screen.getAllDisplays(), | 265 | screens: screen.getAllDisplays(), |
264 | }, | 266 | }, |
265 | ferdi: { | 267 | ferdi: { |
266 | version: app.getVersion(), | 268 | version: ferdiVersion, |
267 | electron: process.versions.electron, | 269 | electron: electronVersion, |
268 | installedRecipes: this.stores.recipes.all.map(recipe => ({ | 270 | installedRecipes: this.stores.recipes.all.map(recipe => ({ |
269 | id: recipe.id, | 271 | id: recipe.id, |
270 | version: recipe.version, | 272 | version: recipe.version, |