aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-11-04 19:41:44 +0100
committerLibravatar GitHub <noreply@github.com>2017-11-04 19:41:44 +0100
commit29b710dde2732d1ecf68d27e45a35ef21f518937 (patch)
treec63981a7a4749fc21c9e2dfa1f490052d6a4b157
parentMerge pull request #209 from meetfranz/feature/developer-debug-hosted-recipes (diff)
parentMerge branch 'develop' into feature/harden-franz (diff)
downloadferdium-app-29b710dde2732d1ecf68d27e45a35ef21f518937.tar.gz
ferdium-app-29b710dde2732d1ecf68d27e45a35ef21f518937.tar.zst
ferdium-app-29b710dde2732d1ecf68d27e45a35ef21f518937.zip
Merge pull request #210 from meetfranz/feature/harden-franz
Feature/harden franz
-rw-r--r--src/api/server/ServerApi.js17
-rw-r--r--src/index.js1
-rw-r--r--src/models/Recipe.js3
-rw-r--r--src/models/Service.js7
4 files changed, 21 insertions, 7 deletions
diff --git a/src/api/server/ServerApi.js b/src/api/server/ServerApi.js
index 8b0b7563c..932b70cdc 100644
--- a/src/api/server/ServerApi.js
+++ b/src/api/server/ServerApi.js
@@ -499,7 +499,7 @@ export default class ServerApi {
499 499
500 return recipe; 500 return recipe;
501 }), 501 }),
502 ).catch(err => console.error(err)); 502 ).catch(err => console.error('Can\'t load recipe', err));
503 } 503 }
504 504
505 _mapRecipePreviewModel(recipes) { 505 _mapRecipePreviewModel(recipes) {
@@ -562,9 +562,16 @@ export default class ServerApi {
562 .filter(file => fs.statSync(path.join(recipesDirectory, file)).isDirectory() && file !== 'temp'); 562 .filter(file => fs.statSync(path.join(recipesDirectory, file)).isDirectory() && file !== 'temp');
563 563
564 const recipes = paths.map((id) => { 564 const recipes = paths.map((id) => {
565 // eslint-disable-next-line 565 let Recipe;
566 const Recipe = require(id)(RecipeModel); 566 try {
567 return new Recipe(loadRecipeConfig(id)); 567 // eslint-disable-next-line
568 Recipe = require(id)(RecipeModel);
569 return new Recipe(loadRecipeConfig(id));
570 } catch (err) {
571 console.error(err);
572 }
573
574 return false;
568 }).filter(recipe => recipe.id).map((data) => { 575 }).filter(recipe => recipe.id).map((data) => {
569 const recipe = data; 576 const recipe = data;
570 577
@@ -579,7 +586,7 @@ export default class ServerApi {
579 586
580 return recipes; 587 return recipes;
581 } catch (err) { 588 } catch (err) {
582 console.debug('Folder `recipe/dev` does not exist'); 589 console.debug('Could not load dev recipes');
583 return false; 590 return false;
584 } 591 }
585 } 592 }
diff --git a/src/index.js b/src/index.js
index a72d76f3a..a3aa14732 100644
--- a/src/index.js
+++ b/src/index.js
@@ -18,6 +18,7 @@ let willQuitApp = false;
18 18
19// Ensure that the recipe directory exists 19// Ensure that the recipe directory exists
20fs.ensureDir(path.join(app.getPath('userData'), 'recipes')); 20fs.ensureDir(path.join(app.getPath('userData'), 'recipes'));
21fs.emptyDirSync(path.join(app.getPath('userData'), 'recipes', 'temp'));
21 22
22// Set App ID for Windows 23// Set App ID for Windows
23if (isWindows) { 24if (isWindows) {
diff --git a/src/models/Recipe.js b/src/models/Recipe.js
index 4b613a40c..9971df77c 100644
--- a/src/models/Recipe.js
+++ b/src/models/Recipe.js
@@ -26,7 +26,8 @@ export default class Recipe {
26 } 26 }
27 27
28 if (!data.id) { 28 if (!data.id) {
29 throw Error('Recipe requires Id'); 29 // Franz 4 recipes do not have an Id
30 throw Error(`Recipe '${data.name}' requires Id`);
30 } 31 }
31 32
32 this.id = data.id || this.id; 33 this.id = data.id || this.id;
diff --git a/src/models/Service.js b/src/models/Service.js
index 7a0310ebc..484252e7c 100644
--- a/src/models/Service.js
+++ b/src/models/Service.js
@@ -58,7 +58,12 @@ export default class Service {
58 58
59 @computed get url() { 59 @computed get url() {
60 if (this.recipe.hasCustomUrl && this.customUrl) { 60 if (this.recipe.hasCustomUrl && this.customUrl) {
61 let url = normalizeUrl(this.customUrl); 61 let url;
62 try {
63 url = normalizeUrl(this.customUrl);
64 } catch (err) {
65 console.error(`Service (${this.recipe.name}): '${this.customUrl}' is not a valid Url.`);
66 }
62 67
63 if (typeof this.recipe.buildUrl === 'function') { 68 if (typeof this.recipe.buildUrl === 'function') {
64 url = this.recipe.buildUrl(url); 69 url = this.recipe.buildUrl(url);