@iobroker/repochecker 5.12.0 → 5.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -25,6 +25,30 @@ Example:
25
25
  Placeholder for the next version (at the beginning of the line):
26
26
  ### **WORK IN PROGRESS**
27
27
  -->
28
+ ### 5.13.0 (2026-05-22)
29
+
30
+ - (@copilot) Ignored `/www`, `/template`, and `/templates` during source dependency scanning, ignored `native.webInstance` for extension adapters in native checks, and updated `[W1130]` array default validation to require a JSON-stringified array. Related to [#881].
31
+ - (@copilot) Fixed `[W8905]` dependabot coverage logic to accept matching npm `directory`/`directories` entries (including wildcard patterns) for each non-root `package.json`.
32
+ - (@copilot) Added an error for `common.nondeletable=true` in `io-package.json`, with a prepared (currently empty) allowlist for adapters that are allowed to use this reserved flag.
33
+ - (@copilot) Fixed `[W0069]` scope: now checks only packages reachable from `dependencies` in `package.json` (including their transitive sub-dependencies), while ignoring packages that are only brought in by `devDependencies` or `optionalDependencies`.
34
+ - (@copilot) Stopped source-code checks from scanning files in `doc/` and `docs/` directories, preventing false positives like `[E5049]` from documentation helper files [#874].
35
+ - (@copilot) Added `[W0069]`/`[S0070]`: checks that all dependencies in `package-lock.json` require a Node.js version compatible with the adapter's `engines.node` minimum. If `package-lock.json` is absent, attempts to create it via `npm install --package-lock-only`. Reports `[W0069]` for incompatible packages and `[S0070]` when the check cannot be performed. Related to #310
36
+ - (@copilot) Extended `instanceObjects` validation for `io-package.json`: now checks `_id`, valid object/state types, state `common.*` structure/types, and role compatibility against official ioBroker state-role definitions, reporting findings as warnings.
37
+ - (@copilot) Added `[W5516]`: warns when the `default` value in a jsonConfig component definition has a JavaScript type that does not match the expected type for that component (e.g. a `number` component with a string default like `"5"`, or a `checkbox` with a numeric default). Related to [#857].
38
+ - (@mcm1957) Added `[E6025]`: `README.md` now raises an error when it does not contain exactly one H1 (`#`) heading. Related to #176.
39
+ - (@copilot) Added `[W5053]`: warns when `admin/jsonCustom.json(5)` exists but custom support is not declared in io-package.json. Related to [#760].
40
+ - (@copilot) Added `[W5054]`: warns when `admin/blockly.js` exists but blockly support is not declared in io-package.json (`common.blockly` not set). Related to [#760].
41
+ - (@copilot) Added `[W5055]`: warns when `admin/index.html` exists but materialize UI is used (the file is for admin2 and is outdated). Related to [#760].
42
+ - (@copilot) Added `[W5056]`: warns when `admin/custom.html` or `admin/custom_m.html` exists — these HTML-based custom dialogs are no longer supported; migrate to `admin/jsonCustom.json`. Related to [#760].
43
+ - (@copilot) Added `[W6023]`/`[W6024]` README checks for adapters using the Sentry plugin: warn when the required Sentry notice is missing and when it appears too far down in the document.
44
+ - (@copilot) Added `[W5052]`: warns for adapter-core `setObject()` usage (`this.setObject(...)` / `adapter.setObject(...)`) and suggests using `setObjectNotExists()` or `extendObject()` instead. Detection ignores comments and string literals to avoid false positives.
45
+ - (@copilot) Added `[E9508]` and extended `.npmignore` packaging checks so `CHANGELOG_OLD.md` is not shipped in npm packages.
46
+ - (@copilot) Added `[E9509]`/`[E9510]`: error when `.dev-server` directory is present in repository but not excluded from npm packaging (via `package.json "files"` or `.npmignore`). Related to #875.
47
+ - (@copilot) Added `[W5052]`/`[W5053]`: when jsonConfig is used, password fields found in `admin/*.json` and `admin/*.json5` (outside table components) are now checked against `protectedNative` and `encryptedNative` in `io-package.json`.
48
+
49
+ ### 5.12.1 (2026-05-20)
50
+ - (mcm197) cleanup some duplicate numbers
51
+
28
52
  ### 5.12.0 (2026-05-20)
29
53
 
30
54
  - (@copilot) Added `[S6022]`: suggest adding a link to `CHANGELOG_OLD.md` in `README.md` when the file exists but no reference to it is found in the readme.
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.checkDependencyNodeRequirements(context))
160
161
  .then(context => M3000_Testing.checkTests(context))
161
162
  .then(context => M8000_Github.checkGithubRepo(context))
162
163
  .then(context => M6000_Readme.checkReadme(context))
@@ -35,51 +35,51 @@ const dependenciesPackageJson = {
35
35
  // packages which must or should be required as devDependencies
36
36
  const devDependenciesPackageJson = {
37
37
  '@alcalzone/release-script': {
38
- required: '5.0.0',
39
- recommended: '5.1.1',
40
- actual: '5.1.1',
38
+ required: '5.2.0',
39
+ recommended: '5.2.0',
40
+ actual: '5.2.0',
41
41
  optional: true,
42
42
  suggested: true,
43
43
  // Conditional requirements: when this package is >= a certain version,
44
44
  // other packages have updated requirements
45
45
  conditionalRequirements: [
46
46
  {
47
- ifVersion: '5.1.1',
47
+ ifVersion: '5.2.0',
48
48
  targetDependency: '@alcalzone/release-script-plugin-iobroker',
49
- required: '5.1.2',
49
+ required: '5.2.0',
50
50
  },
51
51
  {
52
- ifVersion: '5.1.1',
52
+ ifVersion: '5.2.0',
53
53
  targetDependency: '@alcalzone/release-script-plugin-license',
54
- required: '5.1.1',
54
+ required: '5.2.0',
55
55
  },
56
56
  {
57
- ifVersion: '5.1.1',
57
+ ifVersion: '5.2.0',
58
58
  targetDependency: '@alcalzone/release-script-plugin-manual-review',
59
- required: '5.1.1',
59
+ required: '5.2.0',
60
60
  },
61
61
  ],
62
62
  },
63
63
  '@alcalzone/release-script-plugin-iobroker': {
64
- required: '4.0.0',
65
- recommended: '5.1.2',
66
- actual: '5.1.2',
64
+ required: '5.2.0',
65
+ recommended: '5.2.0',
66
+ actual: '5.2.0',
67
67
  optional: true,
68
68
  suggested: true,
69
69
  },
70
70
  '@alcalzone/release-script-plugin-license': {
71
- required: '4.0.0',
72
- recommended: '5.1.1',
73
- actual: '5.1.1',
71
+ required: '5.2.0',
72
+ recommended: '5.2.0',
73
+ actual: '5.2.0',
74
74
  optional: true,
75
- suggested: true,
75
+ suggested: false,
76
76
  },
77
77
  '@alcalzone/release-script-plugin-manual-review': {
78
- required: '4.0.0',
79
- recommended: '5.1.1',
80
- actual: '5.1.1',
78
+ required: '5.2.0',
79
+ recommended: '5.2.0',
80
+ actual: '5.2.0',
81
81
  optional: true,
82
- suggested: true,
82
+ suggested: false,
83
83
  },
84
84
  '@iobroker/adapter-dev': {
85
85
  required: '1.3.0',
@@ -1194,11 +1194,11 @@ async function checkPackageJson(context) {
1194
1194
  context.warnings.push(
1195
1195
  `[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
1196
  );
1197
- } else if (!semver.satisfies(`${minMajor}.0.0`, typesNodeVersion)) {
1198
- // Check if @types/node does not cover the minimum node version
1199
- context.warnings.push(
1200
- `[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.`,
1201
- );
1197
+ // } else if (!semver.satisfies(`${minMajor}.0.0`, typesNodeVersion)) {
1198
+ // // Check if @types/node does not cover the minimum node version
1199
+ // context.warnings.push(
1200
+ // `[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.`,
1201
+ // );
1202
1202
  } else {
1203
1203
  context.checks.push(
1204
1204
  `@types/node "${typesNodeVersion}" matches minimum node.js version ${minimumNodeJsSupported}.`,
@@ -1390,13 +1390,242 @@ async function checkPackageJson(context) {
1390
1390
  }
1391
1391
 
1392
1392
  // single free 008
1393
- // first free 054
1393
+ // first free 069
1394
+
1395
+ // Store the minimum node.js version in context for use by subsequent checks
1396
+ context.minimumNodeJsSupported = minimumNodeJsSupported;
1397
+
1398
+ return context;
1399
+ }
1400
+
1401
+ /**
1402
+ * Creates a package-lock.json in a temp directory by running npm install --package-lock-only.
1403
+ * Returns the content of the generated package-lock.json, or throws if creation fails.
1404
+ *
1405
+ * @param {object} context - The checker context
1406
+ * @returns {Promise<string>} The content of the generated package-lock.json
1407
+ */
1408
+ async function createPackageLockJson(context) {
1409
+ const { exec } = require('node:child_process');
1410
+ const os = require('node:os');
1411
+ const path = require('node:path');
1412
+ const fsp = require('node:fs/promises');
1413
+
1414
+ const tmpDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'repochecker-'));
1415
+ common.debug(`Created temp dir ${tmpDir} for package-lock.json generation`);
1416
+ try {
1417
+ await fsp.writeFile(path.join(tmpDir, 'package.json'), JSON.stringify(context.packageJson, null, 2));
1418
+
1419
+ await new Promise((resolve, reject) => {
1420
+ exec('npm install --package-lock-only --ignore-scripts', { cwd: tmpDir, timeout: 120000 }, error => {
1421
+ if (error) {
1422
+ reject(new Error(`npm install --package-lock-only failed: ${error.message}`));
1423
+ } else {
1424
+ resolve();
1425
+ }
1426
+ });
1427
+ });
1428
+
1429
+ const lockContent = await fsp.readFile(path.join(tmpDir, 'package-lock.json'), 'utf8');
1430
+ return lockContent;
1431
+ } finally {
1432
+ try {
1433
+ await fsp.rm(tmpDir, { recursive: true, force: true });
1434
+ } catch (e) {
1435
+ common.debug(`Could not clean up temp dir ${tmpDir}: ${e}`);
1436
+ }
1437
+ }
1438
+ }
1439
+
1440
+ /**
1441
+ * Checks if dependencies listed in package-lock.json require a Node.js version
1442
+ * that is incompatible with the adapter's engines.node constraint.
1443
+ * If no package-lock.json is present, attempts to create one via npm install --package-lock-only.
1444
+ *
1445
+ * @param {object} context - The checker context
1446
+ * @returns {Promise<object>} The updated context
1447
+ */
1448
+ async function checkDependencyNodeRequirements(context) {
1449
+ const minimumNodeJsSupported = context.minimumNodeJsSupported;
1450
+
1451
+ if (!minimumNodeJsSupported) {
1452
+ context.checks.push('Dependency node requirements check skipped (no engines.node clause in adapter).');
1453
+ return context;
1454
+ }
1455
+
1456
+ let packageLockContent = null;
1457
+ const hasPackageLock = context.filesList && context.filesList.includes('/package-lock.json');
1458
+
1459
+ if (hasPackageLock) {
1460
+ // Load package-lock.json from the repository
1461
+ try {
1462
+ const lockFileContent = await common.getFile(context, '/package-lock.json');
1463
+ if (lockFileContent) {
1464
+ packageLockContent =
1465
+ typeof lockFileContent === 'object' ? JSON.stringify(lockFileContent) : lockFileContent;
1466
+ }
1467
+ } catch (e) {
1468
+ common.debug(`Could not load package-lock.json: ${e}`);
1469
+ }
1470
+ } else {
1471
+ // package-lock.json not in repo - try to create it temporarily
1472
+ context.checks.push(
1473
+ 'package-lock.json not found in repository, attempting to create it for dependency check...',
1474
+ );
1475
+ try {
1476
+ packageLockContent = await createPackageLockJson(context);
1477
+ context.checks.push('package-lock.json created successfully for dependency check.');
1478
+ } catch (e) {
1479
+ common.debug(`Could not create package-lock.json: ${e}`);
1480
+ context.warnings.push(
1481
+ '[S0070] Dependency node requirement check could not be performed: package-lock.json is not available and could not be created. Consider adding package-lock.json to the repository.',
1482
+ );
1483
+ return context;
1484
+ }
1485
+ }
1486
+
1487
+ if (!packageLockContent) {
1488
+ context.warnings.push(
1489
+ '[S0070] Dependency node requirement check could not be performed: package-lock.json could not be loaded.',
1490
+ );
1491
+ return context;
1492
+ }
1493
+
1494
+ let lockJson;
1495
+ try {
1496
+ lockJson = JSON.parse(packageLockContent);
1497
+ } catch {
1498
+ context.warnings.push(
1499
+ '[S0070] Dependency node requirement check could not be performed: package-lock.json is not valid JSON.',
1500
+ );
1501
+ return context;
1502
+ }
1503
+
1504
+ // Only lockfileVersion 2+ includes engines data in the packages field
1505
+ if (!lockJson.packages || lockJson.lockfileVersion < 2) {
1506
+ context.checks.push(
1507
+ 'Dependency node requirements check skipped (package-lock.json lockfileVersion < 2, no engines data available).',
1508
+ );
1509
+ return context;
1510
+ }
1511
+
1512
+ const adapterMinVersion = semver.coerce(minimumNodeJsSupported);
1513
+ if (!adapterMinVersion) {
1514
+ context.checks.push(
1515
+ `Dependency node requirements check skipped (cannot parse adapter minimum node version: ${minimumNodeJsSupported}).`,
1516
+ );
1517
+ return context;
1518
+ }
1519
+
1520
+ const rootDependencies = Object.keys(context.packageJson.dependencies || {});
1521
+ if (rootDependencies.length === 0) {
1522
+ context.checks.push('Dependency node requirements check skipped (no runtime dependencies declared).');
1523
+ return context;
1524
+ }
1525
+
1526
+ const resolvePackagePath = (packageName, fromPath, packages) => {
1527
+ let currentPath = fromPath;
1528
+ while (true) {
1529
+ const candidate = currentPath
1530
+ ? `${currentPath}/node_modules/${packageName}`
1531
+ : `node_modules/${packageName}`;
1532
+ if (packages[candidate]) {
1533
+ return candidate;
1534
+ }
1535
+ const parentIndex = currentPath.lastIndexOf('/node_modules/');
1536
+ if (parentIndex === -1) {
1537
+ break;
1538
+ }
1539
+ currentPath = currentPath.slice(0, parentIndex);
1540
+ }
1541
+ return packages[`node_modules/${packageName}`] ? `node_modules/${packageName}` : null;
1542
+ };
1543
+
1544
+ const getRelevantPackagePaths = (packages, runtimeDependencies) => {
1545
+ const relevantPaths = new Set();
1546
+ const stack = [];
1547
+ const resolutionCache = new Map();
1548
+
1549
+ for (const dependencyName of runtimeDependencies) {
1550
+ const dependencyPath = resolvePackagePath(dependencyName, '', packages);
1551
+ dependencyPath && stack.push(dependencyPath);
1552
+ }
1553
+
1554
+ while (stack.length > 0) {
1555
+ const currentPath = stack.pop();
1556
+ if (!currentPath || relevantPaths.has(currentPath)) {
1557
+ continue;
1558
+ }
1559
+
1560
+ relevantPaths.add(currentPath);
1561
+ const currentPackage = packages[currentPath];
1562
+ if (!currentPackage) {
1563
+ continue;
1564
+ }
1565
+
1566
+ const childDependencies = new Set(Object.keys(currentPackage.dependencies || {}));
1567
+
1568
+ for (const childName of childDependencies) {
1569
+ const cacheKey = `${currentPath}::${childName}`;
1570
+ let childPath = resolutionCache.get(cacheKey);
1571
+ if (childPath === undefined) {
1572
+ childPath = resolvePackagePath(childName, currentPath, packages);
1573
+ resolutionCache.set(cacheKey, childPath);
1574
+ }
1575
+ childPath && stack.push(childPath);
1576
+ }
1577
+ }
1578
+
1579
+ return relevantPaths;
1580
+ };
1581
+
1582
+ const relevantPackagePaths = getRelevantPackagePaths(lockJson.packages, rootDependencies);
1583
+ const incompatiblePackages = [];
1584
+
1585
+ for (const [pkgPath, pkgData] of Object.entries(lockJson.packages)) {
1586
+ // Skip root package entry and entries without engines.node
1587
+ if (!pkgPath || pkgPath === '' || !pkgData || !pkgData.engines || !pkgData.engines.node) {
1588
+ continue;
1589
+ }
1590
+ if (!relevantPackagePaths.has(pkgPath)) {
1591
+ continue;
1592
+ }
1593
+
1594
+ // Extract a readable package name from the path
1595
+ // e.g. "node_modules/foo" -> "foo", "node_modules/foo/node_modules/bar" -> "foo > bar"
1596
+ const pkgName = pkgPath.replace(/^node_modules\//, '').replace(/\/node_modules\//g, ' > ');
1597
+ const nodeReq = pkgData.engines.node;
1598
+
1599
+ try {
1600
+ if (!semver.satisfies(adapterMinVersion.version, nodeReq)) {
1601
+ incompatiblePackages.push(`${pkgName} (requires node: "${nodeReq}")`);
1602
+ }
1603
+ } catch (e) {
1604
+ common.debug(`Could not check node requirement "${nodeReq}" for package "${pkgName}": ${e}`);
1605
+ }
1606
+ }
1607
+
1608
+ if (incompatiblePackages.length > 0) {
1609
+ const maxDisplay = 10;
1610
+ let pkgList = incompatiblePackages.slice(0, maxDisplay).join(', ');
1611
+ if (incompatiblePackages.length > maxDisplay) {
1612
+ pkgList += ` and ${incompatiblePackages.length - maxDisplay} more`;
1613
+ }
1614
+ context.warnings.push(
1615
+ `[W0069] The following dependencies require a node.js version incompatible with the adapter's minimum (node ${minimumNodeJsSupported}): ${pkgList}. Please increase the engines.node requirement at package.json or update/replace the incompatible dependencies.`,
1616
+ );
1617
+ } else {
1618
+ context.checks.push(
1619
+ `All dependency node requirements are compatible with the adapter's minimum node.js version ${minimumNodeJsSupported}.`,
1620
+ );
1621
+ }
1394
1622
 
1395
1623
  return context;
1396
1624
  }
1397
1625
 
1398
1626
  exports.getPackageJson = getPackageJson;
1399
1627
  exports.checkPackageJson = checkPackageJson;
1628
+ exports.checkDependencyNodeRequirements = checkDependencyNodeRequirements;
1400
1629
  exports.validateReleaseFormat = validateReleaseFormat;
1401
1630
 
1402
1631
  // List of error and warnings used at this module
@@ -1474,3 +1703,5 @@ exports.validateReleaseFormat = validateReleaseFormat;
1474
1703
  // [0066] "@types/node":"${typesNodeVersion}" allows node.js major version ${minMajor + 1} or higher. Consider using "^${minMajor}.0.0" or ">=${minMajor} <${minMajor + 1}".
1475
1704
  // [0067] "@types/node":"${typesNodeVersion}" does not cover minimum node.js version ${minimumNodeJsSupported}. Consider updating to ">=${minMajor}".
1476
1705
  // [0068] Invalid semver format ${typesNodeVersion} for devDependency "@types/node" at package.json.
1706
+ // [W0069] The following dependencies require a node.js version incompatible with the adapter's minimum (node ${minimumNodeJsSupported}): ...
1707
+ // [S0070] Dependency node requirement check could not be performed: ...