homey-lib 2.22.1 → 2.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1037,6 +1037,17 @@
1037
1037
  ]
1038
1038
  }
1039
1039
  },
1040
+ "platformLocalRequiredFeatures": {
1041
+ "type": "array",
1042
+ "items": {
1043
+ "type": "string",
1044
+ "enum": [
1045
+ "nfc",
1046
+ "speaker",
1047
+ "ledring"
1048
+ ]
1049
+ }
1050
+ },
1040
1051
  "tags": {
1041
1052
  "$ref": "#/definitions/i18nArray"
1042
1053
  },
package/lib/App/index.js CHANGED
@@ -127,6 +127,18 @@ class App {
127
127
  }
128
128
  }
129
129
 
130
+ // validate that there are no platform local required features defined when targetting cloud
131
+ if ((appJson.platforms || []).includes('cloud')
132
+ && (appJson.platformLocalRequiredFeatures || []).length > 0) {
133
+ throw new Error('The property `platformLocalRequiredFeatures` can not be used in combination with platform: `cloud`.');
134
+ }
135
+
136
+ // validate that platforms includes local when using platformLocalRequiredFeatures
137
+ if ((appJson.platforms || []).includes('local') === false
138
+ && (appJson.platformLocalRequiredFeatures || []).length > 0) {
139
+ console.warn('Warning: using `platformLocalRequiredFeatures` requires `platforms: [local]`.');
140
+ }
141
+
130
142
  if (levelVerified) {
131
143
  if (appJson.platforms === undefined) {
132
144
  throw new Error('The property `platforms` is required in order to publish a verified app.');
@@ -298,7 +310,7 @@ class App {
298
310
  if (!driver.images) {
299
311
  throw new Error(`drivers.${driver.id}: property \`images\` is required in order to publish an app.`);
300
312
  }
301
- await this._validateImages(driver.images, 'driver');
313
+ await this._validateImages(driver.images, 'driver', `drivers.${driver.id}`);
302
314
  }
303
315
 
304
316
  if (levelVerified) {
@@ -560,7 +572,7 @@ class App {
560
572
  }
561
573
  }
562
574
 
563
- async _validateImages(imagesObj, type) {
575
+ async _validateImages(imagesObj, type, errorPath) {
564
576
  const sizes = ['small', 'large'];
565
577
  for (let i = 0; i < sizes.length; i++) {
566
578
  const size = sizes[i];
@@ -568,7 +580,7 @@ class App {
568
580
  const extension = extname(imagePath);
569
581
 
570
582
  if (typeof IMAGE_MARKERS[extension] === 'undefined') {
571
- throw new Error(`Invalid image extention: ${extension}`);
583
+ throw new Error(`Invalid image extension (${extension})${ errorPath ? ` ${errorPath}.${size}` : ''}: ${join(this._path, imagePath)}`);
572
584
  }
573
585
 
574
586
  await this._ensureFileExistsCaseSensitive(imagePath);
@@ -577,14 +589,14 @@ class App {
577
589
  const imageBytes = await this._readBytes(imagePath, compareBuffer.length);
578
590
 
579
591
  if (!imageBytes.equals(compareBuffer)) {
580
- throw new Error(`Invalid image: ${imagePath}`);
592
+ throw new Error(`Invalid image${ errorPath ? ` ${errorPath}.${size}` : ''}: ${join(this._path, imagePath)}`);
581
593
  }
582
594
 
583
595
  const requiredSize = IMAGE_SIZES[type][size];
584
596
  const imageSize = await imageSizeAsync(join(this._path, imagePath));
585
597
  if (imageSize.width !== requiredSize.width
586
598
  || imageSize.height !== requiredSize.height) {
587
- throw new Error(`Invalid image size (${imageSize.width}x${imageSize.height}): ${imagePath}\nRequired: ${requiredSize.width}x${requiredSize.height}`);
599
+ throw new Error(`Invalid image size (${imageSize.width}x${imageSize.height})${ errorPath ? ` ${errorPath}.${size}` : ''}: ${join(this._path, imagePath)}\nRequired: ${requiredSize.width}x${requiredSize.height}`);
588
600
  }
589
601
  }
590
602
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homey-lib",
3
- "version": "2.22.1",
3
+ "version": "2.23.0",
4
4
  "description": "Shared Library for Homey",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -329,8 +329,8 @@ describe('HomeyLib.App#validate() base manifest', function() {
329
329
 
330
330
  await assertValidates(app, {
331
331
  debug: true, // debug does not validate images
332
- publish: /invalid image extention/i,
333
- verified: /invalid image extention/i,
332
+ publish: /invalid image extension/i,
333
+ verified: /invalid image extension/i,
334
334
  });
335
335
  });
336
336
 
@@ -172,8 +172,8 @@ describe('HomeyLib.App#validate() driver manifest', function() {
172
172
 
173
173
  await assertValidates(app, {
174
174
  debug: true, // debug does not validate images
175
- publish: /invalid image extention/i,
176
- verified: /invalid image extention/i,
175
+ publish: /invalid image extension/i,
176
+ verified: /invalid image extension/i,
177
177
  });
178
178
  });
179
179