@iobroker/repochecker 3.2.2 → 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.
- package/LICENSE +21 -21
- package/README.md +233 -224
- package/index.js +70 -72
- package/lib/M000_PackageJson.js +141 -65
- package/lib/M100_IOPackageJson.js +604 -441
- 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 +12 -7
- package/lib/M700_License.js +8 -5
- package/lib/M800_Github.js +15 -7
- package/lib/M900_GitNpmIgnore.js +34 -31
- package/lib/common.js +4 -4
- package/lib/config.js +34 -47
- package/package.json +10 -8
|
@@ -28,48 +28,47 @@ async function getIOPackageJson(context) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const recommendedJsControllerVersion = '5.0.19';
|
|
31
|
-
let requiredJsControllerVersion = '
|
|
31
|
+
let requiredJsControllerVersion = '5.0.19';
|
|
32
32
|
|
|
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,555 +103,719 @@ async function checkIOPackageJson(context) {
|
|
|
104
103
|
|
|
105
104
|
if (suspiciousKeys.length) {
|
|
106
105
|
if (context.ioPackageJson.protectedNative) {
|
|
107
|
-
const missingProtected = suspiciousKeys.filter(
|
|
108
|
-
|
|
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(
|
|
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(
|
|
115
|
-
|
|
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(
|
|
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
|
|
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"
|
|
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
|
-
// }
|
|
147
|
+
context.checks.push('"common.name" is valid in io-package.json');
|
|
148
|
+
}
|
|
145
149
|
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
151
|
-
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
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
|
-
});
|
|
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
|
-
|
|
192
|
-
context.
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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.
|
|
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 (
|
|
209
|
-
context.
|
|
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
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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
|
+
}
|
|
232
|
+
|
|
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');
|
|
225
237
|
|
|
226
|
-
if (
|
|
227
|
-
context.errors.push(
|
|
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
|
-
|
|
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`);
|
|
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.
|
|
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
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
-
|
|
248
|
-
|
|
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
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
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
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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 (
|
|
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');
|
|
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.
|
|
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"');
|
|
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.
|
|
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
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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.
|
|
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
|
-
}
|
|
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
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
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
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
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
|
-
|
|
335
|
-
|
|
336
|
-
|
|
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 (
|
|
343
|
-
context.errors.push(
|
|
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.
|
|
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
|
-
|
|
353
|
-
|
|
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
|
-
|
|
357
|
-
|
|
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 (
|
|
363
|
-
context.
|
|
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.
|
|
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
|
+
}
|
|
373
405
|
|
|
374
|
-
|
|
375
|
-
|
|
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');
|
|
410
|
+
|
|
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.
|
|
416
|
+
context.checks.push('"common.mode" has known mode in io-package.json');
|
|
378
417
|
|
|
379
|
-
if (
|
|
380
|
-
context.errors.push('[
|
|
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.
|
|
386
|
-
context.errors.push(
|
|
387
|
-
|
|
388
|
-
|
|
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
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
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.
|
|
399
|
-
context.errors.push('[
|
|
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.
|
|
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
|
-
}
|
|
438
|
+
context.checks.push('"common.type" has known type in io-package.json');
|
|
439
|
+
}
|
|
440
|
+
}
|
|
408
441
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
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
|
-
|
|
416
|
-
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
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"
|
|
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
|
-
|
|
455
|
-
|
|
456
|
-
|
|
540
|
+
//if (context.ioPackageJson.common.installedFrom) {
|
|
541
|
+
// context.errors.push('[E144] common.installedFrom field found in io-package.json. Must be removed.');
|
|
542
|
+
//}
|
|
457
543
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
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
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
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
|
-
|
|
478
|
-
|
|
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
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
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
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
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
|
-
|
|
612
|
+
let currentJsControllerVersion = undefined;
|
|
499
613
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
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
|
-
|
|
507
|
-
|
|
508
|
-
|
|
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
|
-
|
|
512
|
-
|
|
513
|
-
|
|
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
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
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
|
-
|
|
522
|
-
|
|
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
|
+
);
|
|
523
648
|
}
|
|
524
649
|
}
|
|
525
650
|
}
|
|
526
651
|
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
652
|
+
} else {
|
|
653
|
+
if (!context.ioPackageJson.common.onlyWWW) {
|
|
654
|
+
context.errors.push(`[E185] "common.dependencies" must be an array at io-package.json`);
|
|
655
|
+
if (requiredJsControllerVersion !== recommendedJsControllerVersion) {
|
|
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
|
+
);
|
|
659
|
+
} else {
|
|
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
|
+
);
|
|
663
|
+
}
|
|
536
664
|
}
|
|
665
|
+
}
|
|
537
666
|
|
|
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
|
+
}
|
|
538
676
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
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
|
+
}
|
|
544
698
|
|
|
545
|
-
|
|
546
|
-
|
|
699
|
+
if (context.ioPackageJson.common.globalDependencies) {
|
|
700
|
+
const dependencyArray = common.getDependencyArray(context.ioPackageJson.common.globalDependencies);
|
|
547
701
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
}
|
|
702
|
+
if (!(context.ioPackageJson.common.globalDependencies instanceof Array)) {
|
|
703
|
+
context.errors.push(`[E186] "common.globalDependencies" must be an array at io-package.json`);
|
|
704
|
+
} else {
|
|
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`);
|
|
555
708
|
}
|
|
556
|
-
|
|
557
709
|
}
|
|
710
|
+
}
|
|
558
711
|
|
|
559
|
-
|
|
560
|
-
if (!context.ioPackageJson.common.
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
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
|
+
);
|
|
568
721
|
} else {
|
|
569
|
-
context.checks.push('"common.tier"
|
|
722
|
+
context.checks.push('"common.tier" is valid in io-package.json');
|
|
570
723
|
}
|
|
724
|
+
} else {
|
|
725
|
+
context.checks.push('"common.tier" check skipped for wwwOnly adapter.');
|
|
726
|
+
}
|
|
571
727
|
|
|
572
|
-
|
|
573
|
-
|
|
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
|
+
}
|
|
735
|
+
|
|
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
|
+
);
|
|
574
744
|
} else {
|
|
575
|
-
context.checks.push('
|
|
745
|
+
context.checks.push('Own adapter not listed at "common.restartAdapters".');
|
|
576
746
|
}
|
|
747
|
+
} else {
|
|
748
|
+
context.checks.push('"restartAdapters" check skipped as object not present.');
|
|
749
|
+
}
|
|
577
750
|
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
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}`);
|
|
584
767
|
} else {
|
|
585
|
-
context.
|
|
768
|
+
context.warnings.push(`[W184] ${blacklistIOPackageJson[blacklist].msg}`);
|
|
586
769
|
}
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
if (tmp) {
|
|
605
|
-
if (blacklistIOPackageJson[blacklist].err) {
|
|
606
|
-
context.errors.push(`[E184] ${blacklistIOPackageJson[blacklist].msg}`);
|
|
607
|
-
} else {
|
|
608
|
-
context.warnings.push(`[W184] ${blacklistIOPackageJson[blacklist].msg}`);
|
|
609
|
-
}
|
|
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);
|
|
610
785
|
}
|
|
611
|
-
|
|
612
|
-
// console.log(`blacklist ${blacklist} no match`);
|
|
613
|
-
//}
|
|
614
|
-
}
|
|
615
|
-
context.checks.push('"blacklist (io-package)" checked.');
|
|
616
|
-
|
|
617
|
-
if (context.ioPackageJson.common.extIcon) {
|
|
618
|
-
try {
|
|
619
|
-
let icon = null;
|
|
620
|
-
if (common.isLocal()) {
|
|
621
|
-
const url = context.ioPackageJson.common.extIcon.replace(context.githubUrl, '');
|
|
622
|
-
icon = await common.downloadFile(null, url, true);
|
|
623
|
-
} else {
|
|
624
|
-
icon = await common.downloadFile(context.ioPackageJson.common.extIcon, null, true);
|
|
625
|
-
}
|
|
626
|
-
context.checks.push('"extIcon" could be downloaded');
|
|
786
|
+
context.checks.push('"extIcon" could be downloaded');
|
|
627
787
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
}
|
|
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');
|
|
638
797
|
}
|
|
639
|
-
} catch (e) {
|
|
640
|
-
common.debug(e);
|
|
641
|
-
context.errors.push(`[E125] External icon not found under URL: ${context.ioPackageJson.common.extIcon}`);
|
|
642
798
|
}
|
|
799
|
+
} catch (e) {
|
|
800
|
+
common.debug(e);
|
|
801
|
+
context.errors.push(`[E125] External icon not found under URL: ${context.ioPackageJson.common.extIcon}`);
|
|
643
802
|
}
|
|
803
|
+
}
|
|
644
804
|
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
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
|
+
);
|
|
656
819
|
}
|
|
657
820
|
}
|
|
658
821
|
}
|