@iobroker/repochecker 5.13.2 → 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.
- package/README.md +11 -0
- package/index.js +1 -0
- package/lib/M0000_PackageJson.js +282 -6
- package/lib/M1000_IOPackageJson.js +162 -15
- package/lib/M3000_Testing.js +280 -12
- package/lib/M5000_Code.js +72 -1
- package/lib/M5500__JsonConfig.js +4 -4
- package/lib/M7000_License.js +4 -3
- package/lib/M8900__Dependabot.js +3 -4
- package/lib/config.js +26 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,6 +25,17 @@ Example:
|
|
|
25
25
|
Placeholder for the next version (at the beginning of the line):
|
|
26
26
|
### **WORK IN PROGRESS**
|
|
27
27
|
-->
|
|
28
|
+
### 5.14.0 (2026-05-26)
|
|
29
|
+
|
|
30
|
+
- (@copilot) Added `[E1143]`: when `package.json` `main` points to a `.ts` file, `io-package.json` must set `common.compact` to `false`. In this case `[S1039]` is no longer emitted.
|
|
31
|
+
- (@copilot) Added `[W5060]`: warns when a package is listed in `dependencies` of `package.json` but is not imported or required by any scanned source file. Plugin packages implied by `io-package.json common.plugins` are ignored to avoid false positives.
|
|
32
|
+
- (@copilot) Added `[S3042]`/`[S3043]`/`[S3044]`: suggest using only the major version tag (e.g. `@v2`) when `test-and-release.yml` pins a specific minor/patch version (e.g. `@v2.0.0`) for `ioBroker/testing-action-check`, `ioBroker/testing-action-adapter`, or `ioBroker/testing-action-deploy`.
|
|
33
|
+
- (@copilot) Added notification scope checks in `io-package.json`: errors when `notifications[].scope` is missing and warns when the scope is neither the adapter name nor in a general allowlist (currently empty).
|
|
34
|
+
- (@copilot) Moved file-list-based eslint config file checks to run after code file discovery and now abort on missing internal `context.filesList`.
|
|
35
|
+
- (@copilot) Added eslint migration/config checks for package/workflow validation, including `lint: true` verification in `test-and-release.yml`.
|
|
36
|
+
- (@copilot) Improved `test-and-release.yml` OS checks to evaluate matrix or action-step OS coverage against `package.json` `os` restrictions, including alias mapping (`linux`/`win32`/`darwin`).
|
|
37
|
+
- (@copilot) Added `[W5059]`: warns when adapters using class mode (`class ... extends utils.Adapter`) still call `utils.adapter(...)` in source files.
|
|
38
|
+
|
|
28
39
|
### 5.13.2 (2026-05-26)
|
|
29
40
|
|
|
30
41
|
- (mcm1957) Adapter some severities for new adapters.
|
package/index.js
CHANGED
|
@@ -157,6 +157,7 @@ function check(request, ctx, callback) {
|
|
|
157
157
|
.then(context => M2000_Npm.checkNpm(context))
|
|
158
158
|
.then(context => M4000_Repository.checkRepository(context))
|
|
159
159
|
.then(context => M5000_Code.checkCode(context))
|
|
160
|
+
.then(context => M0000_PackageJson.checkEslintFileChecks(context))
|
|
160
161
|
.then(context => M0000_PackageJson.checkDependencyNodeRequirements(context))
|
|
161
162
|
.then(context => M3000_Testing.checkTests(context))
|
|
162
163
|
.then(context => M8000_Github.checkGithubRepo(context))
|
package/lib/M0000_PackageJson.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
const compareVersions = require('compare-versions');
|
|
12
12
|
const semver = require('semver');
|
|
13
|
+
const axios = require('axios');
|
|
13
14
|
|
|
14
15
|
const common = require('./common.js');
|
|
15
16
|
|
|
@@ -368,6 +369,12 @@ function applyConditionalRequirements(dependencyTable, packageJsonDeps) {
|
|
|
368
369
|
}
|
|
369
370
|
}
|
|
370
371
|
}
|
|
372
|
+
function fileExistsInList(context, filePath) {
|
|
373
|
+
if (!context.filesList) {
|
|
374
|
+
throw new Error('FATAL: context.filesList is undefined');
|
|
375
|
+
}
|
|
376
|
+
return context.filesList.includes(filePath) || context.filesList.includes(filePath.replace(/^\//, ''));
|
|
377
|
+
}
|
|
371
378
|
|
|
372
379
|
/**
|
|
373
380
|
* Expands npm alias dependencies into separate entries for both the alias name and the real package name.
|
|
@@ -402,6 +409,147 @@ function expandNpmAliases(dependencies) {
|
|
|
402
409
|
return expanded;
|
|
403
410
|
}
|
|
404
411
|
|
|
412
|
+
/**
|
|
413
|
+
* Parses a dependency declaration and resolves npm aliases.
|
|
414
|
+
*
|
|
415
|
+
* @param {string} packageName - Declared package name in package.json
|
|
416
|
+
* @param {string} packageVersion - Declared package version/range in package.json
|
|
417
|
+
* @returns {{ packageName: string; packageVersion: string }} Parsed package name and version
|
|
418
|
+
*/
|
|
419
|
+
function parseDependencyDeclaration(packageName, packageVersion) {
|
|
420
|
+
if (typeof packageVersion !== 'string' || !packageVersion.startsWith('npm:')) {
|
|
421
|
+
return { packageName, packageVersion };
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
const withoutPrefix = packageVersion.slice(4);
|
|
425
|
+
const lastAt = withoutPrefix.lastIndexOf('@');
|
|
426
|
+
if (lastAt <= 0) {
|
|
427
|
+
return { packageName, packageVersion };
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
return {
|
|
431
|
+
packageName: withoutPrefix.slice(0, lastAt),
|
|
432
|
+
packageVersion: withoutPrefix.slice(lastAt + 1),
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Returns the update-check rule for the provided package.
|
|
438
|
+
*
|
|
439
|
+
* @param {object} context - The checker context
|
|
440
|
+
* @param {string} packageName - npm package name
|
|
441
|
+
* @returns {{ minimumAgeDays: number; level: 'S' | 'W' }} Threshold and severity for update suggestions
|
|
442
|
+
*/
|
|
443
|
+
function getNpmUpdateRule(context, packageName) {
|
|
444
|
+
const rules = context.cfg?.npmUpdateSuggestions || {};
|
|
445
|
+
const defaultMinimumAgeDays = Number.isFinite(rules.defaultMinimumAgeDays) ? rules.defaultMinimumAgeDays : 60;
|
|
446
|
+
const newAdapterMinimumAgeDays = Number.isFinite(rules.newAdapterMinimumAgeDays)
|
|
447
|
+
? rules.newAdapterMinimumAgeDays
|
|
448
|
+
: 7;
|
|
449
|
+
|
|
450
|
+
const defaultLevel = context.cfg?.isNewAdapter ? 'W' : 'S';
|
|
451
|
+
let minimumAgeDays = context.cfg?.isNewAdapter ? newAdapterMinimumAgeDays : defaultMinimumAgeDays;
|
|
452
|
+
let level = defaultLevel;
|
|
453
|
+
|
|
454
|
+
for (const entry of rules.standardPackages || []) {
|
|
455
|
+
if (!entry || entry.name !== packageName) {
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
if (Number.isFinite(entry.minimumAgeDays)) {
|
|
459
|
+
minimumAgeDays = entry.minimumAgeDays;
|
|
460
|
+
}
|
|
461
|
+
if (entry.level === 'S' || entry.level === 'W') {
|
|
462
|
+
level = entry.level;
|
|
463
|
+
}
|
|
464
|
+
break;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
return { minimumAgeDays, level };
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Checks if dependencies/devDependencies should receive update suggestions based on npm publish age.
|
|
472
|
+
*
|
|
473
|
+
* @param {object} context - The checker context
|
|
474
|
+
* @returns {Promise<object>} Updated context with dependency update suggestions
|
|
475
|
+
*/
|
|
476
|
+
async function checkNpmDependencyUpdateSuggestions(context) {
|
|
477
|
+
const dependencySources = [
|
|
478
|
+
['dependencies', context.packageJson.dependencies || {}],
|
|
479
|
+
['devDependencies', context.packageJson.devDependencies || {}],
|
|
480
|
+
];
|
|
481
|
+
const deduplicatedChecks = new Map();
|
|
482
|
+
|
|
483
|
+
for (const [sourceType, sourceDeps] of dependencySources) {
|
|
484
|
+
for (const [declaredName, declaredVersion] of Object.entries(sourceDeps)) {
|
|
485
|
+
const parsed = parseDependencyDeclaration(declaredName, declaredVersion);
|
|
486
|
+
const minVersion = semver.minVersion(parsed.packageVersion);
|
|
487
|
+
if (!minVersion) {
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
const key = `${parsed.packageName}:${minVersion.version}`;
|
|
492
|
+
if (!deduplicatedChecks.has(key)) {
|
|
493
|
+
deduplicatedChecks.set(key, {
|
|
494
|
+
packageName: parsed.packageName,
|
|
495
|
+
packageVersion: minVersion.version,
|
|
496
|
+
sourceType,
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
const now = Date.now();
|
|
503
|
+
const millisecondsPerDay = 24 * 60 * 60 * 1000;
|
|
504
|
+
|
|
505
|
+
const checks = Array.from(deduplicatedChecks.values());
|
|
506
|
+
const batchSize = 5;
|
|
507
|
+
for (let i = 0; i < checks.length; i += batchSize) {
|
|
508
|
+
const batch = checks.slice(i, i + batchSize);
|
|
509
|
+
await Promise.all(
|
|
510
|
+
batch.map(async checkItem => {
|
|
511
|
+
const { packageName, packageVersion, sourceType } = checkItem;
|
|
512
|
+
try {
|
|
513
|
+
const response = await axios(`https://registry.npmjs.org/${encodeURIComponent(packageName)}`);
|
|
514
|
+
const npmData = response.data;
|
|
515
|
+
const latestVersion = npmData?.['dist-tags']?.latest;
|
|
516
|
+
const latestPublishedAt = npmData?.time?.[latestVersion];
|
|
517
|
+
|
|
518
|
+
if (!latestVersion || compareVersions.compare(latestVersion, packageVersion, '<=')) {
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
if (!latestPublishedAt) {
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
const publishedAtDate = new Date(latestPublishedAt);
|
|
526
|
+
if (Number.isNaN(publishedAtDate.getTime())) {
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
const packageAgeDays = Math.floor((now - publishedAtDate.getTime()) / millisecondsPerDay);
|
|
531
|
+
const updateRule = getNpmUpdateRule(context, packageName);
|
|
532
|
+
if (packageAgeDays < updateRule.minimumAgeDays) {
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
const dayLabel = packageAgeDays === 1 ? 'day' : 'days';
|
|
537
|
+
const issueCode = updateRule.level === 'W' ? 'W0083' : 'S0082';
|
|
538
|
+
context.warnings.push(
|
|
539
|
+
`[${issueCode}] Package "${packageName}" (${sourceType}) can be updated from ${packageVersion} to ${latestVersion}. The newer version has been published for ${packageAgeDays} ${dayLabel}. Please evaluate updating package.json.`,
|
|
540
|
+
);
|
|
541
|
+
} catch (e) {
|
|
542
|
+
common.debug(
|
|
543
|
+
`Could not fetch npm registry data for "${packageName}" while checking dependency update suggestions: ${e.message || e}`,
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
}),
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
return context;
|
|
551
|
+
}
|
|
552
|
+
|
|
405
553
|
/**
|
|
406
554
|
* Validates release format according to ioBroker semver subset requirements
|
|
407
555
|
*
|
|
@@ -715,6 +863,11 @@ async function checkPackageJson(context) {
|
|
|
715
863
|
} else {
|
|
716
864
|
context.checks.push('Scripts found in package.json');
|
|
717
865
|
}
|
|
866
|
+
if (!context.packageJson.scripts || !context.packageJson.scripts.lint) {
|
|
867
|
+
context.warnings.push('[W0074] No "lint" script found in package.json. Please add one.');
|
|
868
|
+
} else {
|
|
869
|
+
context.checks.push('"lint" script found in package.json');
|
|
870
|
+
}
|
|
718
871
|
|
|
719
872
|
if (context.packageJson.maintainers) {
|
|
720
873
|
context.warnings.push(
|
|
@@ -1160,6 +1313,57 @@ async function checkPackageJson(context) {
|
|
|
1160
1313
|
}
|
|
1161
1314
|
context.checks.push('required devDependencies have been checked.');
|
|
1162
1315
|
|
|
1316
|
+
await checkNpmDependencyUpdateSuggestions(context);
|
|
1317
|
+
|
|
1318
|
+
// Check eslint migration and config requirements
|
|
1319
|
+
const devDeps = context.packageJson.devDependencies || {};
|
|
1320
|
+
const hasEslintConfig = Object.prototype.hasOwnProperty.call(devDeps, '@iobroker/eslint-config');
|
|
1321
|
+
if (!hasEslintConfig) {
|
|
1322
|
+
context.warnings.push(
|
|
1323
|
+
'[S0071] No devDependency for "@iobroker/eslint-config" found. Consider migrating to the shared ESLint config.',
|
|
1324
|
+
);
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
const eslintVersionRaw = devDeps.eslint;
|
|
1328
|
+
const eslintVersion = eslintVersionRaw ? semver.coerce(eslintVersionRaw) : null;
|
|
1329
|
+
const hasEslintV9OrHigher = !!(eslintVersion && semver.gte(eslintVersion, '9.0.0'));
|
|
1330
|
+
if (eslintVersion && semver.lt(eslintVersion, '9.0.0')) {
|
|
1331
|
+
context.warnings.push(
|
|
1332
|
+
`[W0072] "eslint":"${eslintVersionRaw}" is below 9.0.0. Please migrate to "@iobroker/eslint-config".`,
|
|
1333
|
+
);
|
|
1334
|
+
} else if (hasEslintV9OrHigher && !hasEslintConfig) {
|
|
1335
|
+
context.warnings.push(
|
|
1336
|
+
`[S0073] "eslint":"${eslintVersionRaw}" is >= 9.0.0 but "@iobroker/eslint-config" is not used. Consider migrating to "@iobroker/eslint-config".`,
|
|
1337
|
+
);
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
if (hasEslintConfig) {
|
|
1341
|
+
const obsoleteEslintDevDeps = [
|
|
1342
|
+
'@eslint/eslintrc',
|
|
1343
|
+
'@eslint/js',
|
|
1344
|
+
'@typescript-eslint/eslint-plugin',
|
|
1345
|
+
'@typescript-eslint/parser',
|
|
1346
|
+
'eslint',
|
|
1347
|
+
'eslint-config-prettier',
|
|
1348
|
+
'eslint-plugin-import',
|
|
1349
|
+
'eslint-plugin-jsdoc',
|
|
1350
|
+
'eslint-plugin-prettier',
|
|
1351
|
+
'eslint-plugin-react',
|
|
1352
|
+
'eslint-plugin-react-hooks',
|
|
1353
|
+
'eslint-plugin-unicorn',
|
|
1354
|
+
'prettier',
|
|
1355
|
+
'typescript-eslint',
|
|
1356
|
+
];
|
|
1357
|
+
const foundObsoleteDeps = obsoleteEslintDevDeps.filter(dep =>
|
|
1358
|
+
Object.prototype.hasOwnProperty.call(devDeps, dep),
|
|
1359
|
+
);
|
|
1360
|
+
if (foundObsoleteDeps.length > 0) {
|
|
1361
|
+
context.warnings.push(
|
|
1362
|
+
`[W0078] Remove obsolete eslint/prettier devDependencies when using "@iobroker/eslint-config": ${foundObsoleteDeps.join(', ')}.`,
|
|
1363
|
+
);
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1163
1367
|
// check @types/node version vs engines.node minimum version
|
|
1164
1368
|
if (minimumNodeJsSupported !== null) {
|
|
1165
1369
|
const minMajor = parseInt(minimumNodeJsSupported.split('.')[0], 10);
|
|
@@ -1194,11 +1398,11 @@ async function checkPackageJson(context) {
|
|
|
1194
1398
|
context.warnings.push(
|
|
1195
1399
|
`[W0066] "@types/node":"${typesNodeVersion}" at package.json allows major version greater than ${minMajor}. Downgrade to node.js ${minMajor}.x.x to avoid wrong typing is recommended.`,
|
|
1196
1400
|
);
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1401
|
+
// } else if (!semver.satisfies(`${minMajor}.0.0`, typesNodeVersion)) {
|
|
1402
|
+
// // Check if @types/node does not cover the minimum node version
|
|
1403
|
+
// context.warnings.push(
|
|
1404
|
+
// `[S0067] "@types/node":"${typesNodeVersion}" at package.json does not cover minimum node.js version ${minimumNodeJsSupported}. Consider updating to "@types/node":"^${minMajor}" to match the engines clause.`,
|
|
1405
|
+
// );
|
|
1202
1406
|
} else {
|
|
1203
1407
|
context.checks.push(
|
|
1204
1408
|
`@types/node "${typesNodeVersion}" matches minimum node.js version ${minimumNodeJsSupported}.`,
|
|
@@ -1398,6 +1602,63 @@ async function checkPackageJson(context) {
|
|
|
1398
1602
|
return context;
|
|
1399
1603
|
}
|
|
1400
1604
|
|
|
1605
|
+
async function checkEslintFileChecks(context) {
|
|
1606
|
+
const devDeps = context.packageJson.devDependencies || {};
|
|
1607
|
+
const hasEslintConfig = Object.prototype.hasOwnProperty.call(devDeps, '@iobroker/eslint-config');
|
|
1608
|
+
const eslintVersionRaw = devDeps.eslint;
|
|
1609
|
+
const eslintVersion = eslintVersionRaw ? semver.coerce(eslintVersionRaw) : null;
|
|
1610
|
+
const hasEslintV9OrHigher = !!(eslintVersion && semver.gte(eslintVersion, '9.0.0'));
|
|
1611
|
+
const obsoleteEslintFiles = ['/.eslintignore', '/.eslintrc.json', '/.prettierignore', '/.prettierrc.js'];
|
|
1612
|
+
|
|
1613
|
+
if (hasEslintConfig) {
|
|
1614
|
+
if (!fileExistsInList(context, '/eslint.config.mjs')) {
|
|
1615
|
+
context.errors.push(
|
|
1616
|
+
'[E0075] "eslint.config.mjs" is missing although "@iobroker/eslint-config" is configured.',
|
|
1617
|
+
);
|
|
1618
|
+
} else {
|
|
1619
|
+
try {
|
|
1620
|
+
const eslintConfigContent = await common.getFile(context, '/eslint.config.mjs');
|
|
1621
|
+
const hasImport = /import\s+config\s+from\s+['"]@iobroker\/eslint-config['"]\s*;?/.test(
|
|
1622
|
+
String(eslintConfigContent || ''),
|
|
1623
|
+
);
|
|
1624
|
+
if (!hasImport) {
|
|
1625
|
+
context.errors.push(
|
|
1626
|
+
'[E0077] "eslint.config.mjs" should use installed "@iobroker/eslint-config" via `import config from \'@iobroker/eslint-config\';`.',
|
|
1627
|
+
);
|
|
1628
|
+
} else {
|
|
1629
|
+
context.checks.push('"eslint.config.mjs" imports "@iobroker/eslint-config".');
|
|
1630
|
+
}
|
|
1631
|
+
} catch (e) {
|
|
1632
|
+
context.errors.push(`[E0081] Could not read "eslint.config.mjs": ${e.message || e}`);
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
if (!fileExistsInList(context, '/prettier.config.mjs')) {
|
|
1637
|
+
context.warnings.push(
|
|
1638
|
+
'[W0076] "prettier.config.mjs" is missing although "@iobroker/eslint-config" is configured.',
|
|
1639
|
+
);
|
|
1640
|
+
} else {
|
|
1641
|
+
context.checks.push('"prettier.config.mjs" found.');
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
const foundObsoleteFiles = obsoleteEslintFiles.filter(file => fileExistsInList(context, file));
|
|
1645
|
+
if (foundObsoleteFiles.length > 0) {
|
|
1646
|
+
context.warnings.push(
|
|
1647
|
+
`[W0079] Remove obsolete eslint/prettier config files when using "@iobroker/eslint-config": ${foundObsoleteFiles.map(file => file.slice(1)).join(', ')}.`,
|
|
1648
|
+
);
|
|
1649
|
+
}
|
|
1650
|
+
} else if (hasEslintV9OrHigher) {
|
|
1651
|
+
const foundObsoleteFiles = obsoleteEslintFiles.filter(file => fileExistsInList(context, file));
|
|
1652
|
+
if (foundObsoleteFiles.length > 0) {
|
|
1653
|
+
context.warnings.push(
|
|
1654
|
+
`[S0080] Remove obsolete eslint/prettier config files: ${foundObsoleteFiles.map(file => file.slice(1)).join(', ')}.`,
|
|
1655
|
+
);
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
return context;
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1401
1662
|
/**
|
|
1402
1663
|
* Creates a package-lock.json in a temp directory by running npm install --package-lock-only.
|
|
1403
1664
|
* Returns the content of the generated package-lock.json, or throws if creation fails.
|
|
@@ -1454,7 +1715,7 @@ async function checkDependencyNodeRequirements(context) {
|
|
|
1454
1715
|
}
|
|
1455
1716
|
|
|
1456
1717
|
let packageLockContent = null;
|
|
1457
|
-
const hasPackageLock = context
|
|
1718
|
+
const hasPackageLock = fileExistsInList(context, '/package-lock.json');
|
|
1458
1719
|
|
|
1459
1720
|
if (hasPackageLock) {
|
|
1460
1721
|
// Load package-lock.json from the repository
|
|
@@ -1625,6 +1886,7 @@ async function checkDependencyNodeRequirements(context) {
|
|
|
1625
1886
|
|
|
1626
1887
|
exports.getPackageJson = getPackageJson;
|
|
1627
1888
|
exports.checkPackageJson = checkPackageJson;
|
|
1889
|
+
exports.checkEslintFileChecks = checkEslintFileChecks;
|
|
1628
1890
|
exports.checkDependencyNodeRequirements = checkDependencyNodeRequirements;
|
|
1629
1891
|
exports.validateReleaseFormat = validateReleaseFormat;
|
|
1630
1892
|
|
|
@@ -1705,3 +1967,17 @@ exports.validateReleaseFormat = validateReleaseFormat;
|
|
|
1705
1967
|
// [0068] Invalid semver format ${typesNodeVersion} for devDependency "@types/node" at package.json.
|
|
1706
1968
|
// [W0069] The following dependencies require a node.js version incompatible with the adapter's minimum (node ${minimumNodeJsSupported}): ...
|
|
1707
1969
|
// [S0070] Dependency node requirement check could not be performed: ...
|
|
1970
|
+
// [S0071] No devDependency for "@iobroker/eslint-config" found.
|
|
1971
|
+
// [W0072] "eslint" below 9.0.0 detected. Please migrate to "@iobroker/eslint-config".
|
|
1972
|
+
// [S0073] "eslint" >= 9.0.0 detected without "@iobroker/eslint-config". Consider migrating.
|
|
1973
|
+
// [W0074] No "lint" script found in package.json.
|
|
1974
|
+
// [E0075] "eslint.config.mjs" is missing although "@iobroker/eslint-config" is configured.
|
|
1975
|
+
// [W0076] "prettier.config.mjs" is missing although "@iobroker/eslint-config" is configured.
|
|
1976
|
+
// [E0077] "eslint.config.mjs" should use installed "@iobroker/eslint-config".
|
|
1977
|
+
// [W0078] Obsolete eslint/prettier devDependencies found while "@iobroker/eslint-config" is used.
|
|
1978
|
+
// [W0079] Obsolete eslint/prettier config files found while "@iobroker/eslint-config" is used.
|
|
1979
|
+
// [S0080] Obsolete eslint/prettier config files found for adapters using eslint >= 9.0.0 without "@iobroker/eslint-config".
|
|
1980
|
+
|
|
1981
|
+
// [E0081] Could not read "eslint.config.mjs": ${e.message || e}
|
|
1982
|
+
// [S0082] Package "${packageName}" (${sourceType}) can be updated from ${packageVersion} to ${latestVersion}. ...
|
|
1983
|
+
// [W0083] Package "${packageName}" (${sourceType}) can be updated from ${packageVersion} to ${latestVersion}. ...
|
|
@@ -35,6 +35,7 @@ let requiredJsControllerVersion = '6.0.11';
|
|
|
35
35
|
const recommendedAdminVersion = '7.6.20';
|
|
36
36
|
let requiredAdminVersion = '7.6.17'; // set to 6.17.14 if jsonConfig is used
|
|
37
37
|
const adaptersAllowedToUseNondeletable = [];
|
|
38
|
+
const generallyAllowedNotificationScopes = [];
|
|
38
39
|
|
|
39
40
|
const blacklistIOPackageJson = {
|
|
40
41
|
$schema: {
|
|
@@ -279,6 +280,55 @@ function doesValueMatchStateType(value, stateType) {
|
|
|
279
280
|
return true;
|
|
280
281
|
}
|
|
281
282
|
|
|
283
|
+
function isReadmeOrLicenseFile(path) {
|
|
284
|
+
if (!path || typeof path !== 'string') {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
const normalized = path.replace(/^\/+/, '').toLowerCase();
|
|
288
|
+
return normalized === 'readme.md' || normalized === 'license' || normalized === 'license.md';
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function isCurrentRepositoryReadmeOrLicenseLink(context, link) {
|
|
292
|
+
if (!link || typeof link !== 'string' || !context?.repository) {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
try {
|
|
296
|
+
const parsedUrl = new URL(link);
|
|
297
|
+
const host = parsedUrl.hostname.toLowerCase();
|
|
298
|
+
const pathParts = parsedUrl.pathname
|
|
299
|
+
.split('/')
|
|
300
|
+
.map(part => decodeURIComponent(part))
|
|
301
|
+
.filter(Boolean);
|
|
302
|
+
const [owner, repo] = context.repository.toLowerCase().split('/');
|
|
303
|
+
|
|
304
|
+
if (host === 'github.com') {
|
|
305
|
+
if (pathParts.length < 5) {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
const [urlOwner, urlRepo, segment] = pathParts;
|
|
309
|
+
if (urlOwner.toLowerCase() !== owner || urlRepo.toLowerCase() !== repo || segment !== 'blob') {
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
return isReadmeOrLicenseFile(pathParts.slice(4).join('/'));
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (host === 'raw.githubusercontent.com') {
|
|
316
|
+
if (pathParts.length < 4) {
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
const [urlOwner, urlRepo] = pathParts;
|
|
320
|
+
if (urlOwner.toLowerCase() !== owner || urlRepo.toLowerCase() !== repo) {
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
return isReadmeOrLicenseFile(pathParts.slice(3).join('/'));
|
|
324
|
+
}
|
|
325
|
+
} catch {
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
|
|
282
332
|
async function validateIOPackageSchema(context) {
|
|
283
333
|
common.debug('[schema] validating io-package.json against schema');
|
|
284
334
|
|
|
@@ -371,6 +421,34 @@ function checkNotificationsTranslations(obj, allowedLanguages) {
|
|
|
371
421
|
return false;
|
|
372
422
|
}
|
|
373
423
|
|
|
424
|
+
function checkNotificationScopes(notifications, adapterName, allowedScopes) {
|
|
425
|
+
const normalizedAdapterName = adapterName.toLowerCase();
|
|
426
|
+
const normalizedAllowedScopes = new Set(allowedScopes.map(scope => scope.toLowerCase()));
|
|
427
|
+
|
|
428
|
+
const missingScopeNotifications = [];
|
|
429
|
+
const unsupportedScopeNotifications = [];
|
|
430
|
+
|
|
431
|
+
for (let i = 0; i < notifications.length; i++) {
|
|
432
|
+
const notification = notifications[i];
|
|
433
|
+
if (!notification || typeof notification !== 'object' || Array.isArray(notification)) {
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
if (!Object.prototype.hasOwnProperty.call(notification, 'scope')) {
|
|
438
|
+
missingScopeNotifications.push(i);
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
const normalizedScope =
|
|
443
|
+
typeof notification.scope === 'string' ? notification.scope.toLowerCase() : String(notification.scope);
|
|
444
|
+
if (normalizedScope !== normalizedAdapterName && !normalizedAllowedScopes.has(normalizedScope)) {
|
|
445
|
+
unsupportedScopeNotifications.push({ index: i, scope: notification.scope });
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
return { missingScopeNotifications, unsupportedScopeNotifications };
|
|
450
|
+
}
|
|
451
|
+
|
|
374
452
|
async function checkIOPackageJson(context) {
|
|
375
453
|
console.log('\n[E1000 - E1999] checking io-package.json');
|
|
376
454
|
|
|
@@ -707,7 +785,16 @@ async function checkIOPackageJson(context) {
|
|
|
707
785
|
}
|
|
708
786
|
}
|
|
709
787
|
|
|
710
|
-
|
|
788
|
+
const hasTypeScriptMainEntry = context.packageJson?.main?.endsWith('.ts');
|
|
789
|
+
if (!context.ioPackageJson.common.onlyWWW && hasTypeScriptMainEntry) {
|
|
790
|
+
if (context.ioPackageJson.common.compact === undefined || context.ioPackageJson.common.compact === true) {
|
|
791
|
+
context.errors.push(
|
|
792
|
+
'[E1143] package.json "main" points to a TypeScript file. Please set "common.compact": false in io-package.json.',
|
|
793
|
+
);
|
|
794
|
+
} else {
|
|
795
|
+
context.checks.push('"common.compact" found in io-package.json');
|
|
796
|
+
}
|
|
797
|
+
} else if (!context.ioPackageJson.common.compact && !context.ioPackageJson.common.onlyWWW) {
|
|
711
798
|
if (context.ioPackageJson.common.compact === undefined) {
|
|
712
799
|
context.warnings.push(
|
|
713
800
|
'[W1013] Please test whether adapter can support compact mode, if not set "common.compact:false" at io-package.json.',
|
|
@@ -790,11 +877,25 @@ async function checkIOPackageJson(context) {
|
|
|
790
877
|
} else {
|
|
791
878
|
context.checks.push('"common.licenseInformation.type" is valid in io-package.json');
|
|
792
879
|
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
880
|
+
const licenseInformationLink = context.ioPackageJson.common?.licenseInformation?.link;
|
|
881
|
+
if (
|
|
882
|
+
['paid', 'commercial', 'limited'].includes(context.ioPackageJson.common?.licenseInformation?.type) &&
|
|
883
|
+
!licenseInformationLink
|
|
884
|
+
) {
|
|
885
|
+
context.warnings.push('[W1071] "common.licenseInformation.link" is required for non-free adapters');
|
|
886
|
+
} else if (licenseInformationLink) {
|
|
887
|
+
context.checks.push('"common.licenseInformation.link" is valid in io-package.json');
|
|
888
|
+
|
|
889
|
+
if (isCurrentRepositoryReadmeOrLicenseLink(context, licenseInformationLink)) {
|
|
890
|
+
context.warnings.push(
|
|
891
|
+
'[W1137] "common.licenseInformation.link" should not point to this repository\'s README.md or LICENSE file',
|
|
892
|
+
);
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
if (!((await common.downloadURL(licenseInformationLink, false)) || '').trim()) {
|
|
896
|
+
context.warnings.push('[W1138] "common.licenseInformation.link" should point to a readable URL');
|
|
796
897
|
} else {
|
|
797
|
-
context.checks.push('"common.licenseInformation.link"
|
|
898
|
+
context.checks.push('"common.licenseInformation.link" points to a readable URL');
|
|
798
899
|
}
|
|
799
900
|
}
|
|
800
901
|
}
|
|
@@ -1183,13 +1284,13 @@ async function checkIOPackageJson(context) {
|
|
|
1183
1284
|
|
|
1184
1285
|
if (instanceObject.common.color !== undefined && typeof instanceObject.common.color !== 'string') {
|
|
1185
1286
|
context.warnings.push(
|
|
1186
|
-
`[
|
|
1287
|
+
`[W1140] io-package.json: instanceObject "${instanceObject._id || index}" common.color must be a string`,
|
|
1187
1288
|
);
|
|
1188
1289
|
}
|
|
1189
1290
|
|
|
1190
1291
|
if (instanceObject.common.icon !== undefined && typeof instanceObject.common.icon !== 'string') {
|
|
1191
1292
|
context.warnings.push(
|
|
1192
|
-
`[
|
|
1293
|
+
`[W1141] io-package.json: instanceObject "${instanceObject._id || index}" common.icon must be a string`,
|
|
1193
1294
|
);
|
|
1194
1295
|
}
|
|
1195
1296
|
|
|
@@ -1649,12 +1750,32 @@ async function checkIOPackageJson(context) {
|
|
|
1649
1750
|
if (context.ioPackageJson.notifications) {
|
|
1650
1751
|
if (!Array.isArray(context.ioPackageJson.notifications)) {
|
|
1651
1752
|
context.errors.push('[E1112] "notifications" in io-package.json must be an array');
|
|
1652
|
-
} else if (checkNotificationsTranslations(context.ioPackageJson.notifications, context.cfg.allowedLanguages)) {
|
|
1653
|
-
context.errors.push(
|
|
1654
|
-
`[E1112] "notifications" in io-package.json must be translated into all supported languages (${context.cfg.allowedLanguages.join(', ')})`,
|
|
1655
|
-
);
|
|
1656
1753
|
} else {
|
|
1657
|
-
context.
|
|
1754
|
+
if (checkNotificationsTranslations(context.ioPackageJson.notifications, context.cfg.allowedLanguages)) {
|
|
1755
|
+
context.errors.push(
|
|
1756
|
+
`[E1139] "notifications" in io-package.json must be translated into all supported languages (${context.cfg.allowedLanguages.join(', ')})`,
|
|
1757
|
+
);
|
|
1758
|
+
} else {
|
|
1759
|
+
context.checks.push('"notifications" in io-package.json are translated into all supported languages');
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
const { missingScopeNotifications, unsupportedScopeNotifications } = checkNotificationScopes(
|
|
1763
|
+
context.ioPackageJson.notifications,
|
|
1764
|
+
context.adapterName,
|
|
1765
|
+
generallyAllowedNotificationScopes,
|
|
1766
|
+
);
|
|
1767
|
+
|
|
1768
|
+
for (const notificationIndex of missingScopeNotifications) {
|
|
1769
|
+
context.errors.push(
|
|
1770
|
+
`[E1137] "notifications[${notificationIndex}].scope" is missing in io-package.json`,
|
|
1771
|
+
);
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
for (const notification of unsupportedScopeNotifications) {
|
|
1775
|
+
context.warnings.push(
|
|
1776
|
+
`[W1142] "notifications[${notification.index}].scope" has unsupported value "${notification.scope}" in io-package.json. Use "${context.adapterName.toLowerCase()}" or a generally allowed scope.`,
|
|
1777
|
+
);
|
|
1778
|
+
}
|
|
1658
1779
|
}
|
|
1659
1780
|
} else {
|
|
1660
1781
|
context.checks.push('"notifications" not found in io-package.json, skipping check');
|
|
@@ -1742,8 +1863,6 @@ exports.checkIOPackageJson = checkIOPackageJson;
|
|
|
1742
1863
|
// [1067] scheduled adapters must have "common.schedule" property in io-package.json
|
|
1743
1864
|
// [1068] "common.keywords" should not contain "${forbiddenKeywords.join(', ')}" io-package.json0
|
|
1744
1865
|
// [1069] "common.keywords" must be an array within io-package.json and contain some useful keywords
|
|
1745
|
-
// [1069] "common.keywords" must be an array within io-package.json and contain some useful keywords
|
|
1746
|
-
// [1069] "common.keywords" must be an array within io-package.json and contain some useful keywords
|
|
1747
1866
|
// [1070] "common.licenseInformation.type" is invalid. Select valid type (e.g. free)
|
|
1748
1867
|
// [1071] "common.licenseInformation.link" is required for non-free adapters
|
|
1749
1868
|
// [1072] "common.localLink" in io-package.json is deprecated. Please define object "common.localLinks": { "_default": "..." }
|
|
@@ -1788,8 +1907,36 @@ exports.checkIOPackageJson = checkIOPackageJson;
|
|
|
1788
1907
|
// [1109] "common.jsonConfig" is deprecated and has been replaced by "common.adminUI" at io-package.json. Please remove.
|
|
1789
1908
|
// [1110] "common.jsonConfig" is deprecated and must be replaced by "common.adminUI" configuration at io-package.json.
|
|
1790
1909
|
// [1111] -- moved to M5000_Code.js as [E5040] (check deferred to allow scanning admin UI files)
|
|
1791
|
-
// [1112] "notifications" in io-package.json must be
|
|
1910
|
+
// [1112] "notifications" in io-package.json must be an array
|
|
1792
1911
|
// [1113] "native" config object will not be used when "common.adminUI.config" is set to "none". Please remove native properties from io-package.json.
|
|
1793
1912
|
// [1114] "common.schedule" is not supported / unused for daemon adapters and should be removed from io-package.json.
|
|
1794
1913
|
// [1115] Plugin "${pluginName}" is listed in "common.plugins" of io-package.json but "@iobroker/plugin-${pluginName}" is not listed as a dependency in package.json. Please add it.
|
|
1795
1914
|
// [1116] Sentry plugin is configured in io-package.json but "@sentry/*" packages (${sentryDeps.join(', ')}) are listed as dependencies in package.json. When using the sentry plugin, explicit @sentry/* dependencies should not be added.
|
|
1915
|
+
// [W1117] Could not download stateRoles URL for validation of instanceObjects common.role
|
|
1916
|
+
// [W1118] io-package.json: instanceObject[${index}] must be an object
|
|
1917
|
+
// [W1119] io-package.json: instanceObject[${index}] must define non-empty string "_id"
|
|
1918
|
+
// [W1120] io-package.json: instanceObject "${instanceObject._id || index}" with type "state" must have "common" object
|
|
1919
|
+
// [W1121] io-package.json: instanceObject "${instanceObject._id || index}" common.${key} must be a number
|
|
1920
|
+
// [W1122] io-package.json: instanceObject "${instanceObject._id || index}" common.unit must be a string
|
|
1921
|
+
// [W1123] io-package.json: instanceObject "${instanceObject._id || index}" common.desc must be a string or object
|
|
1922
|
+
// [W1124] io-package.json: instanceObject "${instanceObject._id || index}" common.read is mandatory and must be boolean
|
|
1923
|
+
// [W1125] io-package.json: instanceObject "${instanceObject._id || index}" common.write is mandatory and must be boolean
|
|
1924
|
+
// [W1126] io-package.json: instanceObject "${instanceObject._id || index}" common.role is mandatory and must be a non-empty string
|
|
1925
|
+
// [W1127] io-package.json: instanceObject "${instanceObject._id || index}" common.states must be number or string
|
|
1926
|
+
// [W1128] io-package.json: instanceObject "${instanceObject._id || index}" common.defAck must be boolean
|
|
1927
|
+
// [W1129] io-package.json: instanceObject "${instanceObject._id || index}" common.workingID must be string
|
|
1928
|
+
// [W1130] io-package.json: instanceObject "${instanceObject._id || index}" common.def must match common.type "${instanceObject.common.type}"
|
|
1929
|
+
// [W1131] io-package.json: instanceObject "${instanceObject._id || index}" has unsupported common.${commonKey} attribute
|
|
1930
|
+
// [W1132] io-package.json: instanceObject "${instanceObject._id || index}" common.role "${instanceObject.common.role}" is not a known ioBroker state role
|
|
1931
|
+
// [W1133] io-package.json: instanceObject "${instanceObject._id || index}" role "${instanceObject.common.role}" expects common.type to be one of [${roleDefinition.types.join(', ')}], but found "${instanceObject.common.type}"
|
|
1932
|
+
// [W1134] io-package.json: instanceObject "${instanceObject._id || index}" role "${instanceObject.common.role}" expects common.read=${roleDefinition.read}
|
|
1933
|
+
// [W1135] io-package.json: instanceObject "${instanceObject._id || index}" role "${instanceObject.common.role}" expects common.write=${roleDefinition.write}
|
|
1934
|
+
// [W1136] io-package.json: instanceObject "${instanceObject._id || index}" common.expert must be boolean
|
|
1935
|
+
// [W1137] "common.licenseInformation.link" should not point to this repository's README.md or LICENSE file
|
|
1936
|
+
// [W1138] "common.licenseInformation.link" should point to a readable URL
|
|
1937
|
+
// [E1137] "notifications[${notificationIndex}].scope" is missing in io-package.json
|
|
1938
|
+
// [E1139] "notifications" in io-package.json must be translated into all supported languages
|
|
1939
|
+
// [W1140] io-package.json: instanceObject common.color must be a string
|
|
1940
|
+
// [W1141] io-package.json: instanceObject common.icon must be a string
|
|
1941
|
+
// [W1142] "notifications[${notification.index}].scope" has unsupported value "${notification.scope}" in io-package.json.
|
|
1942
|
+
// [E1143] package.json "main" points to a TypeScript file. Please set "common.compact": false in io-package.json.
|
package/lib/M3000_Testing.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
`[
|
|
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
|
-
`[
|
|
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
|
-
`[
|
|
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
|
|
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
|
-
|
|
754
|
-
|
|
755
|
-
|
|
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}":
|
|
758
|
-
`
|
|
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
|
-
`
|
|
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
|
|
package/lib/M5500__JsonConfig.js
CHANGED
|
@@ -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(`[
|
|
653
|
+
context.errors.push(`[E5505] no type specified at ${path}; expected "panel"`);
|
|
654
654
|
}
|
|
655
655
|
if (type !== 'panel') {
|
|
656
|
-
context.errors.push(`[
|
|
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
|
package/lib/M7000_License.js
CHANGED
|
@@ -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
|
-
`[
|
|
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
|
-
`[
|
|
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.
|
package/lib/M8900__Dependabot.js
CHANGED
|
@@ -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
|
-
|
|
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 =
|
|
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
|
|
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
|
}
|
package/package.json
CHANGED