@iobroker/repochecker 3.2.3 → 3.2.4

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.
@@ -33,43 +33,42 @@ let requiredJsControllerVersion = '5.0.19';
33
33
  const blacklistIOPackageJson = {
34
34
  installedFrom: {
35
35
  msg: '"installedFrom" is invalid at io-package.json. Please remove.',
36
- err: true
36
+ err: true,
37
37
  },
38
38
  'common.installedFrom': {
39
39
  msg: '"common.installedFrom" is invalid. Please remove from io-package.json.',
40
- err: true
40
+ err: true,
41
41
  },
42
42
  'common.title': {
43
43
  msg: '"common.title" is deprecated and replaced by "common.titleLang". Please remove from io-package.json.',
44
- err: false
44
+ err: false,
45
45
  },
46
46
  'common.main': {
47
47
  msg: '"common.main" is deprecated and ignored. Please remove from io-package.json. Executable is defined by entry "main" at package.json.',
48
- err: false
48
+ err: false,
49
49
  },
50
50
  'common.materialize': {
51
51
  msg: '"common.materialize" is deprecated for admin >= 5 at io-package.json. Please use property "adminUI".',
52
- err: false
52
+ err: false,
53
53
  },
54
54
  'common.materializeTab': {
55
55
  msg: '"common.materializeTab" is deprecated for admin >= 5 at io-package.json. Please use property "adminUI".',
56
- err: false
56
+ err: false,
57
57
  },
58
58
  'common.noConfig': {
59
59
  msg: '"common.noConfig" is deprecated for admin >= 5 at io-package.json. Please use property "adminUI.config":"none".',
60
- err: false
60
+ err: false,
61
61
  },
62
62
  'common.subscribe': {
63
63
  msg: '"common.subscribe" will be removed with js-controller >= 6. Please remove from io-package.json and adapt code if required.',
64
- err: true
64
+ err: true,
65
65
  },
66
66
  'common.wakeup': {
67
67
  msg: '"common.wakeup" is deprecated and ignored. Please remove from io-package.json.',
68
- err: true
68
+ err: true,
69
69
  },
70
70
  };
71
71
 
72
-
73
72
  async function checkIOPackageJson(context) {
74
73
  console.log('\ncheckIOPackage [E100 - E249]');
75
74
 
@@ -104,571 +103,719 @@ async function checkIOPackageJson(context) {
104
103
 
105
104
  if (suspiciousKeys.length) {
106
105
  if (context.ioPackageJson.protectedNative) {
107
- const missingProtected = suspiciousKeys.filter(key => !context.ioPackageJson.protectedNative.includes(key));
108
- if (missingProtected.length) context.warnings.push(`[W173] Potential sensitive data "${missingProtected.join()}" not listed at "protectedNative" in io-package.json`);
106
+ const missingProtected = suspiciousKeys.filter(
107
+ key => !context.ioPackageJson.protectedNative.includes(key),
108
+ );
109
+ if (missingProtected.length) {
110
+ context.warnings.push(
111
+ `[W173] Potential sensitive data "${missingProtected.join()}" not listed at "protectedNative" in io-package.json`,
112
+ );
113
+ }
109
114
  } else {
110
- context.warnings.push(`[W173] Potential sensitive data "${suspiciousKeys.join()}" not listed at "protectedNative" in io-package.json`);
115
+ context.warnings.push(
116
+ `[W173] Potential sensitive data "${suspiciousKeys.join()}" not listed at "protectedNative" in io-package.json`,
117
+ );
111
118
  }
112
119
 
113
120
  if (context.ioPackageJson.encryptedNative) {
114
- const missingProtected = suspiciousKeys.filter(key => !context.ioPackageJson.encryptedNative.includes(key));
115
- if (missingProtected.length) context.warnings.push(`[W174] Potential sensitive data "${missingProtected.join()}" not listed at "encryptedNative" in io-package.json`);
121
+ const missingProtected = suspiciousKeys.filter(
122
+ key => !context.ioPackageJson.encryptedNative.includes(key),
123
+ );
124
+ if (missingProtected.length) {
125
+ context.warnings.push(
126
+ `[W174] Potential sensitive data "${missingProtected.join()}" not listed at "encryptedNative" in io-package.json`,
127
+ );
128
+ }
116
129
  } else {
117
- context.warnings.push(`[W174] Potential sensitive data "${suspiciousKeys.join()}" not listed at "encryptedNative" in io-package.json`);
130
+ context.warnings.push(
131
+ `[W174] Potential sensitive data "${suspiciousKeys.join()}" not listed at "encryptedNative" in io-package.json`,
132
+ );
118
133
  }
119
134
  }
120
135
  }
121
136
 
122
137
  if (!context.ioPackageJson.common) {
123
138
  context.errors.push('[E102] io-package.json must have common object');
124
- return (context);
139
+ return context;
140
+ }
141
+ context.checks.push('"common" found in io-package.json');
142
+ if (!context.ioPackageJson.common.name || context.ioPackageJson.common.name !== context.adapterName.toLowerCase()) {
143
+ context.errors.push(
144
+ `[E103] "common.name" in io-package.json must be equal to "${context.adapterName.toLowerCase()}'". Now is ${context.ioPackageJson.common.name}`,
145
+ );
125
146
  } else {
126
- context.checks.push('"common" found in io-package.json');
127
- if (!context.ioPackageJson.common.name || context.ioPackageJson.common.name !== context.adapterName.toLowerCase()) {
128
- context.errors.push(`[E103] "common.name" in io-package.json must be equal to "${context.adapterName.toLowerCase()}'". Now is ${context.ioPackageJson.common.name}`);
129
- } else {
130
- context.checks.push('"common.name" is valid in io-package.json');
131
- }
132
-
133
- // /*
134
- // if (context.ioPackageJson.common.title) {
135
- // context.warnings.push('[W158] "common.title" is deprecated in io-package.json. Please remove from io-package.json.');
136
- // }
137
-
138
- // if (context.ioPackageJson.common.main) {
139
- // context.warnings.push('[W177] "common.main" is deprecated in io-package.json. For js-controller >= 3.3 please use package.json main and remove "common.main" from io-package.json.');
140
- // }
141
-
142
- // if (context.ioPackageJson.common.materialize) {
143
- // context.warnings.push('[W178] "common.materialize" is deprecated in io-package.json. For admin version >= 5 please use the property "common.adminUI"');
144
- // }
147
+ context.checks.push('"common.name" is valid in io-package.json');
148
+ }
145
149
 
146
- // if (context.ioPackageJson.common.materializeTab) {
147
- // context.warnings.push('[W179] "common.materializeTab" is deprecated in io-package.json. For admin version >= 5 please use the property "common.adminUI".');
148
- // }
150
+ // /*
151
+ // if (context.ioPackageJson.common.title) {
152
+ // context.warnings.push('[W158] "common.title" is deprecated in io-package.json. Please remove from io-package.json.');
153
+ // }
154
+
155
+ // if (context.ioPackageJson.common.main) {
156
+ // context.warnings.push('[W177] "common.main" is deprecated in io-package.json. For js-controller >= 3.3 please use package.json main and remove "common.main" from io-package.json.');
157
+ // }
158
+
159
+ // if (context.ioPackageJson.common.materialize) {
160
+ // context.warnings.push('[W178] "common.materialize" is deprecated in io-package.json. For admin version >= 5 please use the property "common.adminUI"');
161
+ // }
162
+
163
+ // if (context.ioPackageJson.common.materializeTab) {
164
+ // context.warnings.push('[W179] "common.materializeTab" is deprecated in io-package.json. For admin version >= 5 please use the property "common.adminUI".');
165
+ // }
166
+
167
+ // if (context.ioPackageJson.common.noConfig) {
168
+ // context.warnings.push('[W180] "common.noConfig" is deprecated in io-package.json. For admin version >= 5 please use "common.adminUI.config":"none".');
169
+ // }
170
+ // */
171
+ if (!context.ioPackageJson.common.titleLang) {
172
+ context.errors.push('[E104] No "common.titleLang" found in io-package.json');
173
+ } else {
174
+ context.checks.push('"common.titleLang" found in io-package.json');
149
175
 
150
- // if (context.ioPackageJson.common.noConfig) {
151
- // context.warnings.push('[W180] "common.noConfig" is deprecated in io-package.json. For admin version >= 5 please use "common.adminUI.config":"none".');
152
- // }
153
- // */
154
- if (!context.ioPackageJson.common.titleLang) {
155
- context.errors.push('[E104] No "common.titleLang" found in io-package.json');
176
+ if (typeof context.ioPackageJson.common.titleLang !== 'object') {
177
+ context.errors.push(
178
+ `[E105] "common.titleLang" must be an object. Now: ${JSON.stringify(context.ioPackageJson.common.titleLang)}`,
179
+ );
156
180
  } else {
157
- context.checks.push('"common.titleLang" found in io-package.json');
158
-
159
- if (typeof context.ioPackageJson.common.titleLang !== 'object') {
160
- context.errors.push(`[E105] "common.titleLang" must be an object. Now: ${JSON.stringify(context.ioPackageJson.common.titleLang)}`);
161
- } else {
162
- let missingLang = common.checkLanguages(context.ioPackageJson.common.titleLang, context.cfg.requiredLanguages);
163
- if (missingLang.length) {
164
- context.errors.push(`[E126] Missing mandatory translation into ${missingLang.join()} of "common.titleLang" in io-package.json.`);
165
- }
166
-
167
- missingLang = common.checkLanguages(context.ioPackageJson.common.titleLang, context.cfg.allowedLanguages);
168
- missingLang = missingLang.filter(lang => !context.cfg.requiredLanguages.includes(lang));
169
- if (missingLang.length) {
170
- missingLang = [... new Set(missingLang)]; // make unique
171
- context.warnings.push(`[W127] Missing suggested translation into ${missingLang.join()} of "common.titleLang" in io-package.json.`);
172
- }
181
+ let missingLang = common.checkLanguages(
182
+ context.ioPackageJson.common.titleLang,
183
+ context.cfg.requiredLanguages,
184
+ );
185
+ if (missingLang.length) {
186
+ context.errors.push(
187
+ `[E126] Missing mandatory translation into ${missingLang.join()} of "common.titleLang" in io-package.json.`,
188
+ );
173
189
  }
174
190
 
175
- Object.keys(context.ioPackageJson.common.titleLang).forEach(lang => {
176
- const text = context.ioPackageJson.common.titleLang[lang];
177
- if (text.match(/iobroker/i)) {
178
- context.errors.push(`[E106] "common.titleLang" must not have ioBroker in the name. It is clear, for what this adapter was created. Now: ${JSON.stringify(context.ioPackageJson.common.titleLang)}`);
179
- } else {
180
- context.checks.push('"common.titleLang" has no ioBroker in it in io-package.json');
181
- }
182
-
183
- if (text.match(/\sadapter|adapter\s/i)) {
184
- context.warnings.push(`[W128] "common.titleLang" should not contain word "adapter" in the name. It is clear, that this is adapter. Now: ${JSON.stringify(context.ioPackageJson.common.titleLang)}`);
185
- } else {
186
- context.checks.push('"common.titleLang" has no "adapter" in it in io-package.json');
187
- }
188
- });
191
+ missingLang = common.checkLanguages(context.ioPackageJson.common.titleLang, context.cfg.allowedLanguages);
192
+ missingLang = missingLang.filter(lang => !context.cfg.requiredLanguages.includes(lang));
193
+ if (missingLang.length) {
194
+ missingLang = [...new Set(missingLang)]; // make unique
195
+ context.warnings.push(
196
+ `[W127] Missing suggested translation into ${missingLang.join()} of "common.titleLang" in io-package.json.`,
197
+ );
198
+ }
189
199
  }
190
200
 
191
- if (!context.ioPackageJson.common.version) {
192
- context.errors.push('[E107] No "common.version" found in io-package.json');
193
- } else {
194
- context.checks.push('"common.version" found in io-package.json');
195
-
196
- if (!context.packageJson || context.ioPackageJson.common.version !== context.packageJson.version) {
197
- context.errors.push('[E118] Versions in package.json and in io-package.json are different');
201
+ Object.keys(context.ioPackageJson.common.titleLang).forEach(lang => {
202
+ const text = context.ioPackageJson.common.titleLang[lang];
203
+ if (text.match(/iobroker/i)) {
204
+ context.errors.push(
205
+ `[E106] "common.titleLang" must not have ioBroker in the name. It is clear, for what this adapter was created. Now: ${JSON.stringify(context.ioPackageJson.common.titleLang)}`,
206
+ );
198
207
  } else {
199
- context.checks.push('"common.version" is equal in package.json adn in io-package.json');
208
+ context.checks.push('"common.titleLang" has no ioBroker in it in io-package.json');
200
209
  }
201
- }
202
-
203
- if (!context.ioPackageJson.common.desc) {
204
- context.errors.push('[E108] No "common.desc" found in io-package.json');
205
- } else {
206
- context.checks.push('"common.desc" found in io-package.json');
207
210
 
208
- if (typeof context.ioPackageJson.common.desc !== 'object') {
209
- context.errors.push(`[E109] "common.desc" in io-package.json must be an object for many languages. Found only "${context.ioPackageJson.common.desc}"`);
211
+ if (text.match(/\sadapter|adapter\s/i)) {
212
+ context.warnings.push(
213
+ `[W128] "common.titleLang" should not contain word "adapter" in the name. It is clear, that this is adapter. Now: ${JSON.stringify(context.ioPackageJson.common.titleLang)}`,
214
+ );
210
215
  } else {
216
+ context.checks.push('"common.titleLang" has no "adapter" in it in io-package.json');
217
+ }
218
+ });
219
+ }
211
220
 
212
- let missingLang = common.checkLanguages(context.ioPackageJson.common.desc, context.cfg.requiredLanguages);
213
- if (missingLang.length) {
214
- context.errors.push(`[E133] Missing mandatory translation into ${missingLang.join()} of "common.desc" in io-package.json.`);
215
- }
221
+ if (!context.ioPackageJson.common.version) {
222
+ context.errors.push('[E107] No "common.version" found in io-package.json');
223
+ } else {
224
+ context.checks.push('"common.version" found in io-package.json');
216
225
 
217
- missingLang = common.checkLanguages(context.ioPackageJson.common.desc, context.cfg.allowedLanguages);
218
- missingLang = missingLang.filter(lang => !context.cfg.requiredLanguages.includes(lang));
219
- if (missingLang.length) {
220
- missingLang = [... new Set(missingLang)]; // make unique
221
- context.warnings.push(`[W134] Missing suggested translation into ${missingLang.join()} of "common.desc" in io-package.json.`);
222
- }
223
- }
226
+ if (!context.packageJson || context.ioPackageJson.common.version !== context.packageJson.version) {
227
+ context.errors.push('[E118] Versions in package.json and in io-package.json are different');
228
+ } else {
229
+ context.checks.push('"common.version" is equal in package.json adn in io-package.json');
224
230
  }
231
+ }
225
232
 
226
- if (!context.ioPackageJson.common.keywords) {
227
- context.errors.push('[E169] "common.keywords" must be an array within io-package.json and contain some useful keywords');
233
+ if (!context.ioPackageJson.common.desc) {
234
+ context.errors.push('[E108] No "common.desc" found in io-package.json');
235
+ } else {
236
+ context.checks.push('"common.desc" found in io-package.json');
237
+
238
+ if (typeof context.ioPackageJson.common.desc !== 'object') {
239
+ context.errors.push(
240
+ `[E109] "common.desc" in io-package.json must be an object for many languages. Found only "${context.ioPackageJson.common.desc}"`,
241
+ );
228
242
  } else {
229
- const forbiddenKeywords = ['iobroker', 'adapter', 'smart home'];
230
- if (!Array.isArray(context.ioPackageJson.common.keywords)) {
231
- context.errors.push('[E169] "common.keywords" must be an array within io-package.json and contain some useful keywords');
232
- } else if (context.ioPackageJson.common.keywords.length === 0) {
233
- context.errors.push('[E169] "common.keywords" must be an array within io-package.json and contain some useful keywords');
234
- } else if (forbiddenKeywords.filter(keyword => context.ioPackageJson.common.keywords.map(k => k.toLowerCase()).includes(keyword)).length > 0) {
235
- context.warnings.push(`[W168] "common.keywords" should not contain "${forbiddenKeywords.join(', ')}" io-package.json`);
243
+ let missingLang = common.checkLanguages(context.ioPackageJson.common.desc, context.cfg.requiredLanguages);
244
+ if (missingLang.length) {
245
+ context.errors.push(
246
+ `[E133] Missing mandatory translation into ${missingLang.join()} of "common.desc" in io-package.json.`,
247
+ );
236
248
  }
237
249
 
238
- context.checks.push('"common.keywords" found in io-package.json');
250
+ missingLang = common.checkLanguages(context.ioPackageJson.common.desc, context.cfg.allowedLanguages);
251
+ missingLang = missingLang.filter(lang => !context.cfg.requiredLanguages.includes(lang));
252
+ if (missingLang.length) {
253
+ missingLang = [...new Set(missingLang)]; // make unique
254
+ context.warnings.push(
255
+ `[W134] Missing suggested translation into ${missingLang.join()} of "common.desc" in io-package.json.`,
256
+ );
257
+ }
239
258
  }
259
+ }
240
260
 
241
- if (!context.ioPackageJson.common.icon) {
242
- context.errors.push('[E110] Icon not found in the io-package.json');
243
- } else {
244
- context.checks.push('"common.icon" found in io-package.json');
261
+ if (!context.ioPackageJson.common.keywords) {
262
+ context.errors.push(
263
+ '[E169] "common.keywords" must be an array within io-package.json and contain some useful keywords',
264
+ );
265
+ } else {
266
+ const forbiddenKeywords = ['iobroker', 'adapter', 'smart home'];
267
+ if (!Array.isArray(context.ioPackageJson.common.keywords)) {
268
+ context.errors.push(
269
+ '[E169] "common.keywords" must be an array within io-package.json and contain some useful keywords',
270
+ );
271
+ } else if (context.ioPackageJson.common.keywords.length === 0) {
272
+ context.errors.push(
273
+ '[E169] "common.keywords" must be an array within io-package.json and contain some useful keywords',
274
+ );
275
+ } else if (
276
+ forbiddenKeywords.filter(keyword =>
277
+ context.ioPackageJson.common.keywords.map(k => k.toLowerCase()).includes(keyword),
278
+ ).length > 0
279
+ ) {
280
+ context.warnings.push(
281
+ `[W168] "common.keywords" should not contain "${forbiddenKeywords.join(', ')}" io-package.json`,
282
+ );
245
283
  }
246
284
 
247
- if (!context.ioPackageJson.common.extIcon) {
248
- context.errors.push('[E111] extIcon not found in the io-package.json');
249
- } else {
250
- context.checks.push('"common.extIcon" found in io-package.json');
285
+ context.checks.push('"common.keywords" found in io-package.json');
286
+ }
251
287
 
252
- // extract icon name
253
- let fileName = context.ioPackageJson.common.extIcon;
254
- let pos = fileName.indexOf('?');
288
+ if (!context.ioPackageJson.common.icon) {
289
+ context.errors.push('[E110] Icon not found in the io-package.json');
290
+ } else {
291
+ context.checks.push('"common.icon" found in io-package.json');
292
+ }
255
293
 
256
- if (pos !== -1) {
257
- fileName = fileName.substring(0, pos);
258
- }
259
- pos = fileName.lastIndexOf('/');
260
- fileName = fileName.substring(pos + 1, fileName.length);
294
+ if (!context.ioPackageJson.common.extIcon) {
295
+ context.errors.push('[E111] extIcon not found in the io-package.json');
296
+ } else {
297
+ context.checks.push('"common.extIcon" found in io-package.json');
261
298
 
262
- if (fileName !== context.ioPackageJson.common.icon) {
263
- context.errors.push('[E112] extIcon must be the same as an icon but with github path');
264
- } else {
265
- context.checks.push('"common.extIcon" has same path as repo in io-package.json');
266
- }
267
- }
299
+ // extract icon name
300
+ let fileName = context.ioPackageJson.common.extIcon;
301
+ let pos = fileName.indexOf('?');
268
302
 
269
- if (!context.ioPackageJson.common.compact && !context.ioPackageJson.common.onlyWWW) {
270
- if (context.ioPackageJson.common.compact === undefined) {
271
- context.warnings.push('[W113] Please test whether adapter can support compact mode, if not set "common.compact:false" at io-package.json');
272
- } else {
273
- context.warnings.push('[S139] Please evaluate whether adapter can be modified to support compact mode');
274
- }
275
- } else if (!context.ioPackageJson.common.onlyWWW) {
276
- context.checks.push('"common.compact" found in io-package.json');
303
+ if (pos !== -1) {
304
+ fileName = fileName.substring(0, pos);
277
305
  }
306
+ pos = fileName.lastIndexOf('/');
307
+ fileName = fileName.substring(pos + 1, fileName.length);
278
308
 
279
- if (context.ioPackageJson.common.noConfig &&
280
- (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config !== 'none')
281
- ) {
282
- context.errors.push('[E114] "common.noConfig=true" requires "common.adminUI.config" to be set to "none"');
283
- }
284
- if (!context.ioPackageJson.common.materialize &&
285
- !(context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'json') &&
286
- !(context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'materialize') &&
287
- !(context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'html') &&
288
- !(context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'none')
289
- ) {
290
- context.errors.push('[E129] Admin support not specified. Please add "common.adminUI.config = json|materialize|html|none"');
309
+ if (fileName !== context.ioPackageJson.common.icon) {
310
+ context.errors.push('[E112] extIcon must be the same as an icon but with github path');
291
311
  } else {
292
- context.checks.push('"common.materialize" or valid "common.adminUI.config:xxx" found in io-package.json');
293
- }
294
-
295
- if (context.ioPackageJson.common.license) {
296
- context.warnings.push('[W181] "common.license" in io-package.json is deprecated. Please define object "common.licenseInformation"');
312
+ context.checks.push('"common.extIcon" has same path as repo in io-package.json');
297
313
  }
314
+ }
298
315
 
299
- if (!context.ioPackageJson.common.licenseInformation) {
300
- if (!context.ioPackageJson.common.license) {
301
- context.errors.push('[E115] "common.licenseInformation" not found in io-package.json');
302
- }
316
+ if (!context.ioPackageJson.common.compact && !context.ioPackageJson.common.onlyWWW) {
317
+ if (context.ioPackageJson.common.compact === undefined) {
318
+ context.warnings.push(
319
+ '[W113] Please test whether adapter can support compact mode, if not set "common.compact:false" at io-package.json',
320
+ );
303
321
  } else {
304
- context.checks.push('"common.licenseInformation" found in io-package.json');
305
-
306
- if (context.ioPackageJson.common.license) {
307
- context.errors.push('[E182] Please remove "common.license" from io-package.json as "common.licenseInformation" is declared.');
308
- }
309
-
310
- // check if license valid
311
- if (!context.ioPackageJson.common.licenseInformation.license) {
312
- context.errors.push('[E183] "common.licenseInformation.license" is missing');
313
- } else if (!context.cfg.allowedLicenses.includes(context.ioPackageJson.common?.licenseInformation?.license)) {
314
- context.errors.push('[E116] No SPDX license found at "common.licenseInformation". Please use one of listed here: https://spdx.org/licenses/');
315
- } else {
316
- context.checks.push('"common.licenseInformation" is valid in io-package.json');
317
- }
322
+ context.warnings.push('[S139] Please evaluate whether adapter can be modified to support compact mode');
323
+ }
324
+ } else if (!context.ioPackageJson.common.onlyWWW) {
325
+ context.checks.push('"common.compact" found in io-package.json');
326
+ }
318
327
 
319
- // check if type is valid
320
- if (!['free', 'paid', 'commercial', 'limited'].includes(context.ioPackageJson.common?.licenseInformation?.type)) {
321
- context.errors.push('[E170] "common.licenseInformation.type" is invalid. Select valid type (e.g. free)');
322
- } else {
323
- context.checks.push('"common.licenseInformation.type" is valid in io-package.json');
328
+ if (
329
+ context.ioPackageJson.common.noConfig &&
330
+ context.ioPackageJson.common.adminUI &&
331
+ context.ioPackageJson.common.adminUI.config !== 'none'
332
+ ) {
333
+ context.errors.push('[E114] "common.noConfig=true" requires "common.adminUI.config" to be set to "none"');
334
+ }
335
+ if (
336
+ !context.ioPackageJson.common.materialize &&
337
+ !(context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'json') &&
338
+ !(context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'materialize') &&
339
+ !(context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'html') &&
340
+ !(context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'none')
341
+ ) {
342
+ context.errors.push(
343
+ '[E129] Admin support not specified. Please add "common.adminUI.config = json|materialize|html|none"',
344
+ );
345
+ } else {
346
+ context.checks.push('"common.materialize" or valid "common.adminUI.config:xxx" found in io-package.json');
347
+ }
324
348
 
325
- if (['paid', 'commercial', 'limited'].includes(context.ioPackageJson.common?.licenseInformation?.type)) {
326
- if (!context.ioPackageJson.common?.licenseInformation?.link) {
327
- context.errors.push('[E171] "common.licenseInformation.link" is required for non-free adapters');
328
- } else {
329
- context.checks.push('"common.licenseInformation.link" is valid in io-package.json');
330
- }
331
- }
332
- }
349
+ if (context.ioPackageJson.common.license) {
350
+ context.warnings.push(
351
+ '[W181] "common.license" in io-package.json is deprecated. Please define object "common.licenseInformation"',
352
+ );
353
+ }
333
354
 
334
- if (!context.packageJson ||
335
- context.ioPackageJson.common?.licenseInformation?.license !== context.packageJson.license) {
336
- context.errors.push('[E117] Licenses in package.json and in io-package.json are different');
337
- } else {
338
- context.checks.push('"common.licenseInformation.license" is equal in package.json and in io-package.json');
339
- }
355
+ if (!context.ioPackageJson.common.licenseInformation) {
356
+ if (!context.ioPackageJson.common.license) {
357
+ context.errors.push('[E115] "common.licenseInformation" not found in io-package.json');
340
358
  }
359
+ } else {
360
+ context.checks.push('"common.licenseInformation" found in io-package.json');
341
361
 
342
- if (!context.ioPackageJson.common.mode) {
343
- context.errors.push('[E165] "common.mode" not found in io-package.json');
362
+ if (context.ioPackageJson.common.license) {
363
+ context.errors.push(
364
+ '[E182] Please remove "common.license" from io-package.json as "common.licenseInformation" is declared.',
365
+ );
366
+ }
367
+
368
+ // check if license valid
369
+ if (!context.ioPackageJson.common.licenseInformation.license) {
370
+ context.errors.push('[E183] "common.licenseInformation.license" is missing');
371
+ } else if (!context.cfg.allowedLicenses.includes(context.ioPackageJson.common?.licenseInformation?.license)) {
372
+ context.errors.push(
373
+ '[E116] No SPDX license found at "common.licenseInformation". Please use one of listed here: https://spdx.org/licenses/',
374
+ );
344
375
  } else {
345
- context.checks.push('"common.mode" found in io-package.json');
346
-
347
- if (!context.cfg.allowedModes[context.ioPackageJson.common.mode]) {
348
- context.errors.push(`[E166] "common.mode: ${context.ioPackageJson.common.mode}" is unknown in io-package.json.`);
349
- } else {
350
- context.checks.push('"common.mode" has known mode in io-package.json');
376
+ context.checks.push('"common.licenseInformation" is valid in io-package.json');
377
+ }
351
378
 
352
- if (context.ioPackageJson.common.onlyWWW && context.ioPackageJson.common.mode !== 'none') {
353
- context.errors.push('[E164] onlyWWW should have common.mode "none" in io-package.json');
354
- }
379
+ // check if type is valid
380
+ if (
381
+ !['free', 'paid', 'commercial', 'limited'].includes(context.ioPackageJson.common?.licenseInformation?.type)
382
+ ) {
383
+ context.errors.push('[E170] "common.licenseInformation.type" is invalid. Select valid type (e.g. free)');
384
+ } else {
385
+ context.checks.push('"common.licenseInformation.type" is valid in io-package.json');
355
386
 
356
- if (context.ioPackageJson.common.mode === 'schedule' && !context.ioPackageJson.common.schedule) {
357
- context.errors.push('[E167] scheduled adapters must have "common.schedule" property in io-package.json');
387
+ if (['paid', 'commercial', 'limited'].includes(context.ioPackageJson.common?.licenseInformation?.type)) {
388
+ if (!context.ioPackageJson.common?.licenseInformation?.link) {
389
+ context.errors.push('[E171] "common.licenseInformation.link" is required for non-free adapters');
390
+ } else {
391
+ context.checks.push('"common.licenseInformation.link" is valid in io-package.json');
358
392
  }
359
393
  }
360
394
  }
361
395
 
362
- if (!context.ioPackageJson.common.type) {
363
- context.errors.push('[E119] No type found in io-package.json');
396
+ if (
397
+ !context.packageJson ||
398
+ context.ioPackageJson.common?.licenseInformation?.license !== context.packageJson.license
399
+ ) {
400
+ context.errors.push('[E117] Licenses in package.json and in io-package.json are different');
364
401
  } else {
365
- context.checks.push('"common.type" found in io-package.json');
366
-
367
- if (!context.cfg.allowedTypes[context.ioPackageJson.common.type]) {
368
- context.errors.push('[E120] Unknown type found in io-package.json');
369
- } else {
370
- context.checks.push('"common.type" has known type in io-package.json');
371
- }
402
+ context.checks.push('"common.licenseInformation.license" is equal in package.json and in io-package.json');
372
403
  }
404
+ }
405
+
406
+ if (!context.ioPackageJson.common.mode) {
407
+ context.errors.push('[E165] "common.mode" not found in io-package.json');
408
+ } else {
409
+ context.checks.push('"common.mode" found in io-package.json');
373
410
 
374
- if (!context.ioPackageJson.common.authors) {
375
- context.errors.push('[E121] No authors found in io-package.json');
411
+ if (!context.cfg.allowedModes[context.ioPackageJson.common.mode]) {
412
+ context.errors.push(
413
+ `[E166] "common.mode: ${context.ioPackageJson.common.mode}" is unknown in io-package.json.`,
414
+ );
376
415
  } else {
377
- context.checks.push('"common.authors" found in io-package.json');
416
+ context.checks.push('"common.mode" has known mode in io-package.json');
378
417
 
379
- if (!(context.ioPackageJson.common.authors instanceof Array)) {
380
- context.errors.push('[E122] authors must be an Array in io-package.json');
381
- } else {
382
- context.checks.push('"common.authors" is array in io-package.json');
418
+ if (context.ioPackageJson.common.onlyWWW && context.ioPackageJson.common.mode !== 'none') {
419
+ context.errors.push('[E164] onlyWWW should have common.mode "none" in io-package.json');
383
420
  }
384
421
 
385
- if (!context.ioPackageJson.common.authors.length) {
386
- context.errors.push('[E123] Authors may not be empty in io-package.json');
387
- } else {
388
- context.checks.push('"common.authors" is not empty in io-package.json');
422
+ if (context.ioPackageJson.common.mode === 'schedule' && !context.ioPackageJson.common.schedule) {
423
+ context.errors.push(
424
+ '[E167] scheduled adapters must have "common.schedule" property in io-package.json',
425
+ );
389
426
  }
390
427
  }
428
+ }
391
429
 
392
- if (context.ioPackageJson.common.localLink) {
393
- context.warnings.push('[W172] "common.localLink" in io-package.json is deprecated. Please define object "common.localLinks": { "_default": "..." }');
394
- } else {
395
- context.checks.push('No "common.localLink" found in io-package.json');
396
- }
430
+ if (!context.ioPackageJson.common.type) {
431
+ context.errors.push('[E119] No type found in io-package.json');
432
+ } else {
433
+ context.checks.push('"common.type" found in io-package.json');
397
434
 
398
- if (!context.ioPackageJson.common.news) {
399
- context.errors.push('[E130] No "common.news" found in io-package.json');
435
+ if (!context.cfg.allowedTypes[context.ioPackageJson.common.type]) {
436
+ context.errors.push('[E120] Unknown type found in io-package.json');
400
437
  } else {
401
- context.checks.push('"common.news" found in io-package.json');
402
-
403
- if (Object.keys(context.ioPackageJson.common.news).length > 20) {
404
- context.errors.push('[E131] Too many "common.news" found in io-package.json. Must be less than 20. Please remove old news.');
405
- } else if (Object.keys(context.ioPackageJson.common.news).length > 7) {
406
- context.warnings.push('[W132] Many "common.news" found in io-package.json. Repository builder will truncate at 7 news. Please remove old news.');
407
- }
438
+ context.checks.push('"common.type" has known type in io-package.json');
439
+ }
440
+ }
408
441
 
409
- Object.keys(context.ioPackageJson.common.news).forEach(version => {
410
- if (!compareVersions.validateStrict(version)) {
411
- context.errors.push(`[E175] Release "${version}" at "common.news" in io-package.json is malformed.`);
412
- }
413
- });
442
+ if (!context.ioPackageJson.common.authors) {
443
+ context.errors.push('[E121] No authors found in io-package.json');
444
+ } else {
445
+ context.checks.push('"common.authors" found in io-package.json');
414
446
 
415
- if (!context.ioPackageJson.common.news[context.ioPackageJson.common.version]) {
416
- context.errors.push(`[E136] No "common.news" found for actual version ${context.ioPackageJson.common.version} in io-package.json`);
417
- }
447
+ if (!(context.ioPackageJson.common.authors instanceof Array)) {
448
+ context.errors.push('[E122] authors must be an Array in io-package.json');
449
+ } else {
450
+ context.checks.push('"common.authors" is array in io-package.json');
451
+ }
418
452
 
419
- let missingLang = [];
420
- Object.keys(context.ioPackageJson.common.news).forEach(version => {
421
- missingLang = missingLang.concat(common.checkLanguages(context.ioPackageJson.common.news[version], context.cfg.requiredLanguages));
422
- });
423
- if (missingLang.length) {
424
- missingLang = [... new Set(missingLang)]; // make unique
425
- context.errors.push(`[E145] Missing mandatory translation into ${missingLang.join()} of some "common.news" in io-package.json.`);
426
- }
453
+ if (!context.ioPackageJson.common.authors.length) {
454
+ context.errors.push('[E123] Authors may not be empty in io-package.json');
455
+ } else {
456
+ context.checks.push('"common.authors" is not empty in io-package.json');
457
+ }
458
+ }
427
459
 
428
- missingLang = [];
429
- Object.keys(context.ioPackageJson.common.news).forEach(version => {
430
- missingLang = missingLang.concat(common.checkLanguages(context.ioPackageJson.common.news[version], context.cfg.allowedLanguages));
431
- });
432
- missingLang = missingLang.filter(lang => !context.cfg.requiredLanguages.includes(lang));
433
- if (missingLang.length) {
434
- missingLang = [... new Set(missingLang)]; // make unique
435
- context.warnings.push(`[W154] Missing suggested translation into ${missingLang.join()} of some "common.news" in io-package.json.`);
436
- }
460
+ if (context.ioPackageJson.common.localLink) {
461
+ context.warnings.push(
462
+ '[W172] "common.localLink" in io-package.json is deprecated. Please define object "common.localLinks": { "_default": "..." }',
463
+ );
464
+ } else {
465
+ context.checks.push('No "common.localLink" found in io-package.json');
466
+ }
437
467
 
468
+ if (!context.ioPackageJson.common.news) {
469
+ context.errors.push('[E130] No "common.news" found in io-package.json');
470
+ } else {
471
+ context.checks.push('"common.news" found in io-package.json');
472
+
473
+ if (Object.keys(context.ioPackageJson.common.news).length > 20) {
474
+ context.errors.push(
475
+ '[E131] Too many "common.news" found in io-package.json. Must be less than 20. Please remove old news.',
476
+ );
477
+ } else if (Object.keys(context.ioPackageJson.common.news).length > 7) {
478
+ context.warnings.push(
479
+ '[W132] Many "common.news" found in io-package.json. Repository builder will truncate at 7 news. Please remove old news.',
480
+ );
481
+ }
482
+
483
+ Object.keys(context.ioPackageJson.common.news).forEach(version => {
484
+ if (!compareVersions.validateStrict(version)) {
485
+ context.errors.push(`[E175] Release "${version}" at "common.news" in io-package.json is malformed.`);
486
+ }
487
+ });
488
+
489
+ if (!context.ioPackageJson.common.news[context.ioPackageJson.common.version]) {
490
+ context.errors.push(
491
+ `[E136] No "common.news" found for actual version ${context.ioPackageJson.common.version} in io-package.json`,
492
+ );
493
+ }
494
+
495
+ let missingLang = [];
496
+ Object.keys(context.ioPackageJson.common.news).forEach(version => {
497
+ missingLang = missingLang.concat(
498
+ common.checkLanguages(context.ioPackageJson.common.news[version], context.cfg.requiredLanguages),
499
+ );
500
+ });
501
+ if (missingLang.length) {
502
+ missingLang = [...new Set(missingLang)]; // make unique
503
+ context.errors.push(
504
+ `[E145] Missing mandatory translation into ${missingLang.join()} of some "common.news" in io-package.json.`,
505
+ );
506
+ }
507
+
508
+ missingLang = [];
509
+ Object.keys(context.ioPackageJson.common.news).forEach(version => {
510
+ missingLang = missingLang.concat(
511
+ common.checkLanguages(context.ioPackageJson.common.news[version], context.cfg.allowedLanguages),
512
+ );
513
+ });
514
+ missingLang = missingLang.filter(lang => !context.cfg.requiredLanguages.includes(lang));
515
+ if (missingLang.length) {
516
+ missingLang = [...new Set(missingLang)]; // make unique
517
+ context.warnings.push(
518
+ `[W154] Missing suggested translation into ${missingLang.join()} of some "common.news" in io-package.json.`,
519
+ );
438
520
  }
521
+ }
439
522
 
440
- // check main entry
441
- if ((context.ioPackageJson.common.mode !== 'none') && (context.ioPackageJson.common.mode !== 'extension')) {
442
- if (!context.packageJson.main) {
443
- !context.ioPackageJson.common.onlyWWW && context.errors.push('[E143] No main found in the package.json');
523
+ // check main entry
524
+ if (context.ioPackageJson.common.mode !== 'none' && context.ioPackageJson.common.mode !== 'extension') {
525
+ if (!context.packageJson.main) {
526
+ !context.ioPackageJson.common.onlyWWW && context.errors.push('[E143] No main found in the package.json');
527
+ } else {
528
+ context.checks.push('"main" found in package.json');
529
+ if (!context.packageJson.main.endsWith('.js') && !context.packageJson.main.endsWith('.ts')) {
530
+ !context.ioPackageJson.common.onlyWWW &&
531
+ context.errors.push(
532
+ `[E163] common.mode "${context.ioPackageJson.common.mode}" requires JavaScript or Typescript file for "main" in package.json`,
533
+ );
444
534
  } else {
445
- context.checks.push('"main" found in package.json');
446
- if (!context.packageJson.main.endsWith('.js') && !context.packageJson.main.endsWith('.ts')) {
447
- !context.ioPackageJson.common.onlyWWW && context.errors.push(`[E163] common.mode "${context.ioPackageJson.common.mode}" requires JavaScript or Typescript file for "main" in package.json`);
448
- } else {
449
- context.checks.push('"main" references .js or .ts file');
450
- }
535
+ context.checks.push('"main" references .js or .ts file');
451
536
  }
452
537
  }
538
+ }
453
539
 
454
- //if (context.ioPackageJson.common.installedFrom) {
455
- // context.errors.push('[E144] common.installedFrom field found in io-package.json. Must be removed.');
456
- //}
457
-
458
- if (context.ioPackageJson.instanceObjects) {
459
- const instanceObjects = context.ioPackageJson.instanceObjects;
460
- if (!(instanceObjects instanceof Array)) {
461
- context.errors.push('[E146] instanceObjects must be an Array in io-package.json');
462
- } else {
463
- const allowedObjectTypes = ['state', 'channel', 'device', 'enum', 'host', 'adapter', 'instance', 'meta', 'config', 'script', 'user', 'group', 'chart', 'folder'];
464
- const allowedStateTypes = ['number', 'string', 'boolean', 'array', 'object', 'mixed', 'file', 'json'];
540
+ //if (context.ioPackageJson.common.installedFrom) {
541
+ // context.errors.push('[E144] common.installedFrom field found in io-package.json. Must be removed.');
542
+ //}
465
543
 
466
- instanceObjects.forEach(instanceObject => {
467
- if (instanceObject.type !== undefined && !allowedObjectTypes.includes(instanceObject.type)) {
468
- context.errors.push(`[E147] instanceObject type has an invalid type: ${instanceObject.type}`);
469
- }
544
+ if (context.ioPackageJson.instanceObjects) {
545
+ const instanceObjects = context.ioPackageJson.instanceObjects;
546
+ if (!(instanceObjects instanceof Array)) {
547
+ context.errors.push('[E146] instanceObjects must be an Array in io-package.json');
548
+ } else {
549
+ const allowedObjectTypes = [
550
+ 'state',
551
+ 'channel',
552
+ 'device',
553
+ 'enum',
554
+ 'host',
555
+ 'adapter',
556
+ 'instance',
557
+ 'meta',
558
+ 'config',
559
+ 'script',
560
+ 'user',
561
+ 'group',
562
+ 'chart',
563
+ 'folder',
564
+ ];
565
+ const allowedStateTypes = ['number', 'string', 'boolean', 'array', 'object', 'mixed', 'file', 'json'];
566
+
567
+ instanceObjects.forEach(instanceObject => {
568
+ if (instanceObject.type !== undefined && !allowedObjectTypes.includes(instanceObject.type)) {
569
+ context.errors.push(`[E147] instanceObject type has an invalid type: ${instanceObject.type}`);
570
+ }
470
571
 
471
- if (instanceObject.common) {
472
- if (instanceObject.common.type !== undefined) {
473
- if (typeof instanceObject.common.type !== 'string') {
474
- context.errors.push(`[E148] instanceObject common.type has an invalid type! Expected "string", received "${typeof instanceObject.common.type}"`);
475
- }
572
+ if (instanceObject.common) {
573
+ if (instanceObject.common.type !== undefined) {
574
+ if (typeof instanceObject.common.type !== 'string') {
575
+ context.errors.push(
576
+ `[E148] instanceObject common.type has an invalid type! Expected "string", received "${typeof instanceObject.common.type}"`,
577
+ );
578
+ }
476
579
 
477
- if (instanceObject.type === 'state' && !allowedStateTypes.includes(instanceObject.common.type)) {
478
- context.errors.push(`[E149] instanceObject common.type has an invalid value: ${instanceObject.common.type}`);
479
- }
580
+ if (
581
+ instanceObject.type === 'state' &&
582
+ !allowedStateTypes.includes(instanceObject.common.type)
583
+ ) {
584
+ context.errors.push(
585
+ `[E149] instanceObject common.type has an invalid value: ${instanceObject.common.type}`,
586
+ );
480
587
  }
481
588
  }
482
- });
483
- }
589
+ }
590
+ });
484
591
  }
592
+ }
485
593
 
486
- if (!context.ioPackageJson.common.connectionType) {
487
- !context.ioPackageJson.common.onlyWWW && context.errors.push('[E150] No "common.connectionType" found in io-package.json');
488
- } else if (!['local', 'cloud', 'none'].includes(context.ioPackageJson.common.connectionType)) {
489
- context.errors.push(`[E151] "common.connectionType" type has an invalid value "${context.ioPackageJson.common.connectionType}"`);
490
- }
594
+ if (!context.ioPackageJson.common.connectionType) {
595
+ !context.ioPackageJson.common.onlyWWW &&
596
+ context.errors.push('[E150] No "common.connectionType" found in io-package.json');
597
+ } else if (!['local', 'cloud', 'none'].includes(context.ioPackageJson.common.connectionType)) {
598
+ context.errors.push(
599
+ `[E151] "common.connectionType" type has an invalid value "${context.ioPackageJson.common.connectionType}"`,
600
+ );
601
+ }
491
602
 
492
- if (!context.ioPackageJson.common.dataSource) {
493
- !context.ioPackageJson.common.onlyWWW && context.errors.push('[E152] No "common.dataSource" found in io-package.json');
494
- } else if (!['poll', 'push', 'assumption', 'none'].includes(context.ioPackageJson.common.dataSource)) {
495
- context.errors.push(`[E153] "common.dataSource" type has an invalid value "${context.ioPackageJson.common.dataSource}"`);
496
- }
603
+ if (!context.ioPackageJson.common.dataSource) {
604
+ !context.ioPackageJson.common.onlyWWW &&
605
+ context.errors.push('[E152] No "common.dataSource" found in io-package.json');
606
+ } else if (!['poll', 'push', 'assumption', 'none'].includes(context.ioPackageJson.common.dataSource)) {
607
+ context.errors.push(
608
+ `[E153] "common.dataSource" type has an invalid value "${context.ioPackageJson.common.dataSource}"`,
609
+ );
610
+ }
497
611
 
498
- let currentJsControllerVersion = undefined;
612
+ let currentJsControllerVersion = undefined;
499
613
 
500
- if (context.ioPackageJson.common.dependencies) {
501
- if (!(context.ioPackageJson.common.dependencies instanceof Array)) {
502
- context.errors.push(`[E185] "common.dependencies" must be an array at io-package.json`);
503
- } else {
504
- const dependencyArray = common.getDependencyArray(context.ioPackageJson.common.dependencies);
614
+ if (context.ioPackageJson.common.dependencies) {
615
+ if (!(context.ioPackageJson.common.dependencies instanceof Array)) {
616
+ context.errors.push(`[E185] "common.dependencies" must be an array at io-package.json`);
617
+ } else {
618
+ const dependencyArray = common.getDependencyArray(context.ioPackageJson.common.dependencies);
505
619
 
506
- // Admin is not allowed in dependencies (globalDependencies only)
507
- if (dependencyArray.includes('admin')) {
508
- context.errors.push(`[E160] "admin" is not allowed in common.dependencies`);
509
- }
620
+ // Admin is not allowed in dependencies (globalDependencies only)
621
+ if (dependencyArray.includes('admin')) {
622
+ context.errors.push(`[E160] "admin" is not allowed in common.dependencies`);
623
+ }
510
624
 
511
- const jsControllerDependency = context.ioPackageJson.common.dependencies.find(dep => Object.keys(dep).find(attr => attr === 'js-controller'));
512
- if (jsControllerDependency) {
513
- console.log(`Found current js-controller dependency "${jsControllerDependency['js-controller']}"`);
625
+ const jsControllerDependency = context.ioPackageJson.common.dependencies.find(dep =>
626
+ Object.keys(dep).find(attr => attr === 'js-controller'),
627
+ );
628
+ if (jsControllerDependency) {
629
+ console.log(`Found current js-controller dependency "${jsControllerDependency['js-controller']}"`);
514
630
 
515
- if (!jsControllerDependency['js-controller'].startsWith('>=')) {
516
- context.errors.push(`[E159] common.dependencies "js-controller" dependency should always allow future versions (>=x.x.x) - recommended: {"js-controller": ">=${recommendedJsControllerVersion}"}`);
517
- } else {
518
- currentJsControllerVersion = jsControllerDependency['js-controller'].replace(/[^\d.]/g, '');
519
- }
631
+ if (!jsControllerDependency['js-controller'].startsWith('>=')) {
632
+ context.errors.push(
633
+ `[E159] common.dependencies "js-controller" dependency should always allow future versions (>=x.x.x) - recommended: {"js-controller": ">=${recommendedJsControllerVersion}"}`,
634
+ );
520
635
  } else {
521
- if (!context.ioPackageJson.common.onlyWWW) {
522
- if (requiredJsControllerVersion !== recommendedJsControllerVersion) {
523
- context.errors.push(`[E162] js-controller dependency missing. js-controller ${requiredJsControllerVersion} is required as minimum, ${recommendedJsControllerVersion} is recommended. Please add to dependencies at io-package.json.`);
524
- } else {
525
- context.errors.push(`[E162] js-controller dependency missing. js-controller ${requiredJsControllerVersion} is required as minimum. Please add to dependencies at io-package.json.`);
526
- }
636
+ currentJsControllerVersion = jsControllerDependency['js-controller'].replace(/[^\d.]/g, '');
637
+ }
638
+ } else {
639
+ if (!context.ioPackageJson.common.onlyWWW) {
640
+ if (requiredJsControllerVersion !== recommendedJsControllerVersion) {
641
+ context.errors.push(
642
+ `[E162] js-controller dependency missing. js-controller ${requiredJsControllerVersion} is required as minimum, ${recommendedJsControllerVersion} is recommended. Please add to dependencies at io-package.json.`,
643
+ );
644
+ } else {
645
+ context.errors.push(
646
+ `[E162] js-controller dependency missing. js-controller ${requiredJsControllerVersion} is required as minimum. Please add to dependencies at io-package.json.`,
647
+ );
527
648
  }
528
649
  }
529
650
  }
530
- } else {
531
- if (!context.ioPackageJson.common.onlyWWW) {
532
- context.errors.push(`[E185] "common.dependencies" must be an array at io-package.json`);
533
- if (requiredJsControllerVersion !== recommendedJsControllerVersion) {
534
- context.errors.push(`[E162] js-controller dependency missing. js-controller ${requiredJsControllerVersion} is required as minimum, ${recommendedJsControllerVersion} is recommended. Please add to dependencies at io-package.json.`);
535
- } else {
536
- context.errors.push(`[E162] js-controller dependency missing. js-controller ${requiredJsControllerVersion} is required as minimum. Please add to dependencies at io-package.json.`);
537
- }
538
- }
539
- }
540
-
541
- /*
542
- increase dependency as required by addition features
543
- */
544
- if (context.ioPackageJson && context.ioPackageJson.common && context.ioPackageJson.common.supportedMessges) {
545
- requiredJsControllerVersion = common.maxVersion(requiredJsControllerVersion, '5.0.18');
546
- }
547
- if (context.ioPackageJson && context.ioPackageJson.common && context.ioPackageJson.common.nodeProcessParams) {
548
- requiredJsControllerVersion = common.maxVersion(requiredJsControllerVersion, '5.0.18');
549
651
  }
550
-
551
-
552
- if (currentJsControllerVersion && compareVersions.compare(requiredJsControllerVersion, currentJsControllerVersion, '>')) {
652
+ } else {
653
+ if (!context.ioPackageJson.common.onlyWWW) {
654
+ context.errors.push(`[E185] "common.dependencies" must be an array at io-package.json`);
553
655
  if (requiredJsControllerVersion !== recommendedJsControllerVersion) {
554
- context.errors.push(`[E157] js-controller ${currentJsControllerVersion} listed as dependency but ${requiredJsControllerVersion} is required as minimum, ${recommendedJsControllerVersion} is recommended. Please update dependency at io-package.json.`);
656
+ context.errors.push(
657
+ `[E162] js-controller dependency missing. js-controller ${requiredJsControllerVersion} is required as minimum, ${recommendedJsControllerVersion} is recommended. Please add to dependencies at io-package.json.`,
658
+ );
555
659
  } else {
556
- context.errors.push(`[E157] js-controller ${currentJsControllerVersion} listed as dependency but ${requiredJsControllerVersion} is required as minimum. Please update dependency at io-package.json.`);
660
+ context.errors.push(
661
+ `[E162] js-controller dependency missing. js-controller ${requiredJsControllerVersion} is required as minimum. Please add to dependencies at io-package.json.`,
662
+ );
557
663
  }
558
- } else if (currentJsControllerVersion && compareVersions.compare(recommendedJsControllerVersion, currentJsControllerVersion, '>')) {
559
- context.warnings.push(`[W156] js-controller ${currentJsControllerVersion} listed as dependency but ${recommendedJsControllerVersion} is recommended. Please consider updating dependency at io-package.json.`);
560
664
  }
665
+ }
561
666
 
562
- if (context.ioPackageJson.common.globalDependencies) {
563
- const dependencyArray = common.getDependencyArray(context.ioPackageJson.common.globalDependencies);
667
+ /*
668
+ increase dependency as required by addition features
669
+ */
670
+ if (context.ioPackageJson && context.ioPackageJson.common && context.ioPackageJson.common.supportedMessges) {
671
+ requiredJsControllerVersion = common.maxVersion(requiredJsControllerVersion, '5.0.18');
672
+ }
673
+ if (context.ioPackageJson && context.ioPackageJson.common && context.ioPackageJson.common.nodeProcessParams) {
674
+ requiredJsControllerVersion = common.maxVersion(requiredJsControllerVersion, '5.0.18');
675
+ }
564
676
 
565
- if (!(context.ioPackageJson.common.globalDependencies instanceof Array)) {
566
- context.errors.push(`[E186] "common.globalDependencies" must be an array at io-package.json`);
567
- } else {
568
- // js-controller is not allowed in global dependencies (dependencies only)
569
- if (dependencyArray.includes('js-controller')) {
570
- context.errors.push(`[E161] "js-controller" is not allowed in common.globalDependencies`);
571
- }
572
- }
573
- }
677
+ if (
678
+ currentJsControllerVersion &&
679
+ compareVersions.compare(requiredJsControllerVersion, currentJsControllerVersion, '>')
680
+ ) {
681
+ if (requiredJsControllerVersion !== recommendedJsControllerVersion) {
682
+ context.errors.push(
683
+ `[E157] js-controller ${currentJsControllerVersion} listed as dependency but ${requiredJsControllerVersion} is required as minimum, ${recommendedJsControllerVersion} is recommended. Please update dependency at io-package.json.`,
684
+ );
685
+ } else {
686
+ context.errors.push(
687
+ `[E157] js-controller ${currentJsControllerVersion} listed as dependency but ${requiredJsControllerVersion} is required as minimum. Please update dependency at io-package.json.`,
688
+ );
689
+ }
690
+ } else if (
691
+ currentJsControllerVersion &&
692
+ compareVersions.compare(recommendedJsControllerVersion, currentJsControllerVersion, '>')
693
+ ) {
694
+ context.warnings.push(
695
+ `[W156] js-controller ${currentJsControllerVersion} listed as dependency but ${recommendedJsControllerVersion} is recommended. Please consider updating dependency at io-package.json.`,
696
+ );
697
+ }
574
698
 
699
+ if (context.ioPackageJson.common.globalDependencies) {
700
+ const dependencyArray = common.getDependencyArray(context.ioPackageJson.common.globalDependencies);
575
701
 
576
- if (!context.ioPackageJson.common.onlyWWW) {
577
- if (!context.ioPackageJson.common.tier) {
578
- context.warnings.push(`[W135] "common.tier" is required in io-package.json. Please check https://github.com/ioBroker/ioBroker.docs/blob/master/docs/en/dev/objectsschema.md#adapter.`);
579
- } else if (![1, 2, 3].includes(context.ioPackageJson.common.tier)) {
580
- context.errors.push(`[E155] Invalid "common.tier" value: ${context.ioPackageJson.common.tier} at io-package.json. Only 1, 2 or 3 are allowed!`);
581
- } else {
582
- context.checks.push('"common.tier" is valid in io-package.json');
583
- }
702
+ if (!(context.ioPackageJson.common.globalDependencies instanceof Array)) {
703
+ context.errors.push(`[E186] "common.globalDependencies" must be an array at io-package.json`);
584
704
  } else {
585
- context.checks.push('"common.tier" check skipped for wwwOnly adapter.');
705
+ // js-controller is not allowed in global dependencies (dependencies only)
706
+ if (dependencyArray.includes('js-controller')) {
707
+ context.errors.push(`[E161] "js-controller" is not allowed in common.globalDependencies`);
708
+ }
586
709
  }
710
+ }
587
711
 
588
- if (context.ioPackageJson.common.automaticUpgrade) {
589
- context.errors.push(`[E137] "common.automaticUpgrade" will be defined by the user. Please remove from io-package.json`);
712
+ if (!context.ioPackageJson.common.onlyWWW) {
713
+ if (!context.ioPackageJson.common.tier) {
714
+ context.warnings.push(
715
+ `[W135] "common.tier" is required in io-package.json. Please check https://github.com/ioBroker/ioBroker.docs/blob/master/docs/en/dev/objectsschema.md#adapter.`,
716
+ );
717
+ } else if (![1, 2, 3].includes(context.ioPackageJson.common.tier)) {
718
+ context.errors.push(
719
+ `[E155] Invalid "common.tier" value: ${context.ioPackageJson.common.tier} at io-package.json. Only 1, 2 or 3 are allowed!`,
720
+ );
590
721
  } else {
591
- context.checks.push('"common.automaticUpgrade" does not exist in io-package.json');
722
+ context.checks.push('"common.tier" is valid in io-package.json');
592
723
  }
724
+ } else {
725
+ context.checks.push('"common.tier" check skipped for wwwOnly adapter.');
726
+ }
593
727
 
594
- if (context.ioPackageJson.common.restartAdapters) {
595
- const restartAdaptersArray = context.ioPackageJson.common.restartAdapters;
728
+ if (context.ioPackageJson.common.automaticUpgrade) {
729
+ context.errors.push(
730
+ `[E137] "common.automaticUpgrade" will be defined by the user. Please remove from io-package.json`,
731
+ );
732
+ } else {
733
+ context.checks.push('"common.automaticUpgrade" does not exist in io-package.json');
734
+ }
596
735
 
597
- // own adapter is not allowed in a restart array
598
- if (restartAdaptersArray.includes(context.ioPackageJson.common.name)) {
599
- context.errors.push(`[E176] Own adapter is not allowed to be listed at "common.restartAdapters" in io-package.json`);
600
- } else {
601
- context.checks.push('Own adapter not listed at "common.restartAdapters".');
602
- }
736
+ if (context.ioPackageJson.common.restartAdapters) {
737
+ const restartAdaptersArray = context.ioPackageJson.common.restartAdapters;
738
+
739
+ // own adapter is not allowed in a restart array
740
+ if (restartAdaptersArray.includes(context.ioPackageJson.common.name)) {
741
+ context.errors.push(
742
+ `[E176] Own adapter is not allowed to be listed at "common.restartAdapters" in io-package.json`,
743
+ );
603
744
  } else {
604
- context.checks.push('"restartAdapters" check skipped as object not present.');
605
- }
606
-
607
- for (const blacklist in blacklistIOPackageJson) {
608
- //console.log(`checking blacklist ${blacklist}`);
609
- let tmp = context.ioPackageJson;
610
- let log = '';
611
- for (const element of blacklist.split('.')) {
612
- log = `${log}.${element}`;
613
- //console.log(` check ${log}`);
614
- tmp = tmp[element];
615
- if (!tmp) {
616
- //console.log(` ${log} does not exist`);
617
- break;
618
- }
745
+ context.checks.push('Own adapter not listed at "common.restartAdapters".');
746
+ }
747
+ } else {
748
+ context.checks.push('"restartAdapters" check skipped as object not present.');
749
+ }
750
+
751
+ for (const blacklist in blacklistIOPackageJson) {
752
+ //console.log(`checking blacklist ${blacklist}`);
753
+ let tmp = context.ioPackageJson;
754
+ let log = '';
755
+ for (const element of blacklist.split('.')) {
756
+ log = `${log}.${element}`;
757
+ //console.log(` check ${log}`);
758
+ tmp = tmp[element];
759
+ if (!tmp) {
760
+ //console.log(` ${log} does not exist`);
761
+ break;
762
+ }
763
+ }
764
+ if (tmp) {
765
+ if (blacklistIOPackageJson[blacklist].err) {
766
+ context.errors.push(`[E184] ${blacklistIOPackageJson[blacklist].msg}`);
767
+ } else {
768
+ context.warnings.push(`[W184] ${blacklistIOPackageJson[blacklist].msg}`);
619
769
  }
620
- if (tmp) {
621
- if (blacklistIOPackageJson[blacklist].err) {
622
- context.errors.push(`[E184] ${blacklistIOPackageJson[blacklist].msg}`);
623
- } else {
624
- context.warnings.push(`[W184] ${blacklistIOPackageJson[blacklist].msg}`);
625
- }
770
+ }
771
+ //else {
772
+ // console.log(`blacklist ${blacklist} no match`);
773
+ //}
774
+ }
775
+ context.checks.push('"blacklist (io-package)" checked.');
776
+
777
+ if (context.ioPackageJson.common.extIcon) {
778
+ try {
779
+ let icon = null;
780
+ if (common.isLocal()) {
781
+ const url = context.ioPackageJson.common.extIcon.replace(context.githubUrl, '');
782
+ icon = await common.downloadFile(null, url, true);
783
+ } else {
784
+ icon = await common.downloadFile(context.ioPackageJson.common.extIcon, null, true);
626
785
  }
627
- //else {
628
- // console.log(`blacklist ${blacklist} no match`);
629
- //}
630
- }
631
- context.checks.push('"blacklist (io-package)" checked.');
632
-
633
- if (context.ioPackageJson.common.extIcon) {
634
- try {
635
- let icon = null;
636
- if (common.isLocal()) {
637
- const url = context.ioPackageJson.common.extIcon.replace(context.githubUrl, '');
638
- icon = await common.downloadFile(null, url, true);
639
- } else {
640
- icon = await common.downloadFile(context.ioPackageJson.common.extIcon, null, true);
641
- }
642
- context.checks.push('"extIcon" could be downloaded');
786
+ context.checks.push('"extIcon" could be downloaded');
643
787
 
644
- const image = sizeOf(icon);
645
- if (image.width !== image.height) {
646
- context.errors.push('[E140] width and height of logo are not equal');
647
- } else {
648
- context.checks.push('Width and height of logo are equal');
649
- if (image.width < 32) {
650
- context.errors.push('[E141] logo is too small. It must be greater or equal than 32x32');
651
- } else if (image.width > 512) {
652
- context.errors.push('[E142] logo is too big. It must be less or equal than 512x512');
653
- }
788
+ const image = sizeOf(icon);
789
+ if (image.width !== image.height) {
790
+ context.errors.push('[E140] width and height of logo are not equal');
791
+ } else {
792
+ context.checks.push('Width and height of logo are equal');
793
+ if (image.width < 32) {
794
+ context.errors.push('[E141] logo is too small. It must be greater or equal than 32x32');
795
+ } else if (image.width > 512) {
796
+ context.errors.push('[E142] logo is too big. It must be less or equal than 512x512');
654
797
  }
655
- } catch (e) {
656
- common.debug(e);
657
- context.errors.push(`[E125] External icon not found under URL: ${context.ioPackageJson.common.extIcon}`);
658
798
  }
799
+ } catch (e) {
800
+ common.debug(e);
801
+ context.errors.push(`[E125] External icon not found under URL: ${context.ioPackageJson.common.extIcon}`);
659
802
  }
803
+ }
660
804
 
661
- if (!context.ioPackageJson.common.onlyWWW && context.packageJson.main) {
662
- try {
663
- await common.downloadFile(context.githubUrl, `/${context.packageJson.main}`);
664
- context.checks.push(`${context.packageJson.main} could be downloaded`);
665
- } catch (e) {
666
- common.debug(e);
667
- if (!context.ioPackageJson.common.nogit) {
668
- context.errors.push(`[E124] Main file not found under URL: ${context.githubUrl}/${context.packageJson.main}.`);
669
- } else if (!context.packageJson.main.startsWith('build/')) {
670
- context.warnings.push(`[W138] Main file not found under URL: ${context.githubUrl}/${context.packageJson.main} and not located at build/ directory too.`);
671
- }
805
+ if (!context.ioPackageJson.common.onlyWWW && context.packageJson.main) {
806
+ try {
807
+ await common.downloadFile(context.githubUrl, `/${context.packageJson.main}`);
808
+ context.checks.push(`${context.packageJson.main} could be downloaded`);
809
+ } catch (e) {
810
+ common.debug(e);
811
+ if (!context.ioPackageJson.common.nogit) {
812
+ context.errors.push(
813
+ `[E124] Main file not found under URL: ${context.githubUrl}/${context.packageJson.main}.`,
814
+ );
815
+ } else if (!context.packageJson.main.startsWith('build/')) {
816
+ context.warnings.push(
817
+ `[W138] Main file not found under URL: ${context.githubUrl}/${context.packageJson.main} and not located at build/ directory too.`,
818
+ );
672
819
  }
673
820
  }
674
821
  }