@iobroker/repochecker 5.13.1 → 5.14.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.
@@ -69,7 +69,6 @@ function findTagTriggeredRun(workflowRuns, version, taggedVersion) {
69
69
 
70
70
  function checkTagTriggeredRun(context, workflowRuns, version, taggedVersion, codeBase, sourceLabel) {
71
71
  const tagRun = findTagTriggeredRun(workflowRuns, version, taggedVersion);
72
- const workflowUrl = `${context.githubUrlOriginal}/actions/workflows/${WORKFLOW_FILE_SHORT}`;
73
72
  if (!tagRun) {
74
73
  context.warnings.push(
75
74
  `[S${codeBase}] No workflow run for "${WORKFLOW_FILE_SHORT}" triggered by tag "${taggedVersion}" was found for ${sourceLabel}. ` +
@@ -106,7 +105,7 @@ function checkTagTriggeredRun(context, workflowRuns, version, taggedVersion, cod
106
105
  */
107
106
  function fileExistsInList(context, filePath) {
108
107
  if (!context.filesList) {
109
- return false;
108
+ throw new Error('FATAL: context.filesList is undefined');
110
109
  }
111
110
  // remote mode: paths have leading slash; local mode: paths don't have leading slash
112
111
  return context.filesList.includes(filePath) || context.filesList.includes(filePath.replace(/^\//, ''));
@@ -144,6 +143,24 @@ function getJobActionRefs(job, actionPrefix) {
144
143
  .filter(Boolean);
145
144
  }
146
145
 
146
+ function jobHasStepWithActionInputValue(job, actionPrefix, inputName, expectedValue) {
147
+ if (!job || !Array.isArray(job.steps)) {
148
+ return false;
149
+ }
150
+ return job.steps.some(step => {
151
+ if (typeof step.uses !== 'string' || !step.uses.startsWith(actionPrefix) || !step.with) {
152
+ return false;
153
+ }
154
+ const value = step.with[inputName];
155
+ if (typeof expectedValue === 'boolean') {
156
+ return (
157
+ value === expectedValue || (typeof value === 'string' && value.toLowerCase() === String(expectedValue))
158
+ );
159
+ }
160
+ return value === expectedValue;
161
+ });
162
+ }
163
+
147
164
  /**
148
165
  * Parses the major version from an action ref string.
149
166
  * Supports values like "v1", "1", "v2.3.4". Returns null for non-numeric refs like branch names.
@@ -159,6 +176,21 @@ function parseActionMajorVersion(ref) {
159
176
  return match ? parseInt(match[1], 10) : null;
160
177
  }
161
178
 
179
+ /**
180
+ * Returns true if the given action ref is an overly specific version reference
181
+ * (e.g., "v2.0" or "v2.0.0") rather than just a major version (e.g., "v2").
182
+ * Only returns true for numeric version refs with a minor or patch component.
183
+ *
184
+ * @param {string} ref - Action ref string
185
+ * @returns {boolean} true if the ref pins a specific minor/patch version
186
+ */
187
+ function isOverlySpecificVersionRef(ref) {
188
+ if (typeof ref !== 'string') {
189
+ return false;
190
+ }
191
+ return /^v?\d+\.\d/.test(ref.trim());
192
+ }
193
+
162
194
  /**
163
195
  * Returns true if the given job declares that it needs all of the specified jobs.
164
196
  *
@@ -296,6 +328,124 @@ function getMatrixOs(job) {
296
328
  return os;
297
329
  }
298
330
 
331
+ /**
332
+ * Returns OS entries from all steps that use the adapter testing action.
333
+ *
334
+ * @param {object} job - A GitHub Actions job object
335
+ * @param {string} actionPrefix - Action prefix (e.g. ioBroker/testing-action-adapter@)
336
+ * @returns {string[]} Array of OS entries from action step "with.os" or "with.runs-on"
337
+ */
338
+ function getAdapterActionStepOs(job, actionPrefix) {
339
+ if (!job || !Array.isArray(job.steps)) {
340
+ return [];
341
+ }
342
+
343
+ return job.steps
344
+ .filter(step => typeof step.uses === 'string' && step.uses.startsWith(actionPrefix))
345
+ .flatMap(step => {
346
+ const os = step.with && (step.with.os || step.with['runs-on']);
347
+ if (!os) {
348
+ return [];
349
+ }
350
+ if (Array.isArray(os)) {
351
+ return os.filter(v => typeof v === 'string');
352
+ }
353
+ if (typeof os === 'string') {
354
+ return os
355
+ .split(',')
356
+ .map(v => v.trim())
357
+ .filter(Boolean);
358
+ }
359
+ return [];
360
+ });
361
+ }
362
+
363
+ /**
364
+ * Maps a workflow/package OS entry to a normalized required OS system.
365
+ *
366
+ * @param {string} osEntry - OS entry value from workflow matrix or package.json
367
+ * @param {object} aliasMap - Map of alias -> normalized system
368
+ * @returns {string|null} Normalized OS system ("ubuntu", "windows", "macos") or null
369
+ */
370
+ function normalizeOsSystem(osEntry, aliasMap) {
371
+ if (typeof osEntry !== 'string') {
372
+ return null;
373
+ }
374
+ const normalized = osEntry.trim().toLowerCase();
375
+ if (!normalized) {
376
+ return null;
377
+ }
378
+ if (aliasMap[normalized]) {
379
+ return aliasMap[normalized];
380
+ }
381
+ const base = normalized.split('-')[0];
382
+ return aliasMap[base] || null;
383
+ }
384
+
385
+ /**
386
+ * Returns a normalized list of tested systems from workflow OS values.
387
+ *
388
+ * @param {string[]} osValues - Raw OS values from workflow
389
+ * @param {object} aliasMap - Map of alias -> normalized system
390
+ * @returns {string[]} Unique normalized systems
391
+ */
392
+ function normalizeWorkflowOsSystems(osValues, aliasMap) {
393
+ const systems = new Set();
394
+ for (const osValue of osValues) {
395
+ const system = normalizeOsSystem(osValue, aliasMap);
396
+ if (system) {
397
+ systems.add(system);
398
+ }
399
+ }
400
+ return [...systems];
401
+ }
402
+
403
+ /**
404
+ * Returns allowed required OS systems inferred from package.json os clause.
405
+ *
406
+ * @param {string|string[]|undefined} osClause - package.json "os" value
407
+ * @param {string[]} requiredSystems - required workflow systems
408
+ * @param {object} packageOsAliasMap - map of package.json os aliases
409
+ * @returns {Set<string>} Allowed required systems
410
+ */
411
+ function getAllowedRequiredOsSystems(osClause, requiredSystems, packageOsAliasMap) {
412
+ const required = new Set(requiredSystems);
413
+ if (!osClause) {
414
+ return new Set(requiredSystems);
415
+ }
416
+
417
+ const clauseEntries = Array.isArray(osClause) ? osClause : [osClause];
418
+ const positive = new Set();
419
+ const negative = new Set();
420
+
421
+ for (const rawEntry of clauseEntries) {
422
+ if (typeof rawEntry !== 'string') {
423
+ continue;
424
+ }
425
+ const entry = rawEntry.trim().toLowerCase();
426
+ if (!entry) {
427
+ continue;
428
+ }
429
+ const isNegative = entry.startsWith('!');
430
+ const key = isNegative ? entry.slice(1) : entry;
431
+ const system = packageOsAliasMap[key] || null;
432
+ if (!system || !required.has(system)) {
433
+ continue;
434
+ }
435
+ if (isNegative) {
436
+ negative.add(system);
437
+ } else {
438
+ positive.add(system);
439
+ }
440
+ }
441
+
442
+ const allowed = positive.size > 0 ? new Set(positive) : new Set(requiredSystems);
443
+ for (const system of negative) {
444
+ allowed.delete(system);
445
+ }
446
+ return allowed;
447
+ }
448
+
299
449
  async function checkTests(context) {
300
450
  console.log('\n[E3000 - E3999] checking tests');
301
451
 
@@ -406,7 +556,7 @@ async function checkTests(context) {
406
556
  const hasDefaultBranch = branches.includes(defaultBranch);
407
557
  if (!hasWildcard && !hasDefaultBranch) {
408
558
  context.errors.push(
409
- `[E3007] Workflow "${WORKFLOW_FILE_SHORT}": "push" trigger "branches" must include "*" or the default branch "${defaultBranch}". ` +
559
+ `[E3037] Workflow "${WORKFLOW_FILE_SHORT}": "push" trigger "branches" must include "*" or the default branch "${defaultBranch}". ` +
410
560
  `Found: ${JSON.stringify(branches)}`,
411
561
  );
412
562
  } else {
@@ -427,7 +577,7 @@ async function checkTests(context) {
427
577
  const missingPatterns = requiredTagPatterns.filter(pat => !cleanedTags.includes(pat));
428
578
  if (missingPatterns.length > 0) {
429
579
  context.errors.push(
430
- `[E3008] Workflow "${WORKFLOW_FILE_SHORT}": "push" trigger "tags" is missing required pattern(s): ${missingPatterns.join(', ')}`,
580
+ `[E3040] Workflow "${WORKFLOW_FILE_SHORT}": "push" trigger "tags" is missing required pattern(s): ${missingPatterns.join(', ')}`,
431
581
  );
432
582
  } else {
433
583
  context.checks.push('Workflow "push" trigger tags are correctly configured.');
@@ -461,7 +611,7 @@ async function checkTests(context) {
461
611
  const lastRun = workflowRuns[0];
462
612
  if (lastRun.conclusion === 'cancelled') {
463
613
  context.warnings.push(
464
- `[W3031] Latest workflow run of "${WORKFLOW_FILE_SHORT}" was cancelled ${formatRunLink(lastRun)}.`,
614
+ `[W3041] Latest workflow run of "${WORKFLOW_FILE_SHORT}" was cancelled ${formatRunLink(lastRun)}.`,
465
615
  );
466
616
  } else if (lastRun.conclusion === 'failure') {
467
617
  context.errors.push(
@@ -630,6 +780,25 @@ async function checkTests(context) {
630
780
  `which is below the required version "${requiredCheckActionVersion}".`,
631
781
  );
632
782
  }
783
+
784
+ // S3042: warn if a too-specific version ref (e.g. v2.0.0) is used instead of major version only (e.g. v2)
785
+ for (const ref of usedRefs.filter(isOverlySpecificVersionRef)) {
786
+ const majorVersion = `v${parseActionMajorVersion(ref)}`;
787
+ context.warnings.push(
788
+ `[S3042] Workflow "${WORKFLOW_FILE_SHORT}": job "check-and-lint" uses "ioBroker/testing-action-check@${ref}" ` +
789
+ `with a pinned version. Consider locking only the major version "@${majorVersion}" instead.`,
790
+ );
791
+ }
792
+
793
+ if (!jobHasStepWithActionInputValue(jobs['check-and-lint'], checkActionPrefix, 'lint', true)) {
794
+ context.warnings.push(
795
+ `[S3045] Workflow "${WORKFLOW_FILE_SHORT}": job "check-and-lint" should enable linting by setting "lint: true" for "ioBroker/testing-action-check@${requiredCheckActionVersion}".`,
796
+ );
797
+ } else {
798
+ context.checks.push(
799
+ `Job "check-and-lint" enables "lint: true" for "ioBroker/testing-action-check@${requiredCheckActionVersion}".`,
800
+ );
801
+ }
633
802
  }
634
803
 
635
804
  // E3020 / S3021: check node.js version for check-and-lint job
@@ -696,6 +865,15 @@ async function checkTests(context) {
696
865
  `which is below the required version "${requiredAdapterActionVersion}".`,
697
866
  );
698
867
  }
868
+
869
+ // S3043: warn if a too-specific version ref (e.g. v2.0.0) is used instead of major version only (e.g. v2)
870
+ for (const ref of usedRefs.filter(isOverlySpecificVersionRef)) {
871
+ const majorVersion = `v${parseActionMajorVersion(ref)}`;
872
+ context.warnings.push(
873
+ `[S3043] Workflow "${WORKFLOW_FILE_SHORT}": job "adapter-tests" uses "ioBroker/testing-action-adapter@${ref}" ` +
874
+ `with a pinned version. Consider locking only the major version "@${majorVersion}" instead.`,
875
+ );
876
+ }
699
877
  }
700
878
 
701
879
  // W3024 / E3025 / W3026: check node.js version matrix for adapter-tests
@@ -748,18 +926,46 @@ async function checkTests(context) {
748
926
  }
749
927
  }
750
928
 
751
- // W3027: check OS matrix for adapter-tests
929
+ // W3027 / S3031: check required OS coverage for adapter-tests
930
+ const requiredOsSystems = testingCfg.requiredOsSystems || ['ubuntu', 'windows', 'macos'];
931
+ const workflowOsAliasMap = testingCfg.workflowOsAliasMap || {};
932
+ const packageOsAliasMap = testingCfg.packageOsAliasMap || {};
933
+
752
934
  const matrixOs = getMatrixOs(jobs['adapter-tests']);
753
- if (matrixOs.length > 0) {
754
- const missingOs = testingCfg.requiredOsMatrix.filter(os => !matrixOs.includes(os));
755
- if (missingOs.length > 0) {
935
+ const osValues =
936
+ matrixOs.length > 0 ? matrixOs : getAdapterActionStepOs(jobs['adapter-tests'], adapterActionPrefix);
937
+ const osSource = matrixOs.length > 0 ? 'matrix' : 'ioBroker/testing-action-adapter step configuration';
938
+ const testedSystems = normalizeWorkflowOsSystems(osValues, workflowOsAliasMap);
939
+ const missingSystems = requiredOsSystems.filter(system => !testedSystems.includes(system));
940
+
941
+ if (missingSystems.length === 0) {
942
+ context.checks.push(
943
+ `Job "adapter-tests" covers all required operating systems (${requiredOsSystems.join(', ')}) via ${osSource}.`,
944
+ );
945
+ } else {
946
+ const packageOsClause = context.packageJson && context.packageJson.os;
947
+ const allowedSystems = getAllowedRequiredOsSystems(
948
+ packageOsClause,
949
+ requiredOsSystems,
950
+ packageOsAliasMap,
951
+ );
952
+ const excludedMissingSystems = missingSystems.filter(system => !allowedSystems.has(system));
953
+ if (excludedMissingSystems.length > 0) {
954
+ context.warnings.push(
955
+ `[S3031] package.json "os" excludes required OS systems (${excludedMissingSystems.join(', ')}). ` +
956
+ `Please verify whether adapter support can be extended.`,
957
+ );
958
+ }
959
+
960
+ const uncoveredMissingSystems = missingSystems.filter(system => allowedSystems.has(system));
961
+ if (uncoveredMissingSystems.length > 0) {
756
962
  context.warnings.push(
757
- `[W3027] Workflow "${WORKFLOW_FILE_SHORT}": job "adapter-tests" OS matrix is missing: ${missingOs.join(', ')}. ` +
758
- `Consider adding tests for all of: ${testingCfg.requiredOsMatrix.join(', ')}.`,
963
+ `[W3027] Workflow "${WORKFLOW_FILE_SHORT}": testing for OS ${uncoveredMissingSystems.join(', ')} is missing in job "adapter-tests". ` +
964
+ `Add corresponding tests to "${WORKFLOW_FILE_SHORT}" or adapt package.json "os" accordingly.`,
759
965
  );
760
966
  } else {
761
967
  context.checks.push(
762
- `Job "adapter-tests" OS matrix includes all required systems (${testingCfg.requiredOsMatrix.join(', ')}).`,
968
+ `Missing OS tests (${missingSystems.join(', ')}) are covered by package.json "os" restrictions.`,
763
969
  );
764
970
  }
765
971
  }
@@ -808,6 +1014,15 @@ async function checkTests(context) {
808
1014
  );
809
1015
  }
810
1016
 
1017
+ // S3044: warn if a too-specific version ref (e.g. v2.0.0) is used instead of major version only (e.g. v2)
1018
+ for (const ref of usedRefs.filter(isOverlySpecificVersionRef)) {
1019
+ const majorVersion = `v${parseActionMajorVersion(ref)}`;
1020
+ context.warnings.push(
1021
+ `[S3044] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" uses "ioBroker/testing-action-deploy@${ref}" ` +
1022
+ `with a pinned version. Consider locking only the major version "@${majorVersion}" instead.`,
1023
+ );
1024
+ }
1025
+
811
1026
  // S3018: check trusted publishing permissions at job level
812
1027
  const permissions = jobs['deploy'].permissions;
813
1028
  const hasContentsWrite = permissions && permissions.contents === 'write';
@@ -869,3 +1084,56 @@ async function checkTests(context) {
869
1084
  }
870
1085
 
871
1086
  exports.checkTests = checkTests;
1087
+
1088
+ // List of error and warnings used at this module
1089
+ // ----------------------------------------------
1090
+
1091
+ // [E3000] Neither "@iobroker/testing" nor "@iobroker/legacy-testing" is listed as a devDependency in package.json. Please add one of them.
1092
+ // [S3001] "@iobroker/legacy-testing" is used. Consider migrating to "@iobroker/testing" for better support.
1093
+ // [E3002] Workflow file "${WORKFLOW_FILE}" not found. Please create it for standard CI/CD testing.
1094
+ // [E3003] Workflow file "${WORKFLOW_FILE}" could not be read, is empty, not valid YAML, or does not contain valid workflow content.
1095
+ // [W3004] Workflow "name" in "${WORKFLOW_FILE_SHORT}" must be "Test and Release".
1096
+ // [W3005] Workflow "${WORKFLOW_FILE_SHORT}" should have "pull_request: {}" in the "on" trigger configuration.
1097
+ // [E3006] Workflow "${WORKFLOW_FILE_SHORT}" is missing the "push" trigger in the "on" configuration.
1098
+ // [E3007] Workflow "${WORKFLOW_FILE_SHORT}": "push" trigger is missing "branches" configuration.
1099
+ // [E3008] Workflow "${WORKFLOW_FILE_SHORT}": "push" trigger is missing "tags" configuration.
1100
+ // [W3009] Workflow "${WORKFLOW_FILE_SHORT}" is missing recommended concurrency configuration.
1101
+ // [S3010] Workflow "${WORKFLOW_FILE_SHORT}": job "check-and-lint" is missing. Consider adding it.
1102
+ // [E3010] Workflow "${WORKFLOW_FILE_SHORT}": job "check-and-lint" is missing. Please add it.
1103
+ // [E3011] Workflow "${WORKFLOW_FILE_SHORT}": job "adapter-tests" is missing. Please add it.
1104
+ // [S3012] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" is not defined. Consider adding it for automated releases.
1105
+ // [W3013] Workflow "${WORKFLOW_FILE_SHORT}": job "check-and-lint" should contain a step using "ioBroker/testing-action-check@${requiredCheckActionVersion}".
1106
+ // [S3014] Workflow "${WORKFLOW_FILE_SHORT}": job "adapter-tests" should declare "needs: check-and-lint" to run after linting.
1107
+ // [W3015] Workflow "${WORKFLOW_FILE_SHORT}": job "adapter-tests" should contain a step using "ioBroker/testing-action-adapter@${requiredAdapterActionVersion}".
1108
+ // [E3016] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" must declare "needs" for both "check-and-lint" and "adapter-tests".
1109
+ // [W3017] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" should contain a step using "ioBroker/testing-action-deploy@${requiredDeployActionVersion}".
1110
+ // [S3018] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" is missing required permissions "contents: write" and "id-token: write" at job level.
1111
+ // [W3019] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" step using "ioBroker/testing-action-deploy@v1" has "npm-token" parameter specified.
1112
+ // [E3020] Workflow "${WORKFLOW_FILE_SHORT}": job "check-and-lint" uses node.js ${checkLintNodeVersion} which is below the minimum required version.
1113
+ // [S3021] Workflow "${WORKFLOW_FILE_SHORT}": job "check-and-lint" uses node.js ${checkLintNodeVersion}. Consider updating.
1114
+ // [E3022] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" uses node.js ${deployNodeVersion} which is below the minimum required version.
1115
+ // [S3023] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" uses node.js ${deployNodeVersion}. Consider updating.
1116
+ // [W3024] Workflow "${WORKFLOW_FILE_SHORT}": job "adapter-tests" matrix uses node.js ${v} which is below the minimum required version.
1117
+ // [E3025] Workflow "${WORKFLOW_FILE_SHORT}": job "adapter-tests" matrix is missing required node.js version ${v}.
1118
+ // [W3026] Workflow "${WORKFLOW_FILE_SHORT}": job "adapter-tests" matrix is missing recommended node.js version ${v}.
1119
+ // [W3027] Workflow "${WORKFLOW_FILE_SHORT}": testing for OS ${uncoveredMissingSystems} is missing.
1120
+ // [W3028] Workflow "${WORKFLOW_FILE_SHORT}": job "check-and-lint" uses "ioBroker/testing-action-check@${lowerRef}" which is below the required version.
1121
+ // [W3029] Workflow "${WORKFLOW_FILE_SHORT}": job "adapter-tests" uses "ioBroker/testing-action-adapter@${lowerRef}" which is below the required version.
1122
+ // [W3030] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" uses "ioBroker/testing-action-deploy@${lowerRef}" which is below the required version.
1123
+ // [W3031] No workflow runs found for "${WORKFLOW_FILE_SHORT}".
1124
+ // [E3031] Latest workflow run of "${WORKFLOW_FILE_SHORT}" failed.
1125
+ // [S3031] package.json "os" excludes required OS systems.
1126
+ // [W3032] Release ${currentRelease} from io-package.json/package.json has not yet been tagged. Tagging releases is required.
1127
+ // [W3033] Could not validate npm release information because adapter name "${adapterName}" is not in a valid npm package name format.
1128
+ // [E3034] Release ${npmLatestRelease} tagged as "latest" at npm has not yet been tagged at GitHub. Tagging of releases is required.
1129
+ // [W3035] No workflow run for "${WORKFLOW_FILE_SHORT}" triggered by tag "${taggedVersion}" was found for ...
1130
+ // [E3036] Newest npm release ${newestNpmRelease} has not yet been tagged at GitHub. Tagging of releases is required.
1131
+ // [E3037] Workflow "${WORKFLOW_FILE_SHORT}": "push" trigger "branches" must include "*" or the default branch.
1132
+ // [W3038] Could not retrieve npm release information for testing checks: ${e.message}
1133
+ // [W3039] Could not retrieve workflow run data for "${WORKFLOW_FILE_SHORT}": ${e.message}
1134
+ // [E3040] Workflow "${WORKFLOW_FILE_SHORT}": "push" trigger "tags" is missing required pattern(s).
1135
+ // [W3041] Latest workflow run of "${WORKFLOW_FILE_SHORT}" was cancelled.
1136
+ // [S3042] Workflow "${WORKFLOW_FILE_SHORT}": job "check-and-lint" uses "ioBroker/testing-action-check@${ref}" with a pinned version. Consider locking only the major version.
1137
+ // [S3043] Workflow "${WORKFLOW_FILE_SHORT}": job "adapter-tests" uses "ioBroker/testing-action-adapter@${ref}" with a pinned version. Consider locking only the major version.
1138
+ // [S3044] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" uses "ioBroker/testing-action-deploy@${ref}" with a pinned version. Consider locking only the major version.
1139
+ // [S3045] Workflow "${WORKFLOW_FILE_SHORT}": job "check-and-lint" should enable linting by setting "lint: true".
package/lib/M5000_Code.js CHANGED
@@ -1304,6 +1304,8 @@ async function checkCode(context) {
1304
1304
  setObject:
1305
1305
  '[S5054] method "setObject()" should be avoided. Please use "setObjectNotExists()" or "extendObject()" instead.',
1306
1306
  };
1307
+ const letsEncryptWarning =
1308
+ '[W5061] "utils.commonTools.letsEncrypt" usage detected. Let\'s Encrypt support was removed in js-controller 6.';
1307
1309
 
1308
1310
  /**
1309
1311
  * Checks if a line is within an adapter class context by examining the code structure.
@@ -1404,6 +1406,7 @@ async function checkCode(context) {
1404
1406
 
1405
1407
  // Track which deprecated methods have already been reported
1406
1408
  const reportedMethods = new Set();
1409
+ let reportedLetsEncryptUsage = false;
1407
1410
 
1408
1411
  // Search through all loaded executable files for deprecated method usage
1409
1412
  for (const fileName of Object.keys(context)) {
@@ -1430,6 +1433,11 @@ async function checkCode(context) {
1430
1433
  for (let i = 0; i < lines.length; i++) {
1431
1434
  const sanitizedLine = sanitizedLines[i];
1432
1435
 
1436
+ if (!reportedLetsEncryptUsage && /\butils\.commonTools\.letsEncrypt\b/.test(sanitizedLine)) {
1437
+ context.warnings.push(letsEncryptWarning);
1438
+ reportedLetsEncryptUsage = true;
1439
+ }
1440
+
1433
1441
  for (const method of deprecatedMethods) {
1434
1442
  // Skip if this method has already been reported
1435
1443
  if (reportedMethods.has(method)) {
@@ -1481,6 +1489,46 @@ async function checkCode(context) {
1481
1489
  }
1482
1490
  }
1483
1491
 
1492
+ // W5059: Do not use utils.adapter() when adapter uses class mode
1493
+ const mainFilePath = context.packageJson.main ? `/${context.packageJson.main}` : '';
1494
+ const mainSource =
1495
+ typeof context[mainFilePath] === 'string' ? stripStringsAndCommentsPreserveLines(context[mainFilePath]) : '';
1496
+ const usesClassMode = /\bclass\s+\w+\s+extends\s+utils\.Adapter\b/i.test(mainSource);
1497
+
1498
+ if (usesClassMode) {
1499
+ const utilsAdapterFiles = [];
1500
+ const utilsAdapterPattern = /\butils\.adapter\s*\(/i;
1501
+
1502
+ for (const filePath of Object.keys(context)) {
1503
+ if (!filePath.startsWith('/') || typeof context[filePath] !== 'string') {
1504
+ continue;
1505
+ }
1506
+
1507
+ const pathParts = filePath.split('/').filter(part => part !== '');
1508
+ const isInExcludedDir = pathParts.some(part => excludeDirsForExecutables.includes(part));
1509
+ if (isInExcludedDir) {
1510
+ continue;
1511
+ }
1512
+
1513
+ const ext = path.extname(filePath);
1514
+ const executableExtensions = ['.js', '.mjs', '.cjs', '.ts'];
1515
+ if (!executableExtensions.includes(ext)) {
1516
+ continue;
1517
+ }
1518
+
1519
+ const sourceWithoutComments = stripStringsAndCommentsPreserveLines(context[filePath]);
1520
+ if (utilsAdapterPattern.test(sourceWithoutComments)) {
1521
+ utilsAdapterFiles.push(filePath.slice(1));
1522
+ }
1523
+ }
1524
+
1525
+ if (utilsAdapterFiles.length > 0) {
1526
+ context.warnings.push(
1527
+ `[W5059] Adapter uses class mode ("class ... extends utils.Adapter") in "${context.packageJson.main}" and also uses "utils.adapter(...)" in source file(s): ${utilsAdapterFiles.join(', ')}. Please use only one adapter pattern.`,
1528
+ );
1529
+ }
1530
+ }
1531
+
1484
1532
  // Packages known to be provided by the js-controller/system and therefore not required as dependencies
1485
1533
  const systemProvidedPackages = new Set(['@iobroker/plugin-sentry']);
1486
1534
 
@@ -1517,6 +1565,16 @@ async function checkCode(context) {
1517
1565
 
1518
1566
  const packageDependencies = context.packageJson.dependencies || {};
1519
1567
  const packageDevDependencies = context.packageJson.devDependencies || {};
1568
+ const usedPackageDependencies = new Set();
1569
+ const implicitRuntimeDependencies = new Set();
1570
+
1571
+ if (context.ioPackageJson.common.plugins && typeof context.ioPackageJson.common.plugins === 'object') {
1572
+ for (const pluginName of Object.keys(context.ioPackageJson.common.plugins)) {
1573
+ if (pluginName !== 'sentry') {
1574
+ implicitRuntimeDependencies.add(`@iobroker/plugin-${pluginName}`);
1575
+ }
1576
+ }
1577
+ }
1520
1578
 
1521
1579
  // Track packages already reported to avoid duplicate messages
1522
1580
  const reportedDependencyIssues = new Set();
@@ -1622,8 +1680,8 @@ async function checkCode(context) {
1622
1680
  continue;
1623
1681
  }
1624
1682
 
1625
- // Skip if package is listed in dependencies
1626
1683
  if (packageDependencies[packageName]) {
1684
+ usedPackageDependencies.add(packageName);
1627
1685
  continue;
1628
1686
  }
1629
1687
 
@@ -1702,6 +1760,16 @@ async function checkCode(context) {
1702
1760
  );
1703
1761
  }
1704
1762
 
1763
+ for (const dependency of Object.keys(packageDependencies)) {
1764
+ if (usedPackageDependencies.has(dependency) || implicitRuntimeDependencies.has(dependency)) {
1765
+ continue;
1766
+ }
1767
+
1768
+ context.warnings.push(
1769
+ `[W5060] Package "${dependency}" is listed in dependencies of package.json but not imported or required by any scanned source file. Dependency might be unused.`,
1770
+ );
1771
+ }
1772
+
1705
1773
  // 5500 - xxx reserved for jsonConfig module
1706
1774
 
1707
1775
  return context;
@@ -1779,6 +1847,9 @@ exports.checkCode = checkCode;
1779
1847
  // [W5056] "admin/custom.html" or "admin/custom_m.html" is no longer supported. Please migrate to "admin/jsonCustom.json".
1780
1848
  // [W5057] jsonConfig password field "${nativeKey}" (${locationList}) is not listed at "protectedNative" in io-package.json
1781
1849
  // [W5058] jsonConfig password field "${nativeKey}" (${locationList}) is not listed at "encryptedNative" in io-package.json
1850
+ // [W5059] Adapter uses class mode ("class ... extends utils.Adapter") in "${context.packageJson.main}" and also uses "utils.adapter(...)" in source file(s): ${fileList}. Please use only one adapter pattern.
1851
+ // [W5060] Package "${dependency}" is listed in dependencies of package.json but not imported or required by any scanned source file. Dependency might be unused.
1852
+ // [W5061] "utils.commonTools.letsEncrypt" usage detected. Let's Encrypt support was removed in js-controller 6.
1782
1853
  // [W5054] method "setObject()" should be avoided. Please use "setObjectNotExists()" or "extendObject()" instead.
1783
1854
  // [W5515] Schema validation skipped for "${configFile}" due to parse error: ${e.message}
1784
1855
 
@@ -650,10 +650,10 @@ function checkTabs(context, path, jsonConfig) {
650
650
  const type = jsonConfig[key].type;
651
651
  common.debug(` item ${key} / ${type}`);
652
652
  if (!type) {
653
- context.errors.push(`[E5502] no type specified at ${path}; expected "panel"`);
653
+ context.errors.push(`[E5505] no type specified at ${path}; expected "panel"`);
654
654
  }
655
655
  if (type !== 'panel') {
656
- context.errors.push(`[E5503] unexpected type "${key}" detected at ${path}; expected "panel"`);
656
+ context.errors.push(`[E5506] unexpected type "${key}" detected at ${path}; expected "panel"`);
657
657
  } else {
658
658
  checkPanel(context, `${path}/${key}`, jsonConfig[key]);
659
659
  }
@@ -802,8 +802,8 @@ exports.validateJsonConfigSchema = validateJsonConfigSchema;
802
802
  // [5502] no type specified at ${path}
803
803
  // [5503] unexpected type "${key}" detected at ${path}
804
804
  // [5504] unexpected component "${type}" detected at ${path}
805
- // [5505]
806
- // [5506]
805
+ // [5505] no type specified at ${path}; expected "panel"
806
+ // [5506] unexpected type "${key}" detected at ${path}; expected "panel"
807
807
  // [5507] responsive check: missing size attributes [${missing.join(',')}] at ${path}
808
808
  // [5508] responsive check: attribute "xs" should specify a value of "12" at ${path}
809
809
  // [5509] responsive check: "sm" value (${jsonConfig.sm}) greater then value for smaller displays
@@ -83,11 +83,11 @@ async function checkLicenseFile(context) {
83
83
  const m = text.match(/(\d\d\d\d)-\d\d\d\d/);
84
84
  if (m) {
85
85
  context.errors.push(
86
- `[E7002] Future year (${licenseYear}) found in LICENSE. Please use "Copyright (c) ${m[1]}-${year} ${getAuthor(context.packageJson.author)}" at the start of LICENSE`,
86
+ `[E7005] Future year (${licenseYear}) found in LICENSE. Please use "Copyright (c) ${m[1]}-${year} ${getAuthor(context.packageJson.author)}" at the start of LICENSE`,
87
87
  );
88
88
  } else {
89
89
  context.errors.push(
90
- `[E7002]Future year (${licenseYear}) found in LICENSE. Please use "Copyright (c) ${year} ${getAuthor(context.packageJson.author)}" at the start of LICENSE`,
90
+ `[E7005] Future year (${licenseYear}) found in LICENSE. Please use "Copyright (c) ${year} ${getAuthor(context.packageJson.author)}" at the start of LICENSE`,
91
91
  );
92
92
  }
93
93
  } else if (!valid) {
@@ -158,6 +158,7 @@ exports.checkLicenseFile = checkLicenseFile;
158
158
  // [7000] File LICENSE not found. Please add.');
159
159
  // [7001] No actual year found in LICENSE. Please add "Copyright (c) ${m[1]}-${year} ${getAuthor(context.packageJson.author)}" at the start of LICENSE
160
160
  // [7001] No actual year found in LICENSE. Please add "Copyright (c) ${year} ${getAuthor(context.packageJson.author)}" at the start of LICENSE
161
- // [7002] Cannot read LICENSE file. Please check.');
161
+ // [7002] Cannot read LICENSE file. Please check.
162
162
  // [7003] Multiple copyright lines found in LICENSE but line(s) ${linesWithoutTrailingSpaces.join(', ')} missing trailing spaces. Add two spaces at end of each copyright line (except last) for proper formatting.
163
163
  // [7004] Copyright lines in LICENSE 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.
164
+ // [E7005] Future year (${licenseYear}) found in LICENSE. Please use correct year at the start of LICENSE.
@@ -31,7 +31,7 @@ const IOBROKER_ACTION_ORGS = ['iobroker', 'iobroker-community-adapters', 'iobrok
31
31
  */
32
32
  function fileExistsInList(context, filePath) {
33
33
  if (!context.filesList) {
34
- return false;
34
+ throw new Error('FATAL: context.filesList is undefined');
35
35
  }
36
36
  return context.filesList.includes(filePath) || context.filesList.includes(filePath.replace(/^\//, ''));
37
37
  }
@@ -207,7 +207,7 @@ function isIoBrokerActionWithNonVersionedRef(usesValue) {
207
207
  * @param {object} context - The checker context
208
208
  */
209
209
  async function checkWorkflowActionVersions(context) {
210
- const workflowFiles = (context.filesList || []).filter(f => {
210
+ const workflowFiles = context.filesList.filter(f => {
211
211
  const normalized = f.startsWith('/') ? f : `/${f}`;
212
212
  return normalized.startsWith(WORKFLOW_DIR) && (normalized.endsWith('.yml') || normalized.endsWith('.yaml'));
213
213
  });
@@ -416,8 +416,7 @@ async function checkDependabot(context) {
416
416
 
417
417
  // W8905: Ensure every non-root package.json directory is covered by at least one npm dependabot entry
418
418
  if (hasNpm) {
419
- const filesList = context.filesList || [];
420
- const nonRootPackageJsonFiles = filesList.filter(f => {
419
+ const nonRootPackageJsonFiles = context.filesList.filter(f => {
421
420
  const normalized = f.startsWith('/') ? f : `/${f}`;
422
421
  // Match any package.json that is NOT at the root
423
422
  return /\/[^/]+\/.*package\.json$/.test(normalized);
package/lib/config.js CHANGED
@@ -447,6 +447,31 @@ const testingNodeJs = {
447
447
 
448
448
  // Required operating systems for the adapter-tests matrix
449
449
  requiredOsMatrix: ['ubuntu-latest', 'windows-latest', 'macos-latest'],
450
+ requiredOsSystems: ['ubuntu', 'windows', 'macos'],
451
+ workflowOsAliasMap: {
452
+ ubuntu: 'ubuntu',
453
+ windows: 'windows',
454
+ macos: 'macos',
455
+ linux: 'ubuntu',
456
+ win32: 'windows',
457
+ darwin: 'macos',
458
+ },
459
+ packageOsAliasMap: {
460
+ linux: 'ubuntu',
461
+ win32: 'windows',
462
+ darwin: 'macos',
463
+ ubuntu: 'ubuntu',
464
+ windows: 'windows',
465
+ macos: 'macos',
466
+ win: 'windows',
467
+ osx: 'macos',
468
+ },
469
+ };
470
+
471
+ const npmUpdateSuggestions = {
472
+ defaultMinimumAgeDays: 90,
473
+ newAdapterMinimumAgeDays: 7,
474
+ standardPackages: [],
450
475
  };
451
476
 
452
477
  function initConfig(context) {
@@ -461,6 +486,7 @@ function initConfig(context) {
461
486
  context.cfg.reservedAdapterNames = reservedAdapterNames;
462
487
  context.cfg.isNewAdapter = false;
463
488
  context.cfg.testingNodeJs = testingNodeJs;
489
+ context.cfg.npmUpdateSuggestions = npmUpdateSuggestions;
464
490
 
465
491
  return context;
466
492
  }
@@ -29,17 +29,23 @@ const mapSeverity4New = {
29
29
  W1027: 'E', // [W1027] Missing suggested translation into ru,pt,nl,fr,it,es,pl,uk,zh-cn of "common.titleLang"
30
30
  W1032: 'E', // [W1032] Many "common.news" found in io-package.json
31
31
  W1034: 'E', // [W1034] Missing suggested translation into ru,pt,nl,fr,it,es,pl,uk,zh-cn of "common.desc"
32
+ W1054: 'E', // [W1054] Missing suggested translation into ru,pt,nl,fr,it,es,pl,uk,zh-cn of some "common.news" in io-package.json.
32
33
  W1056: 'E', // [W1056] admin 7.6.17 listed as dependency but 7.6.20 is reW1commended.
33
34
  W1084: 'E', // [W1084] "common.title" is deprecated and replaced by "common.titleLang".
34
35
  W2007: 'E', // [W2007] Version 0.7.0-beta.2 is tagged as "latest" at npm
35
36
  W3009: 'E', // [W3009] Workflow "test-and-release.yml" is missing recommended concurrency configuration.
37
+ W3019: 'E', // [W3019] Workflow "test-and-release.yml": job "deploy" step using "ioBroker/testing-action-deploy@v1" has "npm-token" parameter specified. Trusted publishing will not work while "npm-token" is set.
36
38
  W5512: 'E', // [W5512] admin/jsonConfig.json schema validation error: ...
39
+ W6020: 'E', // [W6020] Consider adding a CHANGELOG_OLD.md file to store older changelog entries.
37
40
  W6021: 'E', // [W6021] "## License" is not the last section in README.md.
38
41
  W8915: 'E', // [W8915] Dependabot npm entry (directory: "/") has no "cooldown" configured.
39
42
  W8916: 'E', // [W8916] Dependabot configuration "/.github/dependabot.yml" has no entry with "package-ecosystem: github-actions".
40
43
  W8917: 'E', // [W8917] At least major versions of @types/node should not be updated by dependabot.
41
44
  S0062: 'W', // [S0062] Consider adding and using package "@alcalzone/release-script".
42
45
  S3012: 'E', // [S3012] Workflow "test-and-release.yml": job "deploy" is not defined.
46
+ S5022: 'W', // [S5022] Please consider migrating to admin 5 UI (jsonConfig) or react based UI.
47
+ S5043: 'E', // [S5043] Package "xx" is a built-in Node.js module. Please use "node:fs" instead.
48
+ S5051: 'W', // [S5051] Custom sleep/wait function(s) found in source files (src/lib/adsb.ts).
43
49
  S6008: 'E', // [S6008] Changelog for version 0.7.0-beta.19 should be added to README.md
44
50
  S6020: 'W', // [S6020] Consider adding a CHANGELOG_OLD.md file to store older changelog entries. This is supported by @alcalzone/releasescript.
45
51
  S8901: 'W', // [S8901] Dependabot configuration file ".github/dependabot.yml" not found. Consider adding dependabot to keep dependencies up to date.