@iobroker/repochecker 5.12.1 → 5.13.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/README.md +21 -0
- package/index.js +1 -0
- package/lib/M0000_PackageJson.js +257 -26
- package/lib/M1000_IOPackageJson.js +386 -46
- package/lib/M5000_Code.js +232 -17
- package/lib/M5500__JsonConfig.js +54 -0
- package/lib/M6000_Readme.js +59 -0
- package/lib/M8900__Dependabot.js +112 -14
- package/lib/M9000_GitNpmIgnore.js +59 -0
- package/lib/postprocessing.js +2 -0
- package/package.json +1 -1
|
@@ -34,6 +34,7 @@ let requiredJsControllerVersion = '6.0.11';
|
|
|
34
34
|
|
|
35
35
|
const recommendedAdminVersion = '7.6.20';
|
|
36
36
|
let requiredAdminVersion = '7.6.17'; // set to 6.17.14 if jsonConfig is used
|
|
37
|
+
const adaptersAllowedToUseNondeletable = [];
|
|
37
38
|
|
|
38
39
|
const blacklistIOPackageJson = {
|
|
39
40
|
$schema: {
|
|
@@ -64,10 +65,6 @@ const blacklistIOPackageJson = {
|
|
|
64
65
|
msg: '"common.noConfig" is deprecated for admin >= 5 at io-package.json. Please use property "adminUI.config":"none".',
|
|
65
66
|
err: false,
|
|
66
67
|
},
|
|
67
|
-
'common.nondeletable': {
|
|
68
|
-
msg: '"common.nondeleteable" detected at io-package.json. Please check why this adapter cannot be deleted or updated and remove flag if possible.',
|
|
69
|
-
err: false,
|
|
70
|
-
},
|
|
71
68
|
'common.singleton': {
|
|
72
69
|
msg: '"common.singleton" detected for non onlyWWW adapter. Is this really desired?',
|
|
73
70
|
err: false,
|
|
@@ -102,6 +99,186 @@ const blacklistIOPackageJson = {
|
|
|
102
99
|
},
|
|
103
100
|
};
|
|
104
101
|
|
|
102
|
+
const instanceObjectValidTypes = [
|
|
103
|
+
'state',
|
|
104
|
+
'channel',
|
|
105
|
+
'device',
|
|
106
|
+
'enum',
|
|
107
|
+
'host',
|
|
108
|
+
'adapter',
|
|
109
|
+
'instance',
|
|
110
|
+
'meta',
|
|
111
|
+
'config',
|
|
112
|
+
'script',
|
|
113
|
+
'user',
|
|
114
|
+
'group',
|
|
115
|
+
'chart',
|
|
116
|
+
'folder',
|
|
117
|
+
'schedule',
|
|
118
|
+
'design',
|
|
119
|
+
];
|
|
120
|
+
const instanceObjectStateTypes = [
|
|
121
|
+
'array',
|
|
122
|
+
'boolean',
|
|
123
|
+
'file',
|
|
124
|
+
'json',
|
|
125
|
+
'mixed',
|
|
126
|
+
'multistate',
|
|
127
|
+
'number',
|
|
128
|
+
'object',
|
|
129
|
+
'string',
|
|
130
|
+
];
|
|
131
|
+
const stateRolesUrl = 'https://raw.githubusercontent.com/ioBroker/ioBroker.docs/master/docs/en/dev/stateroles.md';
|
|
132
|
+
let stateRoleDefinitionsCache;
|
|
133
|
+
|
|
134
|
+
function mergeTypeConstraint(base, next) {
|
|
135
|
+
if (!base || !next) {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
return [...new Set([...base, ...next])];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function mergeBooleanConstraint(base, next) {
|
|
142
|
+
if (base === next) {
|
|
143
|
+
return base;
|
|
144
|
+
}
|
|
145
|
+
if (base === 'any' || next === 'any') {
|
|
146
|
+
return 'any';
|
|
147
|
+
}
|
|
148
|
+
return 'any';
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function parseStateRoleDefinitions(markdown) {
|
|
152
|
+
const profileBySection = {
|
|
153
|
+
'### Common': { types: undefined, read: 'any', write: 'any' },
|
|
154
|
+
'### Sensor (booleans, read-only)': { types: ['boolean'], read: true, write: false },
|
|
155
|
+
'### Buttons (booleans, write-only)': { types: ['boolean'], read: false, write: true },
|
|
156
|
+
'### Buttons as sensor': { types: ['boolean'], read: true, write: false },
|
|
157
|
+
'### Values (numbers, read-only)': { types: ['number'], read: true, write: false },
|
|
158
|
+
'### Indicators (boolean, read-only)': { types: ['boolean'], read: true, write: false },
|
|
159
|
+
'### Levels (numbers, read-write)': { types: ['number'], read: true, write: true },
|
|
160
|
+
'### Switches (booleans, read-write)': { types: ['boolean'], read: true, write: true },
|
|
161
|
+
'### Health': { types: ['number'], read: true, write: false },
|
|
162
|
+
'### Others': { types: undefined, read: 'any', write: 'any' },
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
let currentProfile = profileBySection['### Others'];
|
|
166
|
+
const definitions = {};
|
|
167
|
+
for (const rawLine of markdown.split(/\r?\n/)) {
|
|
168
|
+
const line = rawLine.trim();
|
|
169
|
+
if (profileBySection[line]) {
|
|
170
|
+
currentProfile = profileBySection[line];
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const roleMatch = line.match(/^\*\s+`([^`]+)`\s*(.*)$/);
|
|
175
|
+
if (!roleMatch) {
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const role = roleMatch[1].trim();
|
|
180
|
+
const comment = roleMatch[2] || '';
|
|
181
|
+
if (role.includes('*') || role.startsWith('~~') || role.endsWith('~~')) {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const entry = {
|
|
186
|
+
types: currentProfile.types ? [...currentProfile.types] : undefined,
|
|
187
|
+
read: currentProfile.read,
|
|
188
|
+
write: currentProfile.write,
|
|
189
|
+
};
|
|
190
|
+
const inlineTypes = [
|
|
191
|
+
...comment.matchAll(/common\.type\s*=\s*(array|boolean|file|json|mixed|multistate|number|object|string)/g),
|
|
192
|
+
].map(match => match[1]);
|
|
193
|
+
if (inlineTypes.length) {
|
|
194
|
+
entry.types = [...new Set(inlineTypes)];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (definitions[role]) {
|
|
198
|
+
definitions[role] = {
|
|
199
|
+
types: mergeTypeConstraint(definitions[role].types, entry.types),
|
|
200
|
+
read: mergeBooleanConstraint(definitions[role].read, entry.read),
|
|
201
|
+
write: mergeBooleanConstraint(definitions[role].write, entry.write),
|
|
202
|
+
};
|
|
203
|
+
} else {
|
|
204
|
+
definitions[role] = entry;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return definitions;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
async function getStateRoleDefinitions(context) {
|
|
212
|
+
if (stateRoleDefinitionsCache) {
|
|
213
|
+
return stateRoleDefinitionsCache;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const markdown = await common.downloadURL(stateRolesUrl, false);
|
|
217
|
+
if (!markdown || typeof markdown !== 'string') {
|
|
218
|
+
context.warnings.push(
|
|
219
|
+
`[W1117] Could not download ${stateRolesUrl} for validation of instanceObjects common.role`,
|
|
220
|
+
);
|
|
221
|
+
stateRoleDefinitionsCache = {};
|
|
222
|
+
return stateRoleDefinitionsCache;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
stateRoleDefinitionsCache = parseStateRoleDefinitions(markdown);
|
|
226
|
+
return stateRoleDefinitionsCache;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function normalizeStateRoleForLookup(role) {
|
|
230
|
+
if (!role.includes('.setting.')) {
|
|
231
|
+
return role.endsWith('.setting') ? role.slice(0, -8) : role;
|
|
232
|
+
}
|
|
233
|
+
return role.replace('.setting.', '.');
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function getNativeForChecks(ioPackageJson) {
|
|
237
|
+
if (!ioPackageJson.native || typeof ioPackageJson.native !== 'object' || Array.isArray(ioPackageJson.native)) {
|
|
238
|
+
return {};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (ioPackageJson.common?.mode !== 'extension') {
|
|
242
|
+
return ioPackageJson.native;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const nativeForChecks = { ...ioPackageJson.native };
|
|
246
|
+
delete nativeForChecks.webInstance;
|
|
247
|
+
return nativeForChecks;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function doesValueMatchStateType(value, stateType) {
|
|
251
|
+
if (value === undefined) {
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
if (stateType === 'mixed' || stateType === 'multistate') {
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
if (stateType === 'array') {
|
|
258
|
+
if (typeof value !== 'string') {
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
try {
|
|
262
|
+
return Array.isArray(JSON.parse(value));
|
|
263
|
+
} catch {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (stateType === 'boolean') {
|
|
268
|
+
return typeof value === 'boolean';
|
|
269
|
+
}
|
|
270
|
+
if (stateType === 'number') {
|
|
271
|
+
return typeof value === 'number';
|
|
272
|
+
}
|
|
273
|
+
if (stateType === 'string' || stateType === 'file' || stateType === 'json') {
|
|
274
|
+
return typeof value === 'string';
|
|
275
|
+
}
|
|
276
|
+
if (stateType === 'object') {
|
|
277
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
278
|
+
}
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
|
|
105
282
|
async function validateIOPackageSchema(context) {
|
|
106
283
|
common.debug('[schema] validating io-package.json against schema');
|
|
107
284
|
|
|
@@ -201,6 +378,7 @@ async function checkIOPackageJson(context) {
|
|
|
201
378
|
context.errors.push('[E1001] io-package.json must have at least empty "native" attribute');
|
|
202
379
|
} else {
|
|
203
380
|
context.checks.push('"native" found in io-package.json');
|
|
381
|
+
const nativeForChecks = getNativeForChecks(context.ioPackageJson);
|
|
204
382
|
|
|
205
383
|
// Generic check for potential credentials that should have a counterpart in encryptedNative/protectedNative
|
|
206
384
|
const suspiciousPhrases = [
|
|
@@ -223,13 +401,13 @@ async function checkIOPackageJson(context) {
|
|
|
223
401
|
// suspiciousKeys = suspiciousKeys.filter(key => suspiciousPhrases.includes(key.toLowerCase()));
|
|
224
402
|
|
|
225
403
|
const regex = new RegExp(suspiciousPhrases.join('|'), 'i');
|
|
226
|
-
const nativeKeys = Object.keys(
|
|
404
|
+
const nativeKeys = Object.keys(nativeForChecks) || [];
|
|
227
405
|
|
|
228
406
|
let suspiciousKeys = nativeKeys.filter(key => regex.test(key.toLowerCase()));
|
|
229
407
|
common.debug(`Suspicious key test: native: ${nativeKeys}`);
|
|
230
408
|
common.debug(`Suspicious key test: suspiciousKeys (unfiltered): ${suspiciousKeys}`);
|
|
231
409
|
if (suspiciousKeys.length) {
|
|
232
|
-
suspiciousKeys = suspiciousKeys.filter(key => typeof
|
|
410
|
+
suspiciousKeys = suspiciousKeys.filter(key => typeof nativeForChecks[key] !== 'boolean');
|
|
233
411
|
common.debug(`Suspicious key test: suspiciousKeys (filtered): ${suspiciousKeys}`);
|
|
234
412
|
}
|
|
235
413
|
if (suspiciousKeys.length) {
|
|
@@ -300,7 +478,7 @@ async function checkIOPackageJson(context) {
|
|
|
300
478
|
...(context.ioPackageJson.encryptedNative || []),
|
|
301
479
|
]),
|
|
302
480
|
]) {
|
|
303
|
-
if (
|
|
481
|
+
if (nativeForChecks[key] === undefined) {
|
|
304
482
|
// Check if the key contains a dot, indicating an array element path
|
|
305
483
|
if (key.includes('.')) {
|
|
306
484
|
context.warnings.push(`[W1103] Encryption of array elements "${key}" is not yet available`);
|
|
@@ -317,7 +495,7 @@ async function checkIOPackageJson(context) {
|
|
|
317
495
|
// Note: actual error E5040 is raised in M5000_Code.js after checking if the keys are used in admin UI files
|
|
318
496
|
const exampleKeys = ['option1', 'option2'];
|
|
319
497
|
context.nativeExampleKeys = exampleKeys.filter(key =>
|
|
320
|
-
Object.prototype.hasOwnProperty.call(
|
|
498
|
+
Object.prototype.hasOwnProperty.call(nativeForChecks, key),
|
|
321
499
|
);
|
|
322
500
|
}
|
|
323
501
|
|
|
@@ -554,7 +732,7 @@ async function checkIOPackageJson(context) {
|
|
|
554
732
|
if (
|
|
555
733
|
context.ioPackageJson.common.adminUI?.config === 'none' &&
|
|
556
734
|
context.ioPackageJson.native &&
|
|
557
|
-
Object.keys(context.ioPackageJson
|
|
735
|
+
Object.keys(getNativeForChecks(context.ioPackageJson)).length > 0
|
|
558
736
|
) {
|
|
559
737
|
context.warnings.push(
|
|
560
738
|
'[W1113] "native" config object will not be used when "common.adminUI.config" is set to "none". Please remove native properties from io-package.json.',
|
|
@@ -808,47 +986,195 @@ async function checkIOPackageJson(context) {
|
|
|
808
986
|
if (context.ioPackageJson.instanceObjects) {
|
|
809
987
|
const instanceObjects = context.ioPackageJson.instanceObjects;
|
|
810
988
|
if (!(instanceObjects instanceof Array)) {
|
|
811
|
-
context.
|
|
989
|
+
context.warnings.push('[W1046] instanceObjects must be an Array in io-package.json');
|
|
812
990
|
} else {
|
|
813
|
-
const
|
|
814
|
-
|
|
815
|
-
'
|
|
816
|
-
'
|
|
817
|
-
'
|
|
818
|
-
'
|
|
819
|
-
'
|
|
820
|
-
'
|
|
821
|
-
'
|
|
822
|
-
'
|
|
823
|
-
'
|
|
824
|
-
'
|
|
825
|
-
'
|
|
826
|
-
'
|
|
827
|
-
'
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
991
|
+
const stateRoleDefinitions = await getStateRoleDefinitions(context);
|
|
992
|
+
const validStateCommonKeys = new Set([
|
|
993
|
+
'min',
|
|
994
|
+
'max',
|
|
995
|
+
'step',
|
|
996
|
+
'unit',
|
|
997
|
+
'def',
|
|
998
|
+
'defAck',
|
|
999
|
+
'desc',
|
|
1000
|
+
'read',
|
|
1001
|
+
'write',
|
|
1002
|
+
'role',
|
|
1003
|
+
'states',
|
|
1004
|
+
'workingID',
|
|
1005
|
+
'custom',
|
|
1006
|
+
'type',
|
|
1007
|
+
'name',
|
|
1008
|
+
'expert',
|
|
1009
|
+
]);
|
|
1010
|
+
|
|
1011
|
+
instanceObjects.forEach((instanceObject, index) => {
|
|
1012
|
+
if (!instanceObject || typeof instanceObject !== 'object' || Array.isArray(instanceObject)) {
|
|
1013
|
+
context.warnings.push(`[W1118] instanceObject[${index}] must be an object`);
|
|
1014
|
+
return;
|
|
834
1015
|
}
|
|
835
1016
|
|
|
836
|
-
if (
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
1017
|
+
if (
|
|
1018
|
+
instanceObject._id === undefined ||
|
|
1019
|
+
typeof instanceObject._id !== 'string' ||
|
|
1020
|
+
!instanceObject._id.trim()
|
|
1021
|
+
) {
|
|
1022
|
+
context.warnings.push(`[W1119] instanceObject[${index}] must define non-empty string "_id"`);
|
|
1023
|
+
}
|
|
843
1024
|
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
1025
|
+
if (instanceObject.type !== undefined && !instanceObjectValidTypes.includes(instanceObject.type)) {
|
|
1026
|
+
context.warnings.push(`[W1047] instanceObject type has an invalid type: ${instanceObject.type}`);
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
if (instanceObject.type !== 'state') {
|
|
1030
|
+
return;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
if (
|
|
1034
|
+
!instanceObject.common ||
|
|
1035
|
+
typeof instanceObject.common !== 'object' ||
|
|
1036
|
+
Array.isArray(instanceObject.common)
|
|
1037
|
+
) {
|
|
1038
|
+
context.warnings.push(
|
|
1039
|
+
`[W1120] instanceObject "${instanceObject._id || index}" with type "state" must have "common" object`,
|
|
1040
|
+
);
|
|
1041
|
+
return;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
if (typeof instanceObject.common.type !== 'string') {
|
|
1045
|
+
context.warnings.push(
|
|
1046
|
+
`[W1048] instanceObject common.type has an invalid type! Expected "string", received "${typeof instanceObject.common.type}"`,
|
|
1047
|
+
);
|
|
1048
|
+
} else if (!instanceObjectStateTypes.includes(instanceObject.common.type)) {
|
|
1049
|
+
context.warnings.push(
|
|
1050
|
+
`[W1049] instanceObject common.type has an invalid value: ${instanceObject.common.type}`,
|
|
1051
|
+
);
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
['min', 'max', 'step'].forEach(key => {
|
|
1055
|
+
if (instanceObject.common[key] !== undefined && typeof instanceObject.common[key] !== 'number') {
|
|
1056
|
+
context.warnings.push(
|
|
1057
|
+
`[W1121] instanceObject "${instanceObject._id || index}" common.${key} must be a number`,
|
|
1058
|
+
);
|
|
1059
|
+
}
|
|
1060
|
+
});
|
|
1061
|
+
|
|
1062
|
+
if (instanceObject.common.unit !== undefined && typeof instanceObject.common.unit !== 'string') {
|
|
1063
|
+
context.warnings.push(
|
|
1064
|
+
`[W1122] instanceObject "${instanceObject._id || index}" common.unit must be a string`,
|
|
1065
|
+
);
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
if (
|
|
1069
|
+
instanceObject.common.desc !== undefined &&
|
|
1070
|
+
typeof instanceObject.common.desc !== 'string' &&
|
|
1071
|
+
(typeof instanceObject.common.desc !== 'object' ||
|
|
1072
|
+
instanceObject.common.desc === null ||
|
|
1073
|
+
Array.isArray(instanceObject.common.desc))
|
|
1074
|
+
) {
|
|
1075
|
+
context.warnings.push(
|
|
1076
|
+
`[W1123] instanceObject "${instanceObject._id || index}" common.desc must be a string or object`,
|
|
1077
|
+
);
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
if (typeof instanceObject.common.read !== 'boolean') {
|
|
1081
|
+
context.warnings.push(
|
|
1082
|
+
`[W1124] instanceObject "${instanceObject._id || index}" common.read is mandatory and must be boolean`,
|
|
1083
|
+
);
|
|
1084
|
+
}
|
|
1085
|
+
if (typeof instanceObject.common.write !== 'boolean') {
|
|
1086
|
+
context.warnings.push(
|
|
1087
|
+
`[W1125] instanceObject "${instanceObject._id || index}" common.write is mandatory and must be boolean`,
|
|
1088
|
+
);
|
|
1089
|
+
}
|
|
1090
|
+
if (typeof instanceObject.common.role !== 'string' || !instanceObject.common.role.trim()) {
|
|
1091
|
+
context.warnings.push(
|
|
1092
|
+
`[W1126] instanceObject "${instanceObject._id || index}" common.role is mandatory and must be a non-empty string`,
|
|
1093
|
+
);
|
|
1094
|
+
}
|
|
1095
|
+
if (
|
|
1096
|
+
instanceObject.common.states !== undefined &&
|
|
1097
|
+
(typeof instanceObject.common.states !== 'number' &&
|
|
1098
|
+
typeof instanceObject.common.states !== 'string')
|
|
1099
|
+
) {
|
|
1100
|
+
context.warnings.push(
|
|
1101
|
+
`[W1127] instanceObject "${instanceObject._id || index}" common.states must be number or string`,
|
|
1102
|
+
);
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
if (instanceObject.common.defAck !== undefined && typeof instanceObject.common.defAck !== 'boolean') {
|
|
1106
|
+
context.warnings.push(
|
|
1107
|
+
`[W1128] instanceObject "${instanceObject._id || index}" common.defAck must be boolean`,
|
|
1108
|
+
);
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
if (instanceObject.common.expert !== undefined && typeof instanceObject.common.expert !== 'boolean') {
|
|
1112
|
+
context.warnings.push(
|
|
1113
|
+
`[W1136] instanceObject "${instanceObject._id || index}" common.expert must be boolean`,
|
|
1114
|
+
);
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
if (
|
|
1118
|
+
instanceObject.common.workingID !== undefined &&
|
|
1119
|
+
typeof instanceObject.common.workingID !== 'string'
|
|
1120
|
+
) {
|
|
1121
|
+
context.warnings.push(
|
|
1122
|
+
`[W1129] instanceObject "${instanceObject._id || index}" common.workingID must be string`,
|
|
1123
|
+
);
|
|
1124
|
+
}
|
|
1125
|
+
if (
|
|
1126
|
+
typeof instanceObject.common.type === 'string' &&
|
|
1127
|
+
!doesValueMatchStateType(instanceObject.common.def, instanceObject.common.type)
|
|
1128
|
+
) {
|
|
1129
|
+
context.warnings.push(
|
|
1130
|
+
`[W1130] instanceObject "${instanceObject._id || index}" common.def must match common.type "${instanceObject.common.type}"`,
|
|
1131
|
+
);
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
Object.keys(instanceObject.common).forEach(commonKey => {
|
|
1135
|
+
if (!validStateCommonKeys.has(commonKey)) {
|
|
1136
|
+
context.warnings.push(
|
|
1137
|
+
`[W1131] instanceObject "${instanceObject._id || index}" has unsupported common.${commonKey} attribute`,
|
|
1138
|
+
);
|
|
1139
|
+
}
|
|
1140
|
+
});
|
|
1141
|
+
|
|
1142
|
+
if (typeof instanceObject.common.role === 'string') {
|
|
1143
|
+
const roleForLookup = normalizeStateRoleForLookup(instanceObject.common.role);
|
|
1144
|
+
const roleDefinition = stateRoleDefinitions[roleForLookup];
|
|
1145
|
+
if (!roleDefinition) {
|
|
1146
|
+
context.warnings.push(
|
|
1147
|
+
`[W1132] instanceObject "${instanceObject._id || index}" common.role "${instanceObject.common.role}" is not a known ioBroker state role`,
|
|
1148
|
+
);
|
|
1149
|
+
return;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
if (
|
|
1153
|
+
roleDefinition.types &&
|
|
1154
|
+
typeof instanceObject.common.type === 'string' &&
|
|
1155
|
+
!roleDefinition.types.includes(instanceObject.common.type)
|
|
1156
|
+
) {
|
|
1157
|
+
context.warnings.push(
|
|
1158
|
+
`[W1133] instanceObject "${instanceObject._id || index}" role "${instanceObject.common.role}" expects common.type to be one of [${roleDefinition.types.join(', ')}], but found "${instanceObject.common.type}"`,
|
|
1159
|
+
);
|
|
1160
|
+
}
|
|
1161
|
+
if (
|
|
1162
|
+
typeof instanceObject.common.read === 'boolean' &&
|
|
1163
|
+
roleDefinition.read !== 'any' &&
|
|
1164
|
+
instanceObject.common.read !== roleDefinition.read
|
|
1165
|
+
) {
|
|
1166
|
+
context.warnings.push(
|
|
1167
|
+
`[W1134] instanceObject "${instanceObject._id || index}" role "${instanceObject.common.role}" expects common.read=${roleDefinition.read}`,
|
|
1168
|
+
);
|
|
1169
|
+
}
|
|
1170
|
+
if (
|
|
1171
|
+
typeof instanceObject.common.write === 'boolean' &&
|
|
1172
|
+
roleDefinition.write !== 'any' &&
|
|
1173
|
+
instanceObject.common.write !== roleDefinition.write
|
|
1174
|
+
) {
|
|
1175
|
+
context.warnings.push(
|
|
1176
|
+
`[W1135] instanceObject "${instanceObject._id || index}" role "${instanceObject.common.role}" expects common.write=${roleDefinition.write}`,
|
|
1177
|
+
);
|
|
852
1178
|
}
|
|
853
1179
|
}
|
|
854
1180
|
});
|
|
@@ -1144,6 +1470,20 @@ async function checkIOPackageJson(context) {
|
|
|
1144
1470
|
context.checks.push('"restartAdapters" check skipped as object not present.');
|
|
1145
1471
|
}
|
|
1146
1472
|
|
|
1473
|
+
if (context.ioPackageJson.common.nondeletable === true) {
|
|
1474
|
+
if (adaptersAllowedToUseNondeletable.includes(context.adapterName)) {
|
|
1475
|
+
context.checks.push(
|
|
1476
|
+
'"common.nondeletable=true" found in io-package.json for adapter allowed to use this flag',
|
|
1477
|
+
);
|
|
1478
|
+
} else {
|
|
1479
|
+
context.errors.push(
|
|
1480
|
+
'[E1084] "common.nondeletable=true" detected in io-package.json. This flag is reserved and must be removed.',
|
|
1481
|
+
);
|
|
1482
|
+
}
|
|
1483
|
+
} else {
|
|
1484
|
+
context.checks.push('"common.nondeletable" is not set to true in io-package.json');
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1147
1487
|
for (const blacklist in blacklistIOPackageJson) {
|
|
1148
1488
|
//console.log(`checking blacklist ${blacklist}`);
|
|
1149
1489
|
let tmp = context.ioPackageJson;
|