diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/package.js | 28 | ||||
-rw-r--r-- | scripts/sample_recipe/package.json | 5 |
2 files changed, 28 insertions, 5 deletions
diff --git a/scripts/package.js b/scripts/package.js index b7d6a7f..8410247 100644 --- a/scripts/package.js +++ b/scripts/package.js | |||
@@ -112,6 +112,33 @@ const compress = (src, dest) => new Promise((resolve, reject) => { | |||
112 | configErrors.push("The recipe's package.json contains no 'config' object. This field should contain a configuration for your service."); | 112 | configErrors.push("The recipe's package.json contains no 'config' object. This field should contain a configuration for your service."); |
113 | } | 113 | } |
114 | 114 | ||
115 | const topLevelKeys = Object.keys(config); | ||
116 | topLevelKeys.forEach(key => { | ||
117 | if (typeof(config[key]) === 'string' && config[key] === '') { | ||
118 | configErrors.push(`The recipe's package.json contains empty value for key: ${key}`); | ||
119 | } | ||
120 | }); | ||
121 | |||
122 | const knownTopLevelKeys = ['id', 'name', 'version', 'license', 'repository', 'config']; | ||
123 | const unrecognizedKeys = topLevelKeys.filter(x => !knownTopLevelKeys.includes(x)); | ||
124 | if (unrecognizedKeys.length > 0) { | ||
125 | configErrors.push(`The recipe's package.json contains the following keys that are not recognized: ${unrecognizedKeys}`); | ||
126 | } | ||
127 | if (config.config && typeof config.config === "object") { | ||
128 | const configKeys = Object.keys(config.config); | ||
129 | const knownConfigKeys = ['serviceURL', 'hasTeamId', 'urlInputPrefix', 'urlInputSuffix', 'hasHostedOption', 'hasCustomUrl', 'hasNotificationSound', 'hasDirectMessages', 'hasIndirectMessages', 'message', 'disablewebsecurity']; | ||
130 | const unrecognizedConfigKeys = configKeys.filter(x => !knownConfigKeys.includes(x)); | ||
131 | if (unrecognizedConfigKeys.length > 0) { | ||
132 | configErrors.push(`The recipe's package.json contains the following keys that are not recognized: ${unrecognizedConfigKeys}`); | ||
133 | } | ||
134 | |||
135 | configKeys.forEach(key => { | ||
136 | if (typeof(config.config[key]) === 'string' && config.config[key] === '') { | ||
137 | configErrors.push(`The recipe's package.json contains empty value for key: ${key}`); | ||
138 | } | ||
139 | }); | ||
140 | } | ||
141 | |||
115 | if (isGitRepo) { | 142 | if (isGitRepo) { |
116 | const relativeRepoSrc = path.relative(repoRoot, recipeSrc); | 143 | const relativeRepoSrc = path.relative(repoRoot, recipeSrc); |
117 | 144 | ||
@@ -158,7 +185,6 @@ const compress = (src, dest) => new Promise((resolve, reject) => { | |||
158 | // Add recipe to all.json | 185 | // Add recipe to all.json |
159 | const isFeatured = featuredRecipes.includes(config.id); | 186 | const isFeatured = featuredRecipes.includes(config.id); |
160 | const packageInfo = { | 187 | const packageInfo = { |
161 | "author": config.author || '', | ||
162 | "featured": isFeatured, | 188 | "featured": isFeatured, |
163 | "id": config.id, | 189 | "id": config.id, |
164 | "name": config.name, | 190 | "name": config.name, |
diff --git a/scripts/sample_recipe/package.json b/scripts/sample_recipe/package.json index af522db..6481f95 100644 --- a/scripts/sample_recipe/package.json +++ b/scripts/sample_recipe/package.json | |||
@@ -1,10 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "SERVICE", | 2 | "id": "SERVICE", |
3 | "name": "SNAME", | 3 | "name": "SNAME", |
4 | "version": "1.0.0", | 4 | "version": "1.0.1", |
5 | "description": "SERVICE", | ||
6 | "main": "index.js", | ||
7 | "author": "Ferdi <hello@getferdi.com>", | ||
8 | "license": "MIT", | 5 | "license": "MIT", |
9 | "config": { | 6 | "config": { |
10 | "serviceURL": "https://SERVICE.com" | 7 | "serviceURL": "https://SERVICE.com" |