aboutsummaryrefslogtreecommitdiffstats
path: root/src/models/Recipe.js
diff options
context:
space:
mode:
authorLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-08-17 05:07:38 +0530
committerLibravatar GitHub <noreply@github.com>2021-08-17 05:07:38 +0530
commit0fbee32c27a6efdfe88534303922d189ddbba817 (patch)
tree2b9dddba64ff1519e293c64b3b42b4d9172ec4d3 /src/models/Recipe.js
parentRevert "chore: update outdated node_modules (#1807)" (diff)
downloadferdium-app-0fbee32c27a6efdfe88534303922d189ddbba817.tar.gz
ferdium-app-0fbee32c27a6efdfe88534303922d189ddbba817.tar.zst
ferdium-app-0fbee32c27a6efdfe88534303922d189ddbba817.zip
Typescript conversion (#1805)
Diffstat (limited to 'src/models/Recipe.js')
-rw-r--r--src/models/Recipe.js98
1 files changed, 0 insertions, 98 deletions
diff --git a/src/models/Recipe.js b/src/models/Recipe.js
deleted file mode 100644
index 0d97d4472..000000000
--- a/src/models/Recipe.js
+++ /dev/null
@@ -1,98 +0,0 @@
1import semver from 'semver';
2import { pathExistsSync } from 'fs-extra';
3import { join } from 'path';
4
5export default class Recipe {
6 // Note: Do NOT change these default values. If they change, then the corresponding changes in the recipes needs to be done
7 id = '';
8
9 name = '';
10
11 description = '';
12
13 version = '';
14
15 aliases = [];
16
17 path = '';
18
19 serviceURL = '';
20
21 hasDirectMessages = true;
22
23 hasIndirectMessages = false;
24
25 hasNotificationSound = false;
26
27 hasTeamId = false;
28
29 hasCustomUrl = false;
30
31 hasHostedOption = false;
32
33 urlInputPrefix = '';
34
35 urlInputSuffix = '';
36
37 message = '';
38
39 disablewebsecurity = false;
40
41 autoHibernate = false;
42
43 partition = '';
44
45 constructor(data) {
46 if (!data) {
47 throw Error('Recipe config not valid');
48 }
49
50 if (!data.id) {
51 // Ferdi 4 recipes do not have an Id
52 throw Error(`Recipe '${data.name}' requires Id`);
53 }
54
55 try {
56 if (!semver.valid(data.version)) {
57 throw Error(`Version ${data.version} of recipe '${data.name}' is not a valid semver version`);
58 }
59 } catch (e) {
60 console.warn(e.message);
61 }
62
63 this.id = data.id || this.id;
64 this.name = data.name || this.name;
65 this.version = data.version || this.version;
66 this.aliases = data.aliases || this.aliases;
67 this.path = data.path;
68
69 this.serviceURL = data.config.serviceURL || this.serviceURL;
70
71 this.hasDirectMessages = data.config.hasDirectMessages || this.hasDirectMessages;
72 this.hasIndirectMessages = data.config.hasIndirectMessages || this.hasIndirectMessages;
73 this.hasNotificationSound = data.config.hasNotificationSound || this.hasNotificationSound;
74 this.hasTeamId = data.config.hasTeamId || this.hasTeamId;
75 this.hasCustomUrl = data.config.hasCustomUrl || this.hasCustomUrl;
76 this.hasHostedOption = data.config.hasHostedOption || this.hasHostedOption;
77
78 this.urlInputPrefix = data.config.urlInputPrefix || this.urlInputPrefix;
79 this.urlInputSuffix = data.config.urlInputSuffix || this.urlInputSuffix;
80
81 this.disablewebsecurity = data.config.disablewebsecurity || this.disablewebsecurity;
82
83 this.autoHibernate = data.config.autoHibernate || this.autoHibernate;
84
85 this.partition = data.config.partition || this.partition;
86
87 this.message = data.config.message || this.message;
88 }
89
90 // TODO: Need to remove this if its not used anywhere
91 get author() {
92 return [];
93 }
94
95 get hasDarkMode() {
96 return pathExistsSync(join(this.path, 'darkmode.css'));
97 }
98}