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