aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Vijay A <avijayr@protonmail.com>2021-08-05 08:45:37 +0530
committerLibravatar Vijay A <avijayr@protonmail.com>2021-08-05 08:45:37 +0530
commit3336789ba527e0421d0718834afdffd0f85c3b10 (patch)
treebab95c24baa1454eac0091f5f6726647519b8d38
parentUpdated 'CHANGELOG.md'. [skip ci] (diff)
downloadferdium-app-3336789ba527e0421d0718834afdffd0f85c3b10.tar.gz
ferdium-app-3336789ba527e0421d0718834afdffd0f85c3b10.tar.zst
ferdium-app-3336789ba527e0421d0718834afdffd0f85c3b10.zip
refactor: minor refactoring: solve name-clash of env vars vs vars in the program
-rw-r--r--.vscode/launch.json14
-rw-r--r--package.json4
-rw-r--r--src/api/apiBase.js7
-rw-r--r--src/components/auth/Signup.js3
-rw-r--r--src/environment.js12
-rw-r--r--src/lib/Menu.js3
6 files changed, 23 insertions, 20 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json
index f6c7458bf..96fc456fd 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -19,9 +19,9 @@
19 "name": "Ferdi – Live API", 19 "name": "Ferdi – Live API",
20 "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron", 20 "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
21 "program": "${workspaceFolder}/build/index.js", 21 "program": "${workspaceFolder}/build/index.js",
22 "protocol": "inspector", 22 "protocol": "inspector",
23 "env": { 23 "env": {
24 "LIVE_API": "1", 24 "USE_LIVE_API": "1",
25 "DEBUG": "*,-engine.io*,-socket.io*" 25 "DEBUG": "*,-engine.io*,-socket.io*"
26 } 26 }
27 }, 27 },
@@ -33,7 +33,7 @@
33 "program": "${workspaceFolder}/build/index.js", 33 "program": "${workspaceFolder}/build/index.js",
34 "protocol": "inspector", 34 "protocol": "inspector",
35 "env": { 35 "env": {
36 "LOCAL_API": "1", 36 "USE_LOCAL_API": "1",
37 "DEBUG": "*,-engine.io*,-socket.io*" 37 "DEBUG": "*,-engine.io*,-socket.io*"
38 } 38 }
39 }, 39 },
@@ -56,9 +56,9 @@
56 "name": "(Win Sim) Ferdi – Live API", 56 "name": "(Win Sim) Ferdi – Live API",
57 "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron", 57 "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
58 "program": "${workspaceFolder}/build/index.js", 58 "program": "${workspaceFolder}/build/index.js",
59 "protocol": "inspector", 59 "protocol": "inspector",
60 "env": { 60 "env": {
61 "LIVE_API": "1", 61 "USE_LIVE_API": "1",
62 "OS_PLATFORM": "win32", 62 "OS_PLATFORM": "win32",
63 "DEBUG": "*,-engine.io*,-socket.io*" 63 "DEBUG": "*,-engine.io*,-socket.io*"
64 } 64 }
@@ -71,10 +71,10 @@
71 "program": "${workspaceFolder}/build/index.js", 71 "program": "${workspaceFolder}/build/index.js",
72 "protocol": "inspector", 72 "protocol": "inspector",
73 "env": { 73 "env": {
74 "LOCAL_API": "1", 74 "USE_LOCAL_API": "1",
75 "OS_PLATFORM": "win32", 75 "OS_PLATFORM": "win32",
76 "DEBUG": "*,-engine.io*,-socket.io*" 76 "DEBUG": "*,-engine.io*,-socket.io*"
77 } 77 }
78 } 78 }
79 ] 79 ]
80} \ No newline at end of file 80}
diff --git a/package.json b/package.json
index 878e7834d..a209bc661 100644
--- a/package.json
+++ b/package.json
@@ -20,8 +20,8 @@
20 "prepare": "husky install", 20 "prepare": "husky install",
21 "prestart": "npm run rebuild", 21 "prestart": "npm run rebuild",
22 "start": "electron ./build", 22 "start": "electron ./build",
23 "start:local": "cross-env LOCAL_API=1 npm start", 23 "start:local": "cross-env USE_LOCAL_API=1 npm start",
24 "start:live": "cross-env LIVE_API=1 npm start", 24 "start:live": "cross-env USE_LIVE_API=1 npm start",
25 "dev": "cross-env NODE_ENV=development gulp dev", 25 "dev": "cross-env NODE_ENV=development gulp dev",
26 "test": "jest", 26 "test": "jest",
27 "test:watch": "jest --watch", 27 "test:watch": "jest --watch",
diff --git a/src/api/apiBase.js b/src/api/apiBase.js
index 842c85e56..3278dc454 100644
--- a/src/api/apiBase.js
+++ b/src/api/apiBase.js
@@ -5,6 +5,8 @@ import {
5 API_VERSION, 5 API_VERSION,
6} from '../environment'; 6} from '../environment';
7import { 7import {
8 DEV_API_FRANZ_WEBSITE,
9 LIVE_FRANZ_API,
8 LOCAL_SERVER, 10 LOCAL_SERVER,
9 SERVER_NOT_LOADED, 11 SERVER_NOT_LOADED,
10} from '../config'; 12} from '../config';
@@ -34,3 +36,8 @@ const apiBase = (withVersion = true) => {
34}; 36};
35 37
36export default apiBase; 38export default apiBase;
39
40export function termsBase() {
41 // TODO: This needs to handle local vs ferdi vs franz servers
42 return window.ferdi.stores.settings.all.app.server !== LIVE_FRANZ_API ? window.ferdi.stores.settings.all.app.server : DEV_API_FRANZ_WEBSITE;
43}
diff --git a/src/components/auth/Signup.js b/src/components/auth/Signup.js
index 411b6697b..6fb41a164 100644
--- a/src/components/auth/Signup.js
+++ b/src/components/auth/Signup.js
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
4import { observer, inject } from 'mobx-react'; 4import { observer, inject } from 'mobx-react';
5import { defineMessages, intlShape } from 'react-intl'; 5import { defineMessages, intlShape } from 'react-intl';
6 6
7import { isDevMode, termsBase, useLiveAPI } from '../../environment'; 7import { isDevMode, useLiveAPI } from '../../environment';
8import Form from '../../lib/Form'; 8import Form from '../../lib/Form';
9import { required, email, minLength } from '../../helpers/validation-helpers'; 9import { required, email, minLength } from '../../helpers/validation-helpers';
10import serverlessLogin from '../../helpers/serverless-helpers'; 10import serverlessLogin from '../../helpers/serverless-helpers';
@@ -14,6 +14,7 @@ import Link from '../ui/Link';
14import Infobox from '../ui/Infobox'; 14import Infobox from '../ui/Infobox';
15 15
16import { globalError as globalErrorPropType } from '../../prop-types'; 16import { globalError as globalErrorPropType } from '../../prop-types';
17import { termsBase } from '../../api/apiBase';
17 18
18const messages = defineMessages({ 19const messages = defineMessages({
19 headline: { 20 headline: {
diff --git a/src/environment.js b/src/environment.js
index a6ad75820..7b560acb6 100644
--- a/src/environment.js
+++ b/src/environment.js
@@ -17,7 +17,6 @@ import {
17 DEV_WS_API, 17 DEV_WS_API,
18 LOCAL_TODOS_FRONTEND_URL, 18 LOCAL_TODOS_FRONTEND_URL,
19 PRODUCTION_TODOS_FRONTEND_URL, 19 PRODUCTION_TODOS_FRONTEND_URL,
20 LIVE_FRANZ_API,
21 DEFAULT_TODO_SERVICE, 20 DEFAULT_TODO_SERVICE,
22 SEARCH_ENGINE_DDG, 21 SEARCH_ENGINE_DDG,
23 iconSizeBias, 22 iconSizeBias,
@@ -56,7 +55,8 @@ export const SETTINGS_PATH = path.join(app.getPath('userData'), 'config');
56// Replacing app.asar is not beautiful but unfortunately necessary 55// Replacing app.asar is not beautiful but unfortunately necessary
57export const RECIPES_PATH = asarPath(path.join(__dirname, 'recipes')); 56export const RECIPES_PATH = asarPath(path.join(__dirname, 'recipes'));
58 57
59export const useLiveAPI = process.env.LIVE_API; 58export const useLiveAPI = process.env.USE_LIVE_API;
59const useLocalAPI = process.env.USE_LOCAL_API;
60 60
61export const isMac = is.macos; 61export const isMac = is.macos;
62export const isWindows = is.windows; 62export const isWindows = is.windows;
@@ -75,12 +75,10 @@ let web;
75let todos; 75let todos;
76if (!isDevMode || (isDevMode && useLiveAPI)) { 76if (!isDevMode || (isDevMode && useLiveAPI)) {
77 api = LIVE_FERDI_API; 77 api = LIVE_FERDI_API;
78 // api = DEV_FRANZ_API;
79 wsApi = LIVE_WS_API; 78 wsApi = LIVE_WS_API;
80 web = LIVE_API_FERDI_WEBSITE; 79 web = LIVE_API_FERDI_WEBSITE;
81 // web = DEV_API_FRANZ_WEBSITE;
82 todos = PRODUCTION_TODOS_FRONTEND_URL; 80 todos = PRODUCTION_TODOS_FRONTEND_URL;
83} else if (isDevMode && process.env.LOCAL_API) { 81} else if (isDevMode && useLocalAPI) {
84 api = LOCAL_API; 82 api = LOCAL_API;
85 wsApi = LOCAL_WS_API; 83 wsApi = LOCAL_WS_API;
86 web = LOCAL_API_WEBSITE; 84 web = LOCAL_API_WEBSITE;
@@ -152,10 +150,6 @@ export const DEFAULT_APP_SETTINGS = {
152 alwaysShowWorkspaces: false, 150 alwaysShowWorkspaces: false,
153}; 151};
154 152
155export function termsBase() {
156 return window.ferdi.stores.settings.all.app.server !== LIVE_FRANZ_API ? window.ferdi.stores.settings.all.app.server : DEV_API_FRANZ_WEBSITE;
157}
158
159export function aboutAppDetails() { 153export function aboutAppDetails() {
160 return [ 154 return [
161 `Version: ${ferdiVersion}`, 155 `Version: ${ferdiVersion}`,
diff --git a/src/lib/Menu.js b/src/lib/Menu.js
index 89e6e0e0b..2f918dcb0 100644
--- a/src/lib/Menu.js
+++ b/src/lib/Menu.js
@@ -6,7 +6,7 @@ import { autorun, observable } from 'mobx';
6import { defineMessages } from 'react-intl'; 6import { defineMessages } from 'react-intl';
7import { CUSTOM_WEBSITE_RECIPE_ID, GITHUB_FERDI_URL, LIVE_API_FERDI_WEBSITE } from '../config'; 7import { CUSTOM_WEBSITE_RECIPE_ID, GITHUB_FERDI_URL, LIVE_API_FERDI_WEBSITE } from '../config';
8import { 8import {
9 cmdKey, isLinux, isMac, aboutAppDetails, termsBase, 9 cmdKey, isLinux, isMac, aboutAppDetails,
10} from '../environment'; 10} from '../environment';
11import { announcementsStore } from '../features/announcements'; 11import { announcementsStore } from '../features/announcements';
12import { announcementActions } from '../features/announcements/actions'; 12import { announcementActions } from '../features/announcements/actions';
@@ -14,6 +14,7 @@ import { todosStore } from '../features/todos';
14import { todoActions } from '../features/todos/actions'; 14import { todoActions } from '../features/todos/actions';
15import { workspaceActions } from '../features/workspaces/actions'; 15import { workspaceActions } from '../features/workspaces/actions';
16import { workspaceStore } from '../features/workspaces/index'; 16import { workspaceStore } from '../features/workspaces/index';
17import { termsBase } from '../api/apiBase';
17 18
18const menuItems = defineMessages({ 19const menuItems = defineMessages({
19 edit: { 20 edit: {