@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
package/lib/M5000_Code.js
CHANGED
|
@@ -184,6 +184,77 @@ function extractPackageName(importPath) {
|
|
|
184
184
|
return importPath.split('/')[0];
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
+
/**
|
|
188
|
+
* Recursively collect native keys used by jsonConfig password components.
|
|
189
|
+
* Password components inside a table are ignored because table encryption is not available.
|
|
190
|
+
*
|
|
191
|
+
* @param {any} node - Current json node
|
|
192
|
+
* @param {Map<string, Set<string>>} passwordLocations - native key -> set of locations
|
|
193
|
+
* @param {object} options - recursion state
|
|
194
|
+
* @param {string} options.filePath - admin file path
|
|
195
|
+
* @param {string} options.pathInFile - current path in json object
|
|
196
|
+
* @param {boolean} options.inTable - whether recursion currently is inside a table component
|
|
197
|
+
* @param {string | undefined} options.itemKey - item key from parent "items" object
|
|
198
|
+
*/
|
|
199
|
+
function collectJsonConfigPasswordFields(node, passwordLocations, options) {
|
|
200
|
+
if (!node || typeof node !== 'object') {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (Array.isArray(node)) {
|
|
205
|
+
node.forEach((entry, index) =>
|
|
206
|
+
collectJsonConfigPasswordFields(entry, passwordLocations, {
|
|
207
|
+
...options,
|
|
208
|
+
pathInFile: `${options.pathInFile}[${index}]`,
|
|
209
|
+
itemKey: undefined,
|
|
210
|
+
}),
|
|
211
|
+
);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const nodeType = typeof node.type === 'string' ? node.type : undefined;
|
|
216
|
+
const insideTable = options.inTable || nodeType === 'table';
|
|
217
|
+
|
|
218
|
+
if (nodeType === 'password' && !insideTable) {
|
|
219
|
+
const nativeKey =
|
|
220
|
+
typeof node.attr === 'string' && node.attr.trim()
|
|
221
|
+
? node.attr.trim()
|
|
222
|
+
: typeof options.itemKey === 'string'
|
|
223
|
+
? options.itemKey
|
|
224
|
+
: undefined;
|
|
225
|
+
|
|
226
|
+
if (nativeKey) {
|
|
227
|
+
if (!passwordLocations.has(nativeKey)) {
|
|
228
|
+
passwordLocations.set(nativeKey, new Set());
|
|
229
|
+
}
|
|
230
|
+
passwordLocations.get(nativeKey).add(`${options.filePath}:${options.pathInFile}`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (node.items && typeof node.items === 'object' && !Array.isArray(node.items)) {
|
|
235
|
+
for (const [itemKey, itemValue] of Object.entries(node.items)) {
|
|
236
|
+
collectJsonConfigPasswordFields(itemValue, passwordLocations, {
|
|
237
|
+
...options,
|
|
238
|
+
pathInFile: `${options.pathInFile}/items/${itemKey}`,
|
|
239
|
+
inTable: insideTable,
|
|
240
|
+
itemKey,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
for (const [key, value] of Object.entries(node)) {
|
|
246
|
+
if (key === 'items') {
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
collectJsonConfigPasswordFields(value, passwordLocations, {
|
|
250
|
+
...options,
|
|
251
|
+
pathInFile: `${options.pathInFile}/${key}`,
|
|
252
|
+
inTable: insideTable,
|
|
253
|
+
itemKey: undefined,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
187
258
|
/**
|
|
188
259
|
* Strip single-line and block comments from source code content.
|
|
189
260
|
* This is a best-effort approach: it handles the common cases but does not
|
|
@@ -200,6 +271,28 @@ function stripComments(content) {
|
|
|
200
271
|
return result;
|
|
201
272
|
}
|
|
202
273
|
|
|
274
|
+
/**
|
|
275
|
+
* Strip string literals and comments while preserving line positions.
|
|
276
|
+
* Used for API method detection to avoid false positives in comments/log strings.
|
|
277
|
+
*
|
|
278
|
+
* @param {string} content - Source file content
|
|
279
|
+
* @returns {string} Sanitized content
|
|
280
|
+
*/
|
|
281
|
+
function stripStringsAndCommentsPreserveLines(content) {
|
|
282
|
+
let result = content;
|
|
283
|
+
|
|
284
|
+
// Strip string literals first so comment markers inside strings are ignored
|
|
285
|
+
result = result.replace(/'([^'\\\r\n]|\\.)*'/g, match => `'${' '.repeat(match.length - 2)}'`);
|
|
286
|
+
result = result.replace(/"([^"\\\r\n]|\\.)*"/g, match => `"${' '.repeat(match.length - 2)}"`);
|
|
287
|
+
result = result.replace(/`(?:[^`\\]|\\.)*`/g, match => `\`${match.slice(1, -1).replace(/[^\n]/g, ' ')}\``);
|
|
288
|
+
|
|
289
|
+
// Strip comments while preserving newline positions
|
|
290
|
+
result = result.replace(/\/\*[\s\S]*?\*\//g, match => match.replace(/[^\n]/g, ' '));
|
|
291
|
+
result = result.replace(/\/\/[^\n\r]*/g, match => ' '.repeat(match.length));
|
|
292
|
+
|
|
293
|
+
return result;
|
|
294
|
+
}
|
|
295
|
+
|
|
203
296
|
/**
|
|
204
297
|
* Extract all require/import targets from source file content.
|
|
205
298
|
*
|
|
@@ -275,6 +368,8 @@ async function checkCode(context) {
|
|
|
275
368
|
'/admin/jsonTab.json',
|
|
276
369
|
'/admin/jsonTab.json5',
|
|
277
370
|
'/admin/blockly.js',
|
|
371
|
+
'/admin/custom.html',
|
|
372
|
+
'/admin/custom_m.html',
|
|
278
373
|
|
|
279
374
|
'/src-admin/package.json', // check if react is used
|
|
280
375
|
'/src-widgets/package.json', // check if react is used
|
|
@@ -302,7 +397,16 @@ async function checkCode(context) {
|
|
|
302
397
|
|
|
303
398
|
// Add all executable files (.js, .mjs, .cjs, .ts) to readFiles, excluding certain directories
|
|
304
399
|
const executableExtensions = ['.js', '.mjs', '.cjs', '.ts'];
|
|
305
|
-
const excludeDirsForExecutables = [
|
|
400
|
+
const excludeDirsForExecutables = [
|
|
401
|
+
'node_modules',
|
|
402
|
+
'admin',
|
|
403
|
+
'admin-src',
|
|
404
|
+
'doc',
|
|
405
|
+
'docs',
|
|
406
|
+
'.git',
|
|
407
|
+
'.vscode',
|
|
408
|
+
'.dev-server',
|
|
409
|
+
];
|
|
306
410
|
|
|
307
411
|
tempFilesList.forEach(filePath => {
|
|
308
412
|
// Skip files in excluded directories
|
|
@@ -649,6 +753,24 @@ async function checkCode(context) {
|
|
|
649
753
|
} else {
|
|
650
754
|
context.checks.push('admin/words.js found.');
|
|
651
755
|
}
|
|
756
|
+
|
|
757
|
+
// // Check if admin/index.html exists but materialize is used (W5055)
|
|
758
|
+
// // admin/index.html is for admin2, which is not needed when materialize is used
|
|
759
|
+
// if (context.filesList.includes('/admin/index.html')) {
|
|
760
|
+
// context.warnings.push(
|
|
761
|
+
// '[W5055] "admin/index.html" found but materialize is used. This file is for admin2 (old UI) and is outdated. Please consider removing it.',
|
|
762
|
+
// );
|
|
763
|
+
// }
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// Check if admin/custom.html or admin/custom_m.html exists - these are no longer supported (W5056)
|
|
767
|
+
const obsoleteCustomHtmlFiles = ['/admin/custom.html', '/admin/custom_m.html'];
|
|
768
|
+
for (const file of obsoleteCustomHtmlFiles) {
|
|
769
|
+
if (context.filesList.includes(file)) {
|
|
770
|
+
context.warnings.push(
|
|
771
|
+
`[W5056] "${file.replace(/^\//, '')}" is no longer supported. Please migrate to "admin/jsonCustom.json".`,
|
|
772
|
+
);
|
|
773
|
+
}
|
|
652
774
|
}
|
|
653
775
|
|
|
654
776
|
if (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'json') {
|
|
@@ -806,6 +928,19 @@ async function checkCode(context) {
|
|
|
806
928
|
}
|
|
807
929
|
}
|
|
808
930
|
|
|
931
|
+
// Check if admin/jsonCustom.json(5) exists but custom support is NOT declared (W5053)
|
|
932
|
+
if (
|
|
933
|
+
(context.filesList.includes('/admin/jsonCustom.json') ||
|
|
934
|
+
context.filesList.includes('/admin/jsonCustom.json5')) &&
|
|
935
|
+
!context.ioPackageJson.common.supportCustoms &&
|
|
936
|
+
!context.ioPackageJson.common.jsonCustom &&
|
|
937
|
+
!(context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.custom === 'json')
|
|
938
|
+
) {
|
|
939
|
+
context.warnings.push(
|
|
940
|
+
`[W5053] "admin/jsonCustom.json${context.filesList.includes('/admin/jsonCustom.json') ? '' : '5'}" found but custom support is not declared in io-package.json. Consider removing the file or declaring custom support.`,
|
|
941
|
+
);
|
|
942
|
+
}
|
|
943
|
+
|
|
809
944
|
if (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.tab === 'json') {
|
|
810
945
|
if (context['/admin/jsonTab.json'] || context['/admin/jsonTab.json5']) {
|
|
811
946
|
try {
|
|
@@ -853,10 +988,62 @@ async function checkCode(context) {
|
|
|
853
988
|
}
|
|
854
989
|
}
|
|
855
990
|
|
|
991
|
+
// Check password fields in admin jsonConfig files against protectedNative and encryptedNative
|
|
992
|
+
if (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'json') {
|
|
993
|
+
const protectedNative = new Set(
|
|
994
|
+
Array.isArray(context.ioPackageJson.protectedNative) ? context.ioPackageJson.protectedNative : [],
|
|
995
|
+
);
|
|
996
|
+
const encryptedNative = new Set(
|
|
997
|
+
Array.isArray(context.ioPackageJson.encryptedNative) ? context.ioPackageJson.encryptedNative : [],
|
|
998
|
+
);
|
|
999
|
+
const passwordLocations = new Map();
|
|
1000
|
+
|
|
1001
|
+
for (const adminFile of context.filesList) {
|
|
1002
|
+
if (!/^\/admin\/.+\.json5?$/.test(adminFile) || typeof context[adminFile] !== 'string') {
|
|
1003
|
+
continue;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
try {
|
|
1007
|
+
const parsed = adminFile.endsWith('.json5')
|
|
1008
|
+
? JSON5.parse(context[adminFile])
|
|
1009
|
+
: JSON.parse(context[adminFile]);
|
|
1010
|
+
collectJsonConfigPasswordFields(parsed, passwordLocations, {
|
|
1011
|
+
filePath: adminFile.replace(/^\//, ''),
|
|
1012
|
+
pathInFile: '$',
|
|
1013
|
+
inTable: false,
|
|
1014
|
+
itemKey: undefined,
|
|
1015
|
+
});
|
|
1016
|
+
} catch (e) {
|
|
1017
|
+
common.debug(`Skipping password field scan for ${adminFile}: ${e.message}`);
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
for (const [nativeKey, locations] of passwordLocations.entries()) {
|
|
1022
|
+
const locationList = [...locations].join(', ');
|
|
1023
|
+
if (!protectedNative.has(nativeKey)) {
|
|
1024
|
+
context.warnings.push(
|
|
1025
|
+
`[W5057] jsonConfig password field "${nativeKey}" (${locationList}) is not listed at "protectedNative" in io-package.json`,
|
|
1026
|
+
);
|
|
1027
|
+
}
|
|
1028
|
+
if (!encryptedNative.has(nativeKey)) {
|
|
1029
|
+
context.warnings.push(
|
|
1030
|
+
`[W5058] jsonConfig password field "${nativeKey}" (${locationList}) is not listed at "encryptedNative" in io-package.json`,
|
|
1031
|
+
);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
|
|
856
1036
|
if (context.ioPackageJson.common.blockly && !context['/admin/blockly.js']) {
|
|
857
1037
|
context.errors.push('[E5014] "/admin/blockly.js" not found, but blockly support is declared');
|
|
858
1038
|
}
|
|
859
1039
|
|
|
1040
|
+
// Check if admin/blockly.js exists but blockly support is NOT declared (W5054)
|
|
1041
|
+
if (!context.ioPackageJson.common.blockly && context.filesList.includes('/admin/blockly.js')) {
|
|
1042
|
+
context.warnings.push(
|
|
1043
|
+
'[W5054] "admin/blockly.js" found but blockly support is not declared in io-package.json. Consider removing the file or setting "common.blockly": true.',
|
|
1044
|
+
);
|
|
1045
|
+
}
|
|
1046
|
+
|
|
860
1047
|
if (context.ioPackageJson.common.javascriptRules) {
|
|
861
1048
|
if (!context.ioPackageJson.common.javascriptRules.url) {
|
|
862
1049
|
context.errors.push(
|
|
@@ -1091,7 +1278,7 @@ async function checkCode(context) {
|
|
|
1091
1278
|
}
|
|
1092
1279
|
}
|
|
1093
1280
|
|
|
1094
|
-
// Check for deprecated adapter methods
|
|
1281
|
+
// Check for deprecated adapter methods and discouraged setObject usage
|
|
1095
1282
|
const deprecatedMethods = [
|
|
1096
1283
|
'createState',
|
|
1097
1284
|
'createChannel',
|
|
@@ -1099,7 +1286,24 @@ async function checkCode(context) {
|
|
|
1099
1286
|
'deleteState',
|
|
1100
1287
|
'deleteChannel',
|
|
1101
1288
|
'deleteDevice',
|
|
1289
|
+
'setObject',
|
|
1102
1290
|
];
|
|
1291
|
+
const methodWarnings = {
|
|
1292
|
+
createState:
|
|
1293
|
+
'[W5033] method "createState()" is deprecated and will be removed with future js-controller version. Please use "set/deleteObject()" instead.',
|
|
1294
|
+
createChannel:
|
|
1295
|
+
'[W5033] method "createChannel()" is deprecated and will be removed with future js-controller version. Please use "set/deleteObject()" instead.',
|
|
1296
|
+
createDevice:
|
|
1297
|
+
'[W5033] method "createDevice()" is deprecated and will be removed with future js-controller version. Please use "set/deleteObject()" instead.',
|
|
1298
|
+
deleteState:
|
|
1299
|
+
'[W5033] method "deleteState()" is deprecated and will be removed with future js-controller version. Please use "set/deleteObject()" instead.',
|
|
1300
|
+
deleteChannel:
|
|
1301
|
+
'[W5033] method "deleteChannel()" is deprecated and will be removed with future js-controller version. Please use "set/deleteObject()" instead.',
|
|
1302
|
+
deleteDevice:
|
|
1303
|
+
'[W5033] method "deleteDevice()" is deprecated and will be removed with future js-controller version. Please use "set/deleteObject()" instead.',
|
|
1304
|
+
setObject:
|
|
1305
|
+
'[S5054] method "setObject()" should be avoided. Please use "setObjectNotExists()" or "extendObject()" instead.',
|
|
1306
|
+
};
|
|
1103
1307
|
|
|
1104
1308
|
/**
|
|
1105
1309
|
* Checks if a line is within an adapter class context by examining the code structure.
|
|
@@ -1221,9 +1425,10 @@ async function checkCode(context) {
|
|
|
1221
1425
|
|
|
1222
1426
|
const content = context[fileName];
|
|
1223
1427
|
const lines = content.split(/\r\n|\r|\n/g);
|
|
1428
|
+
const sanitizedLines = stripStringsAndCommentsPreserveLines(content).split(/\r\n|\r|\n/g);
|
|
1224
1429
|
|
|
1225
1430
|
for (let i = 0; i < lines.length; i++) {
|
|
1226
|
-
const
|
|
1431
|
+
const sanitizedLine = sanitizedLines[i];
|
|
1227
1432
|
|
|
1228
1433
|
for (const method of deprecatedMethods) {
|
|
1229
1434
|
// Skip if this method has already been reported
|
|
@@ -1231,24 +1436,24 @@ async function checkCode(context) {
|
|
|
1231
1436
|
continue;
|
|
1232
1437
|
}
|
|
1233
1438
|
|
|
1439
|
+
const searchLine = sanitizedLine;
|
|
1440
|
+
|
|
1234
1441
|
// Check for this.methodName pattern
|
|
1235
1442
|
const thisPattern = new RegExp(`\\bthis\\.${method}\\s*\\(`, 'g');
|
|
1236
1443
|
// Check for adapter.methodName pattern
|
|
1237
1444
|
const adapterPattern = new RegExp(`\\badapter\\.${method}\\s*\\(`, 'g');
|
|
1238
1445
|
|
|
1239
1446
|
// Handle this.method() calls - should warn when inside adapter class context
|
|
1240
|
-
if (thisPattern.test(
|
|
1447
|
+
if (thisPattern.test(searchLine)) {
|
|
1241
1448
|
// Make sure this is not a private function definition
|
|
1242
1449
|
const functionDefPattern = new RegExp(
|
|
1243
1450
|
`(function\\s+${method}|${method}\\s*[=:]\\s*function|${method}\\s*\\([^)]*\\)\\s*{)`,
|
|
1244
1451
|
'i',
|
|
1245
1452
|
);
|
|
1246
|
-
if (!functionDefPattern.test(
|
|
1453
|
+
if (!functionDefPattern.test(searchLine)) {
|
|
1247
1454
|
// Only warn if we're in an adapter class context
|
|
1248
1455
|
if (isInAdapterClassContext(lines, i)) {
|
|
1249
|
-
context.warnings.push(
|
|
1250
|
-
`[W5033] method "${method}()" is deprecated and will be removed with future js-controller version. Please use "set/deleteObject()" instead.`,
|
|
1251
|
-
);
|
|
1456
|
+
context.warnings.push(methodWarnings[method]);
|
|
1252
1457
|
reportedMethods.add(method);
|
|
1253
1458
|
break; // Only warn once per line
|
|
1254
1459
|
}
|
|
@@ -1256,18 +1461,16 @@ async function checkCode(context) {
|
|
|
1256
1461
|
}
|
|
1257
1462
|
|
|
1258
1463
|
// Handle adapter.method() calls - should warn when called outside of any class
|
|
1259
|
-
if (adapterPattern.test(
|
|
1464
|
+
if (adapterPattern.test(searchLine)) {
|
|
1260
1465
|
// Make sure this is not a private function definition
|
|
1261
1466
|
const functionDefPattern = new RegExp(
|
|
1262
1467
|
`(function\\s+${method}|${method}\\s*[=:]\\s*function|${method}\\s*\\([^)]*\\)\\s*{)`,
|
|
1263
1468
|
'i',
|
|
1264
1469
|
);
|
|
1265
|
-
if (!functionDefPattern.test(
|
|
1470
|
+
if (!functionDefPattern.test(searchLine)) {
|
|
1266
1471
|
// Warn if we're NOT in an adapter class context (outside any class)
|
|
1267
1472
|
if (!isInAdapterClassContext(lines, i)) {
|
|
1268
|
-
context.warnings.push(
|
|
1269
|
-
`[W5033] method "${method}()" is deprecated and will be removed with future js-controller version. Please use "set/deleteObject()" instead.`,
|
|
1270
|
-
);
|
|
1473
|
+
context.warnings.push(methodWarnings[method]);
|
|
1271
1474
|
reportedMethods.add(method);
|
|
1272
1475
|
break; // Only warn once per line
|
|
1273
1476
|
}
|
|
@@ -1282,17 +1485,21 @@ async function checkCode(context) {
|
|
|
1282
1485
|
const systemProvidedPackages = new Set(['@iobroker/plugin-sentry']);
|
|
1283
1486
|
|
|
1284
1487
|
// W5042/S5043: Scan source files for require/import statements and check dependencies
|
|
1285
|
-
// Exclude files in admin/, build/, doc/, src-admin/, admin-src/, test/ directories
|
|
1488
|
+
// Exclude files in admin/, build/, doc/, docs/, src-admin/, admin-src/, test/ directories
|
|
1286
1489
|
// and *.test.* and *.config.* files
|
|
1287
1490
|
const sourceFileExtensions = new Set(['.js', '.mjs', '.cjs', '.ts']);
|
|
1288
1491
|
const excludedSourceDirs = new Set([
|
|
1289
1492
|
'admin',
|
|
1290
1493
|
'build',
|
|
1291
1494
|
'doc',
|
|
1495
|
+
'docs',
|
|
1496
|
+
'template',
|
|
1497
|
+
'templates',
|
|
1292
1498
|
'src-admin',
|
|
1293
1499
|
'src-editor', // java-script adapter
|
|
1294
1500
|
'src-rules',
|
|
1295
1501
|
'src-widgets',
|
|
1502
|
+
'www',
|
|
1296
1503
|
'widgets',
|
|
1297
1504
|
'admin-src',
|
|
1298
1505
|
'rules-src',
|
|
@@ -1302,8 +1509,8 @@ async function checkCode(context) {
|
|
|
1302
1509
|
'.vscode',
|
|
1303
1510
|
'.dev-server',
|
|
1304
1511
|
]);
|
|
1305
|
-
// Exact file base names to exclude from
|
|
1306
|
-
const excludedSourceFiles = new Set(['tasks.js', 'Gruntfile.js', 'gulpfile.js']);
|
|
1512
|
+
// Exact file base names to exclude from scanning
|
|
1513
|
+
const excludedSourceFiles = new Set(['tasks.js', 'tasks.ts', 'Gruntfile.js', 'gulpfile.js']);
|
|
1307
1514
|
|
|
1308
1515
|
// Exact relative file paths (without leading slash) to exclude from dependency scanning
|
|
1309
1516
|
const excludedSourceRelPaths = new Set(['lib/tools.js']);
|
|
@@ -1447,7 +1654,7 @@ async function checkCode(context) {
|
|
|
1447
1654
|
);
|
|
1448
1655
|
} else {
|
|
1449
1656
|
context.warnings.push(
|
|
1450
|
-
`[W5042] Package "${packageName}" is used in source
|
|
1657
|
+
`[W5042] Package "${packageName}" is used in source file(s) (${filePath.slice(1)}) but not found in dependencies of package.json. Dependency might be missing.`,
|
|
1451
1658
|
);
|
|
1452
1659
|
}
|
|
1453
1660
|
|
|
@@ -1565,6 +1772,14 @@ exports.checkCode = checkCode;
|
|
|
1565
1772
|
// [E5050] process.exit() is called in source files (${fileList}). Calling process.exit() is incompatible with compact mode as it terminates the entire host process. Please avoid it.
|
|
1566
1773
|
// [W5050] process.exit() is called in source files (${fileList}). Calling process.exit() is discouraged in ioBroker adapters as it terminates the entire host process. Please avoid it.
|
|
1567
1774
|
// [S5051] Custom sleep/wait function(s) found in source files (${fileList}). Consider using the built-in "this.delay()" method provided by the ioBroker adapter base class instead.
|
|
1775
|
+
// [W5052] method "setObject()" should be avoided. Please use "setObjectNotExists()" or "extendObject()" instead.
|
|
1776
|
+
// [W5053] "admin/jsonCustom.json[5]" found but custom support is not declared in io-package.json. Consider removing the file or declaring custom support.
|
|
1777
|
+
// [W5054] "admin/blockly.js" found but blockly support is not declared in io-package.json. Consider removing the file or setting "common.blockly": true.
|
|
1778
|
+
// [W5055] "admin/index.html" found but materialize is used. This file is for admin2 (old UI) and is outdated. Please consider removing it.
|
|
1779
|
+
// [W5056] "admin/custom.html" or "admin/custom_m.html" is no longer supported. Please migrate to "admin/jsonCustom.json".
|
|
1780
|
+
// [W5057] jsonConfig password field "${nativeKey}" (${locationList}) is not listed at "protectedNative" in io-package.json
|
|
1781
|
+
// [W5058] jsonConfig password field "${nativeKey}" (${locationList}) is not listed at "encryptedNative" in io-package.json
|
|
1782
|
+
// [W5054] method "setObject()" should be avoided. Please use "setObjectNotExists()" or "extendObject()" instead.
|
|
1568
1783
|
// [W5515] Schema validation skipped for "${configFile}" due to parse error: ${e.message}
|
|
1569
1784
|
|
|
1570
1785
|
// [5500 - ] see M5500_jsonConfig.js
|
package/lib/M5500__JsonConfig.js
CHANGED
|
@@ -58,6 +58,48 @@ const stdAttributes = [
|
|
|
58
58
|
'#include',
|
|
59
59
|
];
|
|
60
60
|
|
|
61
|
+
// Mapping of component types to expected JavaScript types for their 'default' attribute.
|
|
62
|
+
// Components not listed here either don't use a default value or can hold mixed/arbitrary types.
|
|
63
|
+
const componentDefaultType = {
|
|
64
|
+
checkbox: ['boolean'],
|
|
65
|
+
|
|
66
|
+
number: ['number'],
|
|
67
|
+
port: ['number'],
|
|
68
|
+
slider: ['number'],
|
|
69
|
+
|
|
70
|
+
autocomplete: ['string'],
|
|
71
|
+
certificate: ['string'],
|
|
72
|
+
certificates: ['string'],
|
|
73
|
+
certificateCollection: ['string'],
|
|
74
|
+
color: ['string'],
|
|
75
|
+
cron: ['string'],
|
|
76
|
+
datePicker: ['string'],
|
|
77
|
+
file: ['string'],
|
|
78
|
+
fileSelector: ['string'],
|
|
79
|
+
func: ['string'],
|
|
80
|
+
image: ['string'],
|
|
81
|
+
imageSendTo: ['string'],
|
|
82
|
+
instance: ['string'],
|
|
83
|
+
interface: ['string'],
|
|
84
|
+
ip: ['string'],
|
|
85
|
+
language: ['string'],
|
|
86
|
+
license: ['string'],
|
|
87
|
+
objectId: ['string'],
|
|
88
|
+
password: ['string'],
|
|
89
|
+
pattern: ['string'],
|
|
90
|
+
room: ['string'],
|
|
91
|
+
setState: ['string'],
|
|
92
|
+
state: ['string'],
|
|
93
|
+
text: ['string'],
|
|
94
|
+
textSendTo: ['string'],
|
|
95
|
+
timePicker: ['string'],
|
|
96
|
+
user: ['string'],
|
|
97
|
+
uuid: ['string'],
|
|
98
|
+
yamlEditor: ['string'],
|
|
99
|
+
|
|
100
|
+
chips: ['array'],
|
|
101
|
+
};
|
|
102
|
+
|
|
61
103
|
const validComponents = {
|
|
62
104
|
accordion: { function: check_accordion, minAdmin: DEFAULT_MIN_ADMIN },
|
|
63
105
|
alive: { function: check_alive, minAdmin: DEFAULT_MIN_ADMIN },
|
|
@@ -529,6 +571,16 @@ function checkComponent(context, path, jsonConfig) {
|
|
|
529
571
|
} else {
|
|
530
572
|
common.debug(`no checks defined for component ${type}`);
|
|
531
573
|
}
|
|
574
|
+
|
|
575
|
+
// Check that the 'default' value type matches the expected type for this component
|
|
576
|
+
if (jsonConfig.default !== undefined && jsonConfig.default !== null && componentDefaultType[type] !== undefined) {
|
|
577
|
+
const defaultType = Array.isArray(jsonConfig.default) ? 'array' : typeof jsonConfig.default;
|
|
578
|
+
if (!componentDefaultType[type].includes(defaultType)) {
|
|
579
|
+
context.warnings.push(
|
|
580
|
+
`[W5516] type mismatch for "default" at ${path}: component "${type}" expects ${componentDefaultType[type].join(' or ')} but got ${defaultType}`,
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
532
584
|
}
|
|
533
585
|
|
|
534
586
|
function checkPanel(context, path, jsonConfig, isRoot) {
|
|
@@ -760,3 +812,5 @@ exports.validateJsonConfigSchema = validateJsonConfigSchema;
|
|
|
760
812
|
// [E5512] ${filePath} schema validation error: ${errorMsg}
|
|
761
813
|
// [W5513] Could not download schema for validation of ${filePath}
|
|
762
814
|
// [E5514] ${filePath} schema validation failed: ${error.message}
|
|
815
|
+
// [W5515] schema compilation failed: ${error.message}
|
|
816
|
+
// [W5516] type mismatch for "default" at ${path}: component "${type}" expects ${expectedType} but got ${actualType}
|
package/lib/M6000_Readme.js
CHANGED
|
@@ -82,6 +82,15 @@ const ENGLISH_WORD_THRESHOLD = 5;
|
|
|
82
82
|
// Minimum number of distinct German words that must be detected before raising an error
|
|
83
83
|
const GERMAN_WORD_DETECTION_LIMIT = 3;
|
|
84
84
|
|
|
85
|
+
// Keep this text in sync with the exact README wording required for adapters using the Sentry plugin.
|
|
86
|
+
const SENTRY_NOTICE_TEXT_1 =
|
|
87
|
+
'**This adapter uses Sentry libraries to automatically report exceptions and code errors to the developers.**';
|
|
88
|
+
const SENTRY_NOTICE_TEXT_2 =
|
|
89
|
+
'This adapter uses the service `Sentry.io` to automatically report exceptions and code errors';
|
|
90
|
+
const MARKDOWN_H1_REGEX = /^#\s+.+$/gm;
|
|
91
|
+
const MARKDOWN_H2_REGEX = /^##\s+.+$/gm;
|
|
92
|
+
const THIRD_H2_HEADER_INDEX = 2;
|
|
93
|
+
|
|
85
94
|
/**
|
|
86
95
|
* Search for all German words from the blacklist in the given text.
|
|
87
96
|
* Returns an array of all matching words (in detection order).
|
|
@@ -242,6 +251,18 @@ function isEnglishText(text) {
|
|
|
242
251
|
return foundCount >= ENGLISH_WORD_THRESHOLD;
|
|
243
252
|
}
|
|
244
253
|
|
|
254
|
+
function escapeRegExp(text) {
|
|
255
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Allow flexible whitespace so the required notice still matches if it is wrapped across lines in README.md.
|
|
259
|
+
const SENTRY_NOTICE_REGEX_1 = new RegExp(escapeRegExp(SENTRY_NOTICE_TEXT_1).replace(/\s+/g, '\\s+'));
|
|
260
|
+
const SENTRY_NOTICE_REGEX_2 = new RegExp(escapeRegExp(SENTRY_NOTICE_TEXT_2).replace(/\s+/g, '\\s+'));
|
|
261
|
+
|
|
262
|
+
function getSentryNoticeMatch(text) {
|
|
263
|
+
return SENTRY_NOTICE_REGEX_1.exec(text) || SENTRY_NOTICE_REGEX_2.exec(text);
|
|
264
|
+
}
|
|
265
|
+
|
|
245
266
|
function getAuthor(author) {
|
|
246
267
|
if (author && typeof author === 'object') {
|
|
247
268
|
return `${author.name} <${author.email}>`;
|
|
@@ -286,6 +307,41 @@ async function checkReadme(context) {
|
|
|
286
307
|
context.errors.push('[E6001] No README.md found');
|
|
287
308
|
} else {
|
|
288
309
|
context.checks.push('README.md found');
|
|
310
|
+
const h1Headers = [...data.matchAll(MARKDOWN_H1_REGEX)];
|
|
311
|
+
if (h1Headers.length !== 1) {
|
|
312
|
+
context.errors.push(
|
|
313
|
+
`[E6025] README.md must contain exactly one H1 heading, but found ${h1Headers.length}.`,
|
|
314
|
+
);
|
|
315
|
+
} else {
|
|
316
|
+
context.checks.push('README.md contains exactly one H1 heading');
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const sentryPluginConfigured =
|
|
320
|
+
context.ioPackageJson?.common?.plugins &&
|
|
321
|
+
typeof context.ioPackageJson.common.plugins === 'object' &&
|
|
322
|
+
Object.prototype.hasOwnProperty.call(context.ioPackageJson.common.plugins, 'sentry');
|
|
323
|
+
if (sentryPluginConfigured) {
|
|
324
|
+
const sentryNoticeMatch = getSentryNoticeMatch(data);
|
|
325
|
+
if (!sentryNoticeMatch) {
|
|
326
|
+
context.warnings.push(
|
|
327
|
+
'[W6023] Sentry plugin is configured in io-package.json but the required Sentry information was not found in README.md. Please add the standard Sentry notice near the top of README.md.',
|
|
328
|
+
);
|
|
329
|
+
} else {
|
|
330
|
+
context.checks.push('README.md contains the required Sentry information');
|
|
331
|
+
|
|
332
|
+
const levelTwoHeaders = [...data.matchAll(MARKDOWN_H2_REGEX)];
|
|
333
|
+
if (
|
|
334
|
+
levelTwoHeaders.length > THIRD_H2_HEADER_INDEX &&
|
|
335
|
+
sentryNoticeMatch.index > levelTwoHeaders[THIRD_H2_HEADER_INDEX].index
|
|
336
|
+
) {
|
|
337
|
+
context.warnings.push(
|
|
338
|
+
'[W6024] README.md contains the Sentry information, but it is located too far down in the document. Please move it near the top of README.',
|
|
339
|
+
);
|
|
340
|
+
} else {
|
|
341
|
+
context.checks.push('Sentry information is located near the top of README.md');
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
289
345
|
|
|
290
346
|
if (!data.includes('## Changelog')) {
|
|
291
347
|
context.errors.push('[E6003] NO "## Changelog" found in README.md');
|
|
@@ -562,3 +618,6 @@ exports.checkReadme = checkReadme;
|
|
|
562
618
|
// [S6020] Consider adding a CHANGELOG_OLD.md file to store older changelog entries. This file is supported by @alcalzone/releasescript.
|
|
563
619
|
// [W6021] "## License" is not the last section in README.md. The license section should be the last section.
|
|
564
620
|
// [S6022] CHANGELOG_OLD.md exists but no link to it was found in README.md. Consider adding a link to CHANGELOG_OLD.md at the end of the Changelog section.
|
|
621
|
+
// [W6023] Sentry plugin is configured in io-package.json but the required Sentry information was not found in README.md. Please add the standard Sentry notice near the top of README.md.
|
|
622
|
+
// [W6024] README.md contains the Sentry information, but it is located too far down in the document. Please move it before the third "##" section.
|
|
623
|
+
// [E6025] README.md must contain exactly one H1 heading, but found N.
|