@iobroker/repochecker 5.11.1 → 5.12.1

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/lib/M5000_Code.js CHANGED
@@ -106,9 +106,10 @@ function getAllFiles(context, dirPath, root, filesList) {
106
106
  filesList = getAllFiles(context, path.join(dirPath, file), [root, file].join('/'), filesList);
107
107
  }
108
108
  } else {
109
- filesList.push([root, file].join('/').slice(1));
110
- if (context.readFiles.includes([root, file].join('/').slice(1))) {
111
- context[[root, file].join('/')] = fs.readFileSync(path.join(dirPath, file), 'utf8');
109
+ const filePath = [root, file].join('/');
110
+ filesList.push(filePath);
111
+ if (context.readFiles && context.readFiles.includes(filePath)) {
112
+ context[filePath] = fs.readFileSync(path.join(dirPath, file), 'utf8');
112
113
  }
113
114
  }
114
115
  });
@@ -1022,7 +1023,7 @@ async function checkCode(context) {
1022
1023
  if (!context[`/${context.packageJson.main}`]) {
1023
1024
  if (!context.ioPackageJson.common.nogit) {
1024
1025
  context.errors.push(
1025
- `[E5019] "${context.packageJson.main}" found in package.json, but not found as file`,
1026
+ `[E5019] "${context.packageJson.main}" found in package.json, but not found as file. Please commit "build/*" tree to github or set "common.noGit" attribute to true at io-package.json.`,
1026
1027
  );
1027
1028
  }
1028
1029
  } else {
@@ -1313,6 +1314,15 @@ async function checkCode(context) {
1313
1314
  // Track packages already reported to avoid duplicate messages
1314
1315
  const reportedDependencyIssues = new Set();
1315
1316
 
1317
+ // Track files containing process.env for E5049/W5049 check
1318
+ const processEnvFiles = [];
1319
+
1320
+ // Track files containing process.exit for E5050/W5050 check
1321
+ const processExitFiles = [];
1322
+
1323
+ // Track files containing a sleep/wait function implementation for S5051 check
1324
+ const sleepFiles = [];
1325
+
1316
1326
  for (const filePath of Object.keys(context)) {
1317
1327
  if (!filePath.startsWith('/') || typeof context[filePath] !== 'string') {
1318
1328
  continue;
@@ -1347,6 +1357,23 @@ async function checkCode(context) {
1347
1357
 
1348
1358
  common.debug(`Scanning "${filePath.slice(1)}" for dependencies`);
1349
1359
 
1360
+ // E5049/W5049: Check for process.env usage (after stripping comments to avoid false positives)
1361
+ const contentWithoutComments = stripComments(context[filePath]);
1362
+ if (/\bprocess\.env\b/.test(contentWithoutComments)) {
1363
+ processEnvFiles.push(filePath.slice(1));
1364
+ }
1365
+
1366
+ // E5050/W5050: Check for process.exit() calls (after stripping comments to avoid false positives)
1367
+ if (/\bprocess\.exit\s*\(/.test(contentWithoutComments)) {
1368
+ processExitFiles.push(filePath.slice(1));
1369
+ }
1370
+
1371
+ // S5051: Check for custom sleep/wait function implementations (after stripping comments)
1372
+ // Matches: function sleep(...), async function sleep(...), const/let/var sleep = ..., and same for 'wait'
1373
+ if (/\bfunction\s+(sleep|wait)\s*\(|(?:const|let|var)\s+(sleep|wait)\s*=/.test(contentWithoutComments)) {
1374
+ sleepFiles.push(filePath.slice(1));
1375
+ }
1376
+
1350
1377
  const imports = extractImports(context[filePath]);
1351
1378
 
1352
1379
  for (const importTarget of imports) {
@@ -1428,6 +1455,46 @@ async function checkCode(context) {
1428
1455
  }
1429
1456
  }
1430
1457
 
1458
+ // E5049/W5049: Report process.env usage based on compact mode setting
1459
+ if (processEnvFiles.length > 0) {
1460
+ const fileList = processEnvFiles.join(', ');
1461
+ const compactValue = context.ioPackageJson.common.compact;
1462
+ if (compactValue === false) {
1463
+ context.warnings.push(
1464
+ `[W5049] process.env is used in source files (${fileList}). Usage of process.env is discouraged in ioBroker adapters.`,
1465
+ );
1466
+ } else {
1467
+ // compact is true or undefined — compact mode is active or may become active
1468
+ context.errors.push(
1469
+ `[E5049] process.env is used in source files (${fileList}). process.env is incompatible with compact mode. Please use adapter configuration instead.`,
1470
+ );
1471
+ }
1472
+ }
1473
+
1474
+ // E5050/W5050: Report process.exit() usage based on compact mode setting
1475
+ if (processExitFiles.length > 0) {
1476
+ const fileList = processExitFiles.join(', ');
1477
+ const compactValue = context.ioPackageJson.common.compact;
1478
+ if (compactValue === false) {
1479
+ context.warnings.push(
1480
+ `[S5050] process.exit() is called in source files (${fileList}). Calling process.exit() is discouraged in ioBroker adapters. Please avoid it.`,
1481
+ );
1482
+ } else {
1483
+ // compact is true or undefined — compact mode is active or may become active
1484
+ context.errors.push(
1485
+ `[E5050] process.exit() used in (${fileList}). This is incompatible with compact mode as it terminates the entire host process. Remove process.exit() or set common.compact to false at io-package.json.`,
1486
+ );
1487
+ }
1488
+ }
1489
+
1490
+ // S5051: Report custom sleep/wait function implementations
1491
+ if (sleepFiles.length > 0) {
1492
+ const fileList = sleepFiles.join(', ');
1493
+ context.warnings.push(
1494
+ `[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.`,
1495
+ );
1496
+ }
1497
+
1431
1498
  // 5500 - xxx reserved for jsonConfig module
1432
1499
 
1433
1500
  return context;
@@ -1493,6 +1560,11 @@ exports.checkCode = checkCode;
1493
1560
  // [W5046] "admin/jsonConfig.json" or "admin/jsonConfig.json5" found but "common.adminUI.config" is not set to "json" in io-package.json. Please add "common.adminUI": { "config": "json" }.
1494
1561
  // [W5047] "${file}" is most likely outdated since jsonConfig is used. Please consider removing it.
1495
1562
  // [W5048] "${file}" is most likely obsolete when using "@iobroker/eslint-config". Please remove it.
1563
+ // [E5049] process.env is used in source files (${fileList}). process.env is incompatible with compact mode. Please use adapter configuration instead.
1564
+ // [W5049] process.env is used in source files (${fileList}). Usage of process.env is discouraged in ioBroker adapters.
1565
+ // [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
+ // [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
+ // [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.
1496
1568
  // [W5515] Schema validation skipped for "${configFile}" due to parse error: ${e.message}
1497
1569
 
1498
1570
  // [5500 - ] see M5500_jsonConfig.js
@@ -327,6 +327,13 @@ async function checkReadme(context) {
327
327
  }
328
328
  } else {
329
329
  context.checks.push('CHANGELOG_OLD.md found');
330
+ if (!data.includes('CHANGELOG_OLD.md')) {
331
+ context.warnings.push(
332
+ '[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.',
333
+ );
334
+ } else {
335
+ context.checks.push('README.md contains link to CHANGELOG_OLD.md');
336
+ }
330
337
  }
331
338
  }
332
339
 
@@ -429,6 +436,16 @@ async function checkReadme(context) {
429
436
  `[W6011] Copyright lines in README.md are separated by empty line(s) at line(s) ${emptyLineBetweenCopyrightLines.join(', ')}. Remove the empty line(s) between copyright lines and terminate each line (except last) with two spaces.`,
430
437
  );
431
438
  }
439
+
440
+ // Check that ## License is the last ## section in README.md
441
+ const textAfterLicense = data.substring(pos + '## License'.length);
442
+ if (/\n## [^#]/.test(textAfterLicense)) {
443
+ context.warnings.push(
444
+ '[W6021] "## License" is not the last section in README.md. The license section should be the last section.',
445
+ );
446
+ } else {
447
+ context.checks.push('"## License" is the last section in README.md');
448
+ }
432
449
  }
433
450
 
434
451
  // Check for direct npm install instructions
@@ -543,3 +560,5 @@ exports.checkReadme = checkReadme;
543
560
  // [W6018] Both CHANGELOG.md and CHANGELOG_OLD.md files were found. Please check why both files exist.
544
561
  // [W6019] README.md changelog contains ${versionEntryCount} entries. Please consider moving older entries to a separate CHANGELOG_OLD.md file, which is supported by @alcalzone/releasescript.
545
562
  // [S6020] Consider adding a CHANGELOG_OLD.md file to store older changelog entries. This file is supported by @alcalzone/releasescript.
563
+ // [W6021] "## License" is not the last section in README.md. The license section should be the last section.
564
+ // [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.
@@ -15,6 +15,10 @@ const AUTOMERGE_FILE = '/.github/workflows/automerge-dependabot.yml';
15
15
  const OLD_AUTOMERGE_FILE = '/.github/workflows/dependabot-auto-merge.yml';
16
16
  const OLD_AUTOMERGE_FILE_OLD = '/.github/workflows/dependabot-auto-merge.yml.OLD';
17
17
  const AUTO_MERGE_CONFIG = '/.github/auto-merge.yml';
18
+ const WORKFLOW_DIR = '/.github/workflows/';
19
+
20
+ // GitHub organisations whose actions must use versioned references
21
+ const IOBROKER_ACTION_ORGS = ['iobroker', 'iobroker-community-adapters', 'iobroker-bot-orga'];
18
22
 
19
23
  /**
20
24
  * Returns true if the given file path exists in the context's filesList,
@@ -31,6 +35,121 @@ function fileExistsInList(context, filePath) {
31
35
  return context.filesList.includes(filePath) || context.filesList.includes(filePath.replace(/^\//, ''));
32
36
  }
33
37
 
38
+ /**
39
+ * Recursively collects all `uses:` string values from a parsed workflow object.
40
+ *
41
+ * @param {unknown} obj - A parsed YAML value (object, array, or primitive)
42
+ * @returns {string[]} All `uses:` string values found
43
+ */
44
+ function extractUsesValues(obj) {
45
+ const usesValues = [];
46
+ if (!obj || typeof obj !== 'object') {
47
+ return usesValues;
48
+ }
49
+ if (Array.isArray(obj)) {
50
+ for (const item of obj) {
51
+ usesValues.push(...extractUsesValues(item));
52
+ }
53
+ } else {
54
+ for (const [key, value] of Object.entries(obj)) {
55
+ if (key === 'uses' && typeof value === 'string') {
56
+ usesValues.push(value);
57
+ } else {
58
+ usesValues.push(...extractUsesValues(value));
59
+ }
60
+ }
61
+ }
62
+ return usesValues;
63
+ }
64
+
65
+ /**
66
+ * Returns true when a GitHub Actions `uses:` value references an ioBroker-owned action
67
+ * without a versioned tag (e.g. `@main`, `@master`, or missing `@ref`).
68
+ *
69
+ * A reference is considered versioned only when the part after `@` starts with `v`
70
+ * followed by a digit (e.g. `@v1`, `@v2.3`, `@v1.0.0`).
71
+ *
72
+ * @param {string} usesValue - The raw `uses:` string value
73
+ * @returns {boolean} true when the action belongs to an ioBroker org and uses a non-versioned ref
74
+ */
75
+ function isIoBrokerActionWithNonVersionedRef(usesValue) {
76
+ // `uses` for local actions (./path) or Docker actions (docker://) are not checked
77
+ if (usesValue.startsWith('./') || usesValue.startsWith('docker://')) {
78
+ return false;
79
+ }
80
+ // Extract the owner (the part before the first `/`)
81
+ const slashIndex = usesValue.indexOf('/');
82
+ if (slashIndex === -1) {
83
+ return false;
84
+ }
85
+ const owner = usesValue.substring(0, slashIndex).toLowerCase();
86
+ if (!IOBROKER_ACTION_ORGS.includes(owner)) {
87
+ return false;
88
+ }
89
+ // Check the ref after `@`
90
+ const atIndex = usesValue.lastIndexOf('@');
91
+ if (atIndex === -1) {
92
+ // No `@ref` at all — unversioned
93
+ return true;
94
+ }
95
+ const ref = usesValue.substring(atIndex + 1);
96
+ // Versioned: must start with `v` followed by a digit (e.g. v1, v2.3, v1.0.0)
97
+ return !/^v\d/.test(ref);
98
+ }
99
+
100
+ /**
101
+ * Checks all `.github/workflows/*.yml` / `.yaml` files for iobroker action references
102
+ * that do not use a versioned tag.
103
+ *
104
+ * @param {object} context - The checker context
105
+ */
106
+ async function checkWorkflowActionVersions(context) {
107
+ const workflowFiles = (context.filesList || []).filter(f => {
108
+ const normalized = f.startsWith('/') ? f : `/${f}`;
109
+ return normalized.startsWith(WORKFLOW_DIR) && (normalized.endsWith('.yml') || normalized.endsWith('.yaml'));
110
+ });
111
+
112
+ for (const filePath of workflowFiles) {
113
+ const normalizedPath = filePath.startsWith('/') ? filePath : `/${filePath}`;
114
+ let fileContent;
115
+ try {
116
+ fileContent = await common.getFile(context, normalizedPath);
117
+ } catch {
118
+ continue; // File unreadable – other checks will report this
119
+ }
120
+
121
+ if (!fileContent) {
122
+ continue;
123
+ }
124
+
125
+ let workflow;
126
+ try {
127
+ workflow = yaml.load(fileContent);
128
+ } catch {
129
+ continue; // Invalid YAML – other checks will report this
130
+ }
131
+
132
+ if (!workflow || typeof workflow !== 'object') {
133
+ continue;
134
+ }
135
+
136
+ const usesValues = extractUsesValues(workflow);
137
+ const shortPath = normalizedPath.replace(WORKFLOW_DIR, '');
138
+
139
+ for (const usesValue of usesValues) {
140
+ if (isIoBrokerActionWithNonVersionedRef(usesValue)) {
141
+ const atIndex = usesValue.lastIndexOf('@');
142
+ const refDesc =
143
+ atIndex !== -1 ? `non-versioned ref "@${usesValue.substring(atIndex + 1)}"` : 'no version tag';
144
+ context.warnings.push(
145
+ `[W8918] Workflow "${shortPath}" references ioBroker action "${usesValue}" with ${refDesc}. ` +
146
+ `Please use a versioned tag like "@v1".`,
147
+ );
148
+ }
149
+ }
150
+ }
151
+ }
152
+
34
153
  /**
35
154
  * Checks the automerge workflow configuration.
36
155
  *
@@ -109,6 +228,9 @@ async function checkAutomerge(context) {
109
228
  async function checkDependabot(context) {
110
229
  console.log('\n[E8900 - E8999] checking dependabot');
111
230
 
231
+ // W8918: Check all workflow files for non-versioned iobroker action references
232
+ await checkWorkflowActionVersions(context);
233
+
112
234
  // S8901: Check if dependabot.yml exists
113
235
  if (!fileExistsInList(context, DEPENDABOT_FILE)) {
114
236
  context.warnings.push(
@@ -255,6 +377,48 @@ async function checkDependabot(context) {
255
377
  }
256
378
  }
257
379
 
380
+ // W8917: Check for @types/node ignore on root or wildcard npm entries
381
+ if (hasNpm) {
382
+ const npmEntries = updates.filter(u => u['package-ecosystem'] === 'npm');
383
+ let missingTypesNodeIgnore = false;
384
+
385
+ for (const npmEntry of npmEntries) {
386
+ const entryDirectory = npmEntry['directory'];
387
+ const configuredDirectories = npmEntry['directories'];
388
+ const usesRootDirectory =
389
+ entryDirectory === '/' ||
390
+ (Array.isArray(configuredDirectories) &&
391
+ configuredDirectories.some(dir => dir === '**/*' || dir === '**' || dir === '/'));
392
+
393
+ if (!usesRootDirectory) {
394
+ continue;
395
+ }
396
+
397
+ const ignoreEntries = Array.isArray(npmEntry['ignore']) ? npmEntry['ignore'] : [];
398
+ const typesNodeIgnore = ignoreEntries.find(entry => entry && entry['dependency-name'] === '@types/node');
399
+ const updateTypes = typesNodeIgnore ? typesNodeIgnore['update-types'] : null;
400
+ const updateTypesList = Array.isArray(updateTypes)
401
+ ? updateTypes
402
+ : typeof updateTypes === 'string'
403
+ ? [updateTypes]
404
+ : [];
405
+ const hasRequiredUpdateType = updateTypesList.some(
406
+ type => type === 'version-update:semver-major' || type === 'version-update:semver-minor',
407
+ );
408
+
409
+ if (!hasRequiredUpdateType) {
410
+ missingTypesNodeIgnore = true;
411
+ break;
412
+ }
413
+ }
414
+
415
+ if (missingTypesNodeIgnore) {
416
+ context.warnings.push(
417
+ `[W8917] At least major versions of @types/node should not be updated by dependabot. Please add ignore block at dependabot.yml.`,
418
+ );
419
+ }
420
+ }
421
+
258
422
  // Check each update entry for schedule and open-pull-requests-limit issues
259
423
  const monthlyEcosystems = [];
260
424
  for (const update of updates) {
@@ -342,3 +506,5 @@ exports.checkDependabot = checkDependabot;
342
506
  // [S8914] Automerging is active but .github/auto-merge.yml not found.
343
507
  // [W8915] npm entry has no cooldown or cooldown < 5 days configured.
344
508
  // [W8916] Dependabot configuration "${DEPENDABOT_FILE}" has no entry with "package-ecosystem: github-actions". Please add one.
509
+ // [W8917] At east major versions of @types/node should not be updated by dependabot. Please add ignore block at dependabot.yml.
510
+ // [W8918] Workflow uses ioBroker action with non-versioned ref (e.g. @main, @master). Use a versioned tag like @v1.
package/lib/config.js CHANGED
@@ -428,6 +428,27 @@ const schemaUrls = {
428
428
  'https://raw.githubusercontent.com/ioBroker/ioBroker.admin/master/packages/jsonConfig/schemas/jsonConfig.json',
429
429
  };
430
430
 
431
+ const testingNodeJs = {
432
+ // Required minimum action versions
433
+ 'ioBroker/testing-action-check': 'v1',
434
+ 'ioBroker/testing-action-adapter': 'v1',
435
+ 'ioBroker/testing-action-deploy': 'v1',
436
+
437
+ // Node.js version requirements for non-matrix jobs
438
+ minimumNodeVersionCheckAndLint: '22',
439
+ recommendedNodeVersionCheckAndLint: '24',
440
+ minimumNodeVersionDeploy: '24',
441
+ recommendedNodeVersionDeploy: '24',
442
+
443
+ // Node.js versions for the adapter-tests matrix
444
+ validMatrixNodeVersions: ['20', '22', '24'], // valid versions to use in testing matrix
445
+ requiredMatrixNodeVersions: ['20', '22', '24'], // versions that MUST be present in testing matrix
446
+ recommendedMatrixNodeVersions: ['20', '22', '24'], // recommended versions that SHOULD be added to testing matrix
447
+
448
+ // Required operating systems for the adapter-tests matrix
449
+ requiredOsMatrix: ['ubuntu-latest', 'windows-latest', 'macos-latest'],
450
+ };
451
+
431
452
  function initConfig(context) {
432
453
  console.log('[init] initializing configuration');
433
454
 
@@ -439,6 +460,7 @@ function initConfig(context) {
439
460
  context.cfg.requiredLanguages = requiredLanguages;
440
461
  context.cfg.reservedAdapterNames = reservedAdapterNames;
441
462
  context.cfg.isNewAdapter = false;
463
+ context.cfg.testingNodeJs = testingNodeJs;
442
464
 
443
465
  return context;
444
466
  }
@@ -493,3 +515,4 @@ exports.initConfig = initConfig;
493
515
  exports.logEnvironment = logEnvironment;
494
516
  exports.updateConfig = updateConfig;
495
517
  exports.schemaUrls = schemaUrls;
518
+ exports.testingNodeJs = testingNodeJs;
@@ -24,15 +24,18 @@
24
24
  */
25
25
  const mapSeverity4New = {
26
26
  W0063: 'E', // [W0063] "@types/mocha, mocha, @types/sinon, sinon"
27
- W0028: 'E', // [W0028] Minimum node.js version 20 recommended.
27
+ W0028: 'E', // [W0028] Minimum node.js version 22 recommended.
28
28
  W1027: 'E', // [W1027] Missing suggested translation into ru,pt,nl,fr,it,es,pl,uk,zh-cn of "common.titleLang"
29
29
  W1032: 'E', // [W1032] Many "common.news" found in io-package.json
30
30
  W1034: 'E', // [W1034] Missing suggested translation into ru,pt,nl,fr,it,es,pl,uk,zh-cn of "common.desc"
31
- W1056: 'E', // [W1056] admin 7.6.17 listed as dependency but 7.6.20 is recommended.
32
- W2007: 'E', // [W2007] Version 0.7.0-beta.2 is tagged as "latest" at npm
31
+ W1056: 'E', // [W1056] admin 7.6.17 listed as dependency but 7.6.20 is reW1commended.
32
+ W1084: 'E', // [W1084] "common.title" is deprecated and replaced by "common.titleLang".
33
+ W2007: 'E', // [W2007] Version 0.7.0-beta.2 is tagged as "latest" at npm
33
34
  W3009: 'E', // [W3009] Workflow "test-and-release.yml" is missing recommended concurrency configuration.
35
+ W6021: 'E', // [W6021] "## License" is not the last section in README.md.
34
36
  W8915: 'E', // [W8915] Dependabot npm entry (directory: "/") has no "cooldown" configured.
35
37
  W8916: 'E', // [W8916] Dependabot configuration "/.github/dependabot.yml" has no entry with "package-ecosystem: github-actions".
38
+ W8917: 'E', // [W8917] At least major versions of @types/node should not be updated by dependabot.
36
39
  S0062: 'W', // [S0062] Consider adding and using package "@alcalzone/release-script".
37
40
  S3012: 'E', // [S3012] Workflow "test-and-release.yml": job "deploy" is not defined.
38
41
  S6008: 'E', // [S6008] Changelog for version 0.7.0-beta.19 should be added to README.md
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
- "version": "5.11.1",
2
+ "version": "5.12.1",
3
3
  "name": "@iobroker/repochecker",
4
4
  "dependencies": {
5
- "ajv": "^8.18.0",
6
- "axios": "^1.15.0",
5
+ "ajv": "^8.20.0",
6
+ "axios": "^1.15.2",
7
7
  "compare-versions": "^6.1.1",
8
8
  "image-size": "^1.2.0",
9
9
  "js-yaml": "^4.1.1",
@@ -15,7 +15,7 @@
15
15
  "@alcalzone/release-script": "^5.1.1",
16
16
  "@iobroker/eslint-config": "^2.2.0",
17
17
  "@tsconfig/node20": "^20.1.9",
18
- "@types/node": "^24.12.0",
18
+ "@types/node": "^22.19.17",
19
19
  "@types/semver": "^7.7.1"
20
20
  },
21
21
  "repository": {