aboutsummaryrefslogtreecommitdiffstats
path: root/src/models/Recipe.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/models/Recipe.js')
-rw-r--r--src/models/Recipe.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/models/Recipe.js b/src/models/Recipe.js
index 9971df77c..1fc23ac89 100644
--- a/src/models/Recipe.js
+++ b/src/models/Recipe.js
@@ -1,10 +1,11 @@
1import emailParser from 'address-rfc2822'; 1import emailParser from 'address-rfc2822';
2import semver from 'semver';
2 3
3export default class Recipe { 4export default class Recipe {
4 id = ''; 5 id = '';
5 name = ''; 6 name = '';
6 description = ''; 7 description = '';
7 version = '1.0'; 8 version = '';
8 path = ''; 9 path = '';
9 10
10 serviceURL = ''; 11 serviceURL = '';
@@ -15,6 +16,7 @@ export default class Recipe {
15 hasTeamId = false; 16 hasTeamId = false;
16 hasPredefinedUrl = false; 17 hasPredefinedUrl = false;
17 hasCustomUrl = false; 18 hasCustomUrl = false;
19 hasHostedOption = false;
18 urlInputPrefix = ''; 20 urlInputPrefix = '';
19 urlInputSuffix = ''; 21 urlInputSuffix = '';
20 22
@@ -30,6 +32,10 @@ export default class Recipe {
30 throw Error(`Recipe '${data.name}' requires Id`); 32 throw Error(`Recipe '${data.name}' requires Id`);
31 } 33 }
32 34
35 if (!semver.valid(data.version)) {
36 throw Error(`Version ${data.version} of recipe '${data.name}' is not a valid semver version`);
37 }
38
33 this.id = data.id || this.id; 39 this.id = data.id || this.id;
34 this.name = data.name || this.name; 40 this.name = data.name || this.name;
35 this.rawAuthor = data.author || this.author; 41 this.rawAuthor = data.author || this.author;
@@ -45,6 +51,7 @@ export default class Recipe {
45 this.hasTeamId = data.config.hasTeamId || this.hasTeamId; 51 this.hasTeamId = data.config.hasTeamId || this.hasTeamId;
46 this.hasPredefinedUrl = data.config.hasPredefinedUrl || this.hasPredefinedUrl; 52 this.hasPredefinedUrl = data.config.hasPredefinedUrl || this.hasPredefinedUrl;
47 this.hasCustomUrl = data.config.hasCustomUrl || this.hasCustomUrl; 53 this.hasCustomUrl = data.config.hasCustomUrl || this.hasCustomUrl;
54 this.hasHostedOption = data.config.hasHostedOption || this.hasHostedOption;
48 55
49 this.urlInputPrefix = data.config.urlInputPrefix || this.urlInputPrefix; 56 this.urlInputPrefix = data.config.urlInputPrefix || this.urlInputPrefix;
50 this.urlInputSuffix = data.config.urlInputSuffix || this.urlInputSuffix; 57 this.urlInputSuffix = data.config.urlInputSuffix || this.urlInputSuffix;