* Validates images for marketplace themes * @private * @returns {boolean[]}
()
| 232 | * @returns {boolean[]} |
| 233 | */ |
| 234 | async _validateMetaImages() { |
| 235 | const { meta, variations } = await this.themeConfig.getConfig(); |
| 236 | const composedImagePath = path.resolve(this.themePath, 'meta', meta.composed_image); |
| 237 | const imageTasks = []; |
| 238 | if (!this._isValidImageType(composedImagePath)) { |
| 239 | throw new Error( |
| 240 | 'Invalid file type for "meta.composed_image".'.red + |
| 241 | `\r\nValid types (${VALID_IMAGE_TYPES.join(', ')})`.red, |
| 242 | ); |
| 243 | } |
| 244 | if (!fs.existsSync(composedImagePath)) { |
| 245 | throw new Error( |
| 246 | 'The path you specified for your "meta.composed_image" does not exist.'.red, |
| 247 | ); |
| 248 | } |
| 249 | imageTasks.push((cb) => |
| 250 | this._validateImage(composedImagePath, WIDTH_COMPOSED, HEIGHT_COMPOSED, cb), |
| 251 | ); |
| 252 | for (const variation of variations) { |
| 253 | const id = variation.id.blue; |
| 254 | const desktopScreenshotPath = path.resolve( |
| 255 | this.themePath, |
| 256 | 'meta', |
| 257 | variation.meta.desktop_screenshot, |
| 258 | ); |
| 259 | if (!this._isValidImageType(desktopScreenshotPath)) { |
| 260 | throw new Error( |
| 261 | `Invalid file type for ${id} variation's "desktop_screenshot".`.red + |
| 262 | `\r\nValid types (${VALID_IMAGE_TYPES.join(', ')})`.red, |
| 263 | ); |
| 264 | } |
| 265 | if (!fs.existsSync(desktopScreenshotPath)) { |
| 266 | throw new Error( |
| 267 | `The path you specified for the ${id} variation's "desktop_screenshot" does not exist.`.red, |
| 268 | ); |
| 269 | } |
| 270 | imageTasks.push((cb) => |
| 271 | this._validateImage(desktopScreenshotPath, WIDTH_DESKTOP, HEIGHT_DESKTOP, cb), |
| 272 | ); |
| 273 | const mobileScreenshotPath = path.resolve( |
| 274 | this.themePath, |
| 275 | 'meta', |
| 276 | variation.meta.mobile_screenshot, |
| 277 | ); |
| 278 | if (!this._isValidImageType(mobileScreenshotPath)) { |
| 279 | throw new Error( |
| 280 | `Invalid file type for ${id} variation's "mobile_screenshot".`.red + |
| 281 | `\r\nValid types (${VALID_IMAGE_TYPES.join(', ')})`.red, |
| 282 | ); |
| 283 | } |
| 284 | if (!fs.existsSync(mobileScreenshotPath)) { |
| 285 | throw new Error( |
| 286 | `The path you specified for the ${id} variation's "mobile_screenshot" does not exist.`.red, |
| 287 | ); |
| 288 | } |
| 289 | imageTasks.push((cb) => |
| 290 | this._validateImage(mobileScreenshotPath, WIDTH_MOBILE, HEIGHT_MOBILE, cb), |
| 291 | ); |
nothing calls this directly
no test coverage detected