diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/package.js | 26 | ||||
-rw-r--r-- | scripts/sample_recipe/index.js | 3 |
2 files changed, 14 insertions, 15 deletions
diff --git a/scripts/package.js b/scripts/package.js index 4fc02f1..ecf648d 100644 --- a/scripts/package.js +++ b/scripts/package.js | |||
@@ -125,7 +125,7 @@ const compress = (src, dest) => | |||
125 | "The recipe's package.json contains no 'id' field. This field should contain a unique ID made of lowercase letters (a-z), numbers (0-9), hyphens (-), periods (.), and underscores (_)", | 125 | "The recipe's package.json contains no 'id' field. This field should contain a unique ID made of lowercase letters (a-z), numbers (0-9), hyphens (-), periods (.), and underscores (_)", |
126 | ); | 126 | ); |
127 | // eslint-disable-next-line no-useless-escape | 127 | // eslint-disable-next-line no-useless-escape |
128 | } else if (!/^[a-zA-Z0-9._\-]+$/.test(config.id)) { | 128 | } else if (!/^[\w.\-]+$/.test(config.id)) { |
129 | configErrors.push( | 129 | configErrors.push( |
130 | "The recipe's package.json defines an invalid recipe ID. Please make sure the 'id' field only contains lowercase letters (a-z), numbers (0-9), hyphens (-), periods (.), and underscores (_)", | 130 | "The recipe's package.json defines an invalid recipe ID. Please make sure the 'id' field only contains lowercase letters (a-z), numbers (0-9), hyphens (-), periods (.), and underscores (_)", |
131 | ); | 131 | ); |
@@ -152,7 +152,7 @@ const compress = (src, dest) => | |||
152 | } | 152 | } |
153 | 153 | ||
154 | const topLevelKeys = Object.keys(config); | 154 | const topLevelKeys = Object.keys(config); |
155 | topLevelKeys.forEach(key => { | 155 | for (const key of topLevelKeys) { |
156 | if (typeof config[key] === 'string') { | 156 | if (typeof config[key] === 'string') { |
157 | if (config[key] === '') { | 157 | if (config[key] === '') { |
158 | configErrors.push( | 158 | configErrors.push( |
@@ -167,9 +167,9 @@ const compress = (src, dest) => | |||
167 | `The recipe's package.json contains unexpected value for key: ${key}`, | 167 | `The recipe's package.json contains unexpected value for key: ${key}`, |
168 | ); | 168 | ); |
169 | } | 169 | } |
170 | }); | 170 | } |
171 | 171 | ||
172 | const knownTopLevelKeys = [ | 172 | const knownTopLevelKeys = new Set([ |
173 | 'id', | 173 | 'id', |
174 | 'name', | 174 | 'name', |
175 | 'version', | 175 | 'version', |
@@ -177,9 +177,9 @@ const compress = (src, dest) => | |||
177 | 'repository', | 177 | 'repository', |
178 | 'aliases', | 178 | 'aliases', |
179 | 'config', | 179 | 'config', |
180 | ]; | 180 | ]); |
181 | const unrecognizedKeys = topLevelKeys.filter( | 181 | const unrecognizedKeys = topLevelKeys.filter( |
182 | x => !knownTopLevelKeys.includes(x), | 182 | x => !knownTopLevelKeys.has(x), |
183 | ); | 183 | ); |
184 | if (unrecognizedKeys.length > 0) { | 184 | if (unrecognizedKeys.length > 0) { |
185 | configErrors.push( | 185 | configErrors.push( |
@@ -188,7 +188,7 @@ const compress = (src, dest) => | |||
188 | } | 188 | } |
189 | if (config.config && typeof config.config === 'object') { | 189 | if (config.config && typeof config.config === 'object') { |
190 | const configKeys = Object.keys(config.config); | 190 | const configKeys = Object.keys(config.config); |
191 | const knownConfigKeys = [ | 191 | const knownConfigKeys = new Set([ |
192 | 'serviceURL', | 192 | 'serviceURL', |
193 | 'hasTeamId', | 193 | 'hasTeamId', |
194 | 'urlInputPrefix', | 194 | 'urlInputPrefix', |
@@ -201,9 +201,9 @@ const compress = (src, dest) => | |||
201 | 'allowFavoritesDelineationInUnreadCount', | 201 | 'allowFavoritesDelineationInUnreadCount', |
202 | 'message', | 202 | 'message', |
203 | 'disablewebsecurity', | 203 | 'disablewebsecurity', |
204 | ]; | 204 | ]); |
205 | const unrecognizedConfigKeys = configKeys.filter( | 205 | const unrecognizedConfigKeys = configKeys.filter( |
206 | x => !knownConfigKeys.includes(x), | 206 | x => !knownConfigKeys.has(x), |
207 | ); | 207 | ); |
208 | if (unrecognizedConfigKeys.length > 0) { | 208 | if (unrecognizedConfigKeys.length > 0) { |
209 | configErrors.push( | 209 | configErrors.push( |
@@ -215,7 +215,7 @@ const compress = (src, dest) => | |||
215 | // configErrors.push("The recipe's package.json contains both 'hasCustomUrl' and 'hasHostedOption'. Please remove 'hasCustomUrl' since it is overridden by 'hasHostedOption'"); | 215 | // configErrors.push("The recipe's package.json contains both 'hasCustomUrl' and 'hasHostedOption'. Please remove 'hasCustomUrl' since it is overridden by 'hasHostedOption'"); |
216 | // } | 216 | // } |
217 | 217 | ||
218 | configKeys.forEach(key => { | 218 | for (const key of configKeys) { |
219 | if ( | 219 | if ( |
220 | typeof config.config[key] === 'string' && | 220 | typeof config.config[key] === 'string' && |
221 | config.config[key] === '' | 221 | config.config[key] === '' |
@@ -224,7 +224,7 @@ const compress = (src, dest) => | |||
224 | `The recipe's package.json contains empty value for key: ${key}`, | 224 | `The recipe's package.json contains empty value for key: ${key}`, |
225 | ); | 225 | ); |
226 | } | 226 | } |
227 | }); | 227 | } |
228 | } | 228 | } |
229 | 229 | ||
230 | if (isGitRepo) { | 230 | if (isGitRepo) { |
@@ -243,7 +243,7 @@ const compress = (src, dest) => | |||
243 | result.deletions !== 0) | 243 | result.deletions !== 0) |
244 | ) { | 244 | ) { |
245 | const pkgJsonRelative = path.relative(repoRoot, packageJson); | 245 | const pkgJsonRelative = path.relative(repoRoot, packageJson); |
246 | if (!result.files.find(({ file }) => file === pkgJsonRelative)) { | 246 | if (!result.files.some(({ file }) => file === pkgJsonRelative)) { |
247 | configErrors.push( | 247 | configErrors.push( |
248 | `Found changes in '${relativeRepoSrc}' without the corresponding version bump in '${pkgJsonRelative}'`, | 248 | `Found changes in '${relativeRepoSrc}' without the corresponding version bump in '${pkgJsonRelative}'`, |
249 | ); | 249 | ); |
@@ -313,6 +313,6 @@ const compress = (src, dest) => | |||
313 | ); | 313 | ); |
314 | 314 | ||
315 | if (unsuccessful > 0) { | 315 | if (unsuccessful > 0) { |
316 | process.exit(1); | 316 | throw new Error(`One or more recipes couldn't be packaged.`); |
317 | } | 317 | } |
318 | })(); | 318 | })(); |
diff --git a/scripts/sample_recipe/index.js b/scripts/sample_recipe/index.js index 0e52bf0..b947467 100644 --- a/scripts/sample_recipe/index.js +++ b/scripts/sample_recipe/index.js | |||
@@ -1,2 +1 @@ | |||
1 | module.exports = Ferdi => class SCLEAN extends Ferdi { | module.exports = Ferdi => class SCLEAN extends Ferdi {}; | |
2 | }; | ||