@iobroker/repochecker 5.14.1 → 5.15.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,14 @@ Example:
25
25
  Placeholder for the next version (at the beginning of the line):
26
26
  ### **WORK IN PROGRESS**
27
27
  -->
28
+ ### 5.15.0 (2026-05-27)
29
+
30
+ - (mcm1957) I18n checks have been extended
31
+
32
+ ### 5.14.2 (2026-05-27)
33
+
34
+ - (mcm1957) Crash when checking github dependencies has been fixed
35
+
28
36
  ### 5.14.1 (2026-05-26)
29
37
 
30
38
  - (mcm1957) support for exceptions for some package update suggestions added
@@ -417,6 +417,8 @@ function expandNpmAliases(dependencies) {
417
417
  * @returns {{ packageName: string; packageVersion: string }} Parsed package name and version
418
418
  */
419
419
  function parseDependencyDeclaration(packageName, packageVersion) {
420
+ common.debug(`executing parseDependencyDeclaration(${packageName}, ${packageVersion})`);
421
+
420
422
  if (typeof packageVersion !== 'string' || !packageVersion.startsWith('npm:')) {
421
423
  return { packageName, packageVersion };
422
424
  }
@@ -474,6 +476,7 @@ function getNpmUpdateRule(context, packageName) {
474
476
  * @returns {Promise<object>} Updated context with dependency update suggestions
475
477
  */
476
478
  async function checkNpmDependencyUpdateSuggestions(context) {
479
+ common.debug(`executing checkNpmDependencyUpdateSuggestions`);
477
480
  const dependencySources = [
478
481
  ['dependencies', context.packageJson.dependencies || {}],
479
482
  ['devDependencies', context.packageJson.devDependencies || {}],
@@ -483,6 +486,12 @@ async function checkNpmDependencyUpdateSuggestions(context) {
483
486
  for (const [sourceType, sourceDeps] of dependencySources) {
484
487
  for (const [declaredName, declaredVersion] of Object.entries(sourceDeps)) {
485
488
  const parsed = parseDependencyDeclaration(declaredName, declaredVersion);
489
+ common.debug(` result: {${parsed.packageName}, ${parsed.packageVersion}}`);
490
+ if (!semver.validRange(parsed.packageVersion)) {
491
+ common.debug(` ${parsed.packageVersion} is invalid, ignored`);
492
+ continue;
493
+ }
494
+
486
495
  const minVersion = semver.minVersion(parsed.packageVersion);
487
496
  if (!minVersion) {
488
497
  continue;
@@ -499,6 +508,8 @@ async function checkNpmDependencyUpdateSuggestions(context) {
499
508
  }
500
509
  }
501
510
 
511
+ common.debug(` deduplictedChecks prepared`);
512
+
502
513
  const now = Date.now();
503
514
  const millisecondsPerDay = 24 * 60 * 60 * 1000;
504
515
 
@@ -513,6 +524,7 @@ async function checkNpmDependencyUpdateSuggestions(context) {
513
524
  return;
514
525
  }
515
526
  try {
527
+ common.debug(` fetching npm data for ${packageName}`);
516
528
  const response = await axios(`https://registry.npmjs.org/${encodeURIComponent(packageName)}`);
517
529
  const npmData = response.data;
518
530
  const latestVersion = npmData?.['dist-tags']?.latest;
@@ -1332,7 +1344,7 @@ async function checkPackageJson(context) {
1332
1344
  const hasEslintV9OrHigher = !!(eslintVersion && semver.gte(eslintVersion, '9.0.0'));
1333
1345
  if (eslintVersion && semver.lt(eslintVersion, '9.0.0')) {
1334
1346
  context.warnings.push(
1335
- `[W0072] "eslint":"${eslintVersionRaw}" is below 9.0.0. Please migrate to "@iobroker/eslint-config".`,
1347
+ `[W0072] "eslint":"${eslintVersionRaw}" is outdated. Please migrate to "@iobroker/eslint-config".`,
1336
1348
  );
1337
1349
  } else if (hasEslintV9OrHigher && !hasEslintConfig) {
1338
1350
  context.warnings.push(
@@ -1362,7 +1374,7 @@ async function checkPackageJson(context) {
1362
1374
  );
1363
1375
  if (foundObsoleteDeps.length > 0) {
1364
1376
  context.warnings.push(
1365
- `[W0078] Remove obsolete eslint/prettier devDependencies when using "@iobroker/eslint-config": ${foundObsoleteDeps.join(', ')}.`,
1377
+ `[W0078] Remove obsolete devDependencies ${foundObsoleteDeps.join(', ')} when using "@iobroker/eslint-config".`,
1366
1378
  );
1367
1379
  }
1368
1380
  }
@@ -1611,7 +1623,8 @@ async function checkEslintFileChecks(context) {
1611
1623
  const eslintVersionRaw = devDeps.eslint;
1612
1624
  const eslintVersion = eslintVersionRaw ? semver.coerce(eslintVersionRaw) : null;
1613
1625
  const hasEslintV9OrHigher = !!(eslintVersion && semver.gte(eslintVersion, '9.0.0'));
1614
- const obsoleteEslintFiles = ['/.eslintignore', '/.eslintrc.json', '/.prettierignore', '/.prettierrc.js'];
1626
+ const obsoleteEslintFiles = ['/.eslintignore', '/.eslintrc.json'];
1627
+ const obsoletePrettierFiles = ['/.prettierignore', '/.prettierrc.js'];
1615
1628
 
1616
1629
  if (hasEslintConfig) {
1617
1630
  if (!fileExistsInList(context, '/eslint.config.mjs')) {
@@ -1644,11 +1657,21 @@ async function checkEslintFileChecks(context) {
1644
1657
  context.checks.push('"prettier.config.mjs" found.');
1645
1658
  }
1646
1659
 
1647
- const foundObsoleteFiles = obsoleteEslintFiles.filter(file => fileExistsInList(context, file));
1648
- if (foundObsoleteFiles.length > 0) {
1649
- context.warnings.push(
1650
- `[W0079] Remove obsolete eslint/prettier config files when using "@iobroker/eslint-config": ${foundObsoleteFiles.map(file => file.slice(1)).join(', ')}.`,
1651
- );
1660
+ if (fileExistsInList(context, '/eslint.config.mjs')) {
1661
+ const foundObsoleteFiles = obsoleteEslintFiles.filter(file => fileExistsInList(context, file));
1662
+ if (foundObsoleteFiles.length > 0) {
1663
+ context.warnings.push(
1664
+ `[W0079] Remove obsolete eslint config files when using "/eslint.config.mjs": ${foundObsoleteFiles.map(file => file.slice(1)).join(', ')}.`,
1665
+ );
1666
+ }
1667
+ }
1668
+ if (fileExistsInList(context, '/prettier.config.mjs')) {
1669
+ const foundObsoleteFiles = obsoletePrettierFiles.filter(file => fileExistsInList(context, file));
1670
+ if (foundObsoleteFiles.length > 0) {
1671
+ context.warnings.push(
1672
+ `[W0084] Remove obsolete prettier config files when using "/prettier.config.mjs": ${foundObsoleteFiles.map(file => file.slice(1)).join(', ')}.`,
1673
+ );
1674
+ }
1652
1675
  }
1653
1676
  } else if (hasEslintV9OrHigher) {
1654
1677
  const foundObsoleteFiles = obsoleteEslintFiles.filter(file => fileExistsInList(context, file));
@@ -1980,7 +2003,8 @@ exports.validateReleaseFormat = validateReleaseFormat;
1980
2003
  // [W0078] Obsolete eslint/prettier devDependencies found while "@iobroker/eslint-config" is used.
1981
2004
  // [W0079] Obsolete eslint/prettier config files found while "@iobroker/eslint-config" is used.
1982
2005
  // [S0080] Obsolete eslint/prettier config files found for adapters using eslint >= 9.0.0 without "@iobroker/eslint-config".
1983
-
1984
2006
  // [E0081] Could not read "eslint.config.mjs": ${e.message || e}
1985
2007
  // [S0082] Package "${packageName}" (${sourceType}) can be updated from ${packageVersion} to ${latestVersion}. ...
1986
2008
  // [W0083] Package "${packageName}" (${sourceType}) can be updated from ${packageVersion} to ${latestVersion}. ...
2009
+ // [W0084] Remove obsolete prettier config files when using "/prettier.config.mjs": ${foundObsoleteFiles.map(file => file.slice(1)).join(', ')}.
2010
+
package/lib/M2000_Npm.js CHANGED
@@ -122,6 +122,14 @@ async function checkNpm(context) {
122
122
  }
123
123
 
124
124
  if (body['dist-tags'] && body['dist-tags'].latest) {
125
+ context.npmLatestVersion = body['dist-tags'].latest;
126
+ const latestVersionData = body.versions && body.versions[context.npmLatestVersion];
127
+ context.npmLatestHasProvenance = !!(
128
+ latestVersionData &&
129
+ latestVersionData.dist &&
130
+ latestVersionData.dist.provenance
131
+ );
132
+
125
133
  if (common.isAlphaVersion(body['dist-tags'].latest)) {
126
134
  context.warnings.push(
127
135
  `[W2007] Version ${body['dist-tags'].latest} is tagged as "latest" at npm. Pre-release versions must not be tagged as "latest" and will be ignored by repository updates.`,
@@ -130,6 +138,14 @@ async function checkNpm(context) {
130
138
  context.checks.push(`Latest npm version ${body['dist-tags'].latest} is a normal release`);
131
139
  }
132
140
 
141
+ if (context.npmLatestHasProvenance) {
142
+ context.checks.push(`Latest npm version ${body['dist-tags'].latest} is signed with provenance`);
143
+ } else {
144
+ context.warnings.push(
145
+ `[S2008] Version ${body['dist-tags'].latest} tagged as "latest" at npm is not signed with provenance. Trusted publishing is recommended.`,
146
+ );
147
+ }
148
+
133
149
  if (context.packageJson.version !== body['dist-tags'].latest) {
134
150
  if (compareVersions.compare(body['dist-tags'].latest, context.packageJson.version, '>=')) {
135
151
  context.errors.push(
@@ -205,3 +221,4 @@ exports.getNpm = getNpm;
205
221
  // [2004] Versions "${missingVersions.join(', ')}" listed at common.news at io-package.json do not exist at NPM. Please remove from news section.
206
222
  // [2006] Package iobroker.${context.adapterName} has no valid published version on npm. Please publish a version.
207
223
  // [W2007] Version ${body['dist-tags'].latest} is tagged as "latest" at npm but is a pre-release version. Alpha/pre-release versions must not be tagged as "latest" and will be ignored by repository updates.
224
+ // [S2008] Version ${body['dist-tags'].latest} tagged as "latest" at npm is not signed with provenance.
package/lib/M5000_Code.js CHANGED
@@ -16,6 +16,7 @@ const yaml = require('js-yaml');
16
16
 
17
17
  const common = require('./common.js');
18
18
  const M5500__jsonConfig = require('./M5500__JsonConfig.js');
19
+ const M5600__I18n = require('./M5600__I18n.js');
19
20
 
20
21
  // YAML file extensions for validation
21
22
  const yamlExtensions = ['.yml', '.yaml'];
@@ -445,6 +446,14 @@ async function checkCode(context) {
445
446
  }
446
447
  });
447
448
 
449
+ // Add all i18n translation files discovered across the entire repository tree
450
+ M5600__I18n.getI18nFilesToRead(tempFilesList).forEach(filePath => {
451
+ const normalizedPath = filePath.startsWith('/') ? filePath : `/${filePath}`;
452
+ if (!readFiles.includes(normalizedPath)) {
453
+ readFiles.push(normalizedPath);
454
+ }
455
+ });
456
+
448
457
  // if (!context.ioPackageJson.common.noConfig) {
449
458
  // if (context.ioPackageJson.common.materialize || (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'materialize')) {
450
459
  // readFiles.push('admin/index_m.html');
@@ -792,27 +801,37 @@ async function checkCode(context) {
792
801
  }
793
802
 
794
803
  if (jsonConfig) {
795
- if (jsonConfig.i18n === true) {
804
+ // Resolve the i18n directory: default is admin/i18n, but may be overridden by a string attribute
805
+ // Note that i18n value is relative to the location of jsonConfig
806
+ const i18nAttr = jsonConfig.i18n;
807
+ const i18nDir =
808
+ typeof i18nAttr === 'string' && i18nAttr.trim() !== '' ? `/admin/${i18nAttr.trim()}` : '/admin/i18n';
809
+
810
+ if (i18nAttr === true || typeof i18nAttr === 'string') {
796
811
  context.cfg.allowedLanguages.forEach(lang => {
797
- if (context[`/admin/i18n/${lang}/translations.json`]) {
812
+ if (context[`${i18nDir}/${lang}/translations.json`]) {
798
813
  try {
799
- JSON.parse(context[`/admin/i18n/${lang}/translations.json`]);
814
+ JSON.parse(context[`${i18nDir}/${lang}/translations.json`]);
800
815
  } catch (e) {
801
- context.errors.push(`[E5009] Cannot parse "admin/i18n/${lang}/translations.json": ${e}`);
816
+ context.errors.push(
817
+ `[E5009] Cannot parse "${i18nDir.replace(/^\//, '')}/${lang}/translations.json": ${e}`,
818
+ );
802
819
  }
803
- } else if (context[`/admin/i18n/${lang}.json`]) {
820
+ } else if (context[`${i18nDir}/${lang}.json`]) {
804
821
  try {
805
- JSON.parse(context[`/admin/i18n/${lang}.json`]);
822
+ JSON.parse(context[`${i18nDir}/${lang}.json`]);
806
823
  } catch (e) {
807
- context.errors.push(`[E5009] Cannot parse "admin/i18n/${lang}.json": ${e}`);
824
+ context.errors.push(
825
+ `[E5009] Cannot parse "${i18nDir.replace(/^\//, '')}/${lang}.json": ${e}`,
826
+ );
808
827
  }
809
828
  } else {
810
829
  context.errors.push(
811
- `[E5010] "/admin/i18n/${lang}/translations.json" or "admin/i18n/${lang}.json" not found, but admin support is declared. Please add.`,
830
+ `[E5010] "${i18nDir.replace(/^\//, '')}/${lang}/translations.json" or "${i18nDir.replace(/^\//, '')}/${lang}.json" not found, but admin support is declared. Please add.`,
812
831
  );
813
832
  }
814
833
  });
815
- } else if (jsonConfig.i18n === false) {
834
+ } else if (i18nAttr === false) {
816
835
  context.warnings.push(`[W5015] Why did you decide to disable i18n support?`);
817
836
  } else {
818
837
  context.warnings.push(`[W5022] Why did you decide not to use i18n support?`);
@@ -1772,6 +1791,9 @@ async function checkCode(context) {
1772
1791
 
1773
1792
  // 5500 - xxx reserved for jsonConfig module
1774
1793
 
1794
+ // 5600 - 5699: comprehensive i18n checks across the full repository
1795
+ M5600__I18n.checkAllI18n(context);
1796
+
1775
1797
  return context;
1776
1798
  }
1777
1799
 
@@ -0,0 +1,508 @@
1
+ 'use strict';
2
+ /*
3
+ This module is a support module for iobroker.repochecker
4
+
5
+ Area checked: i18n translation files
6
+ Numbering : 5600 - 5699
7
+
8
+ */
9
+
10
+ const JSON5 = require('json5');
11
+
12
+ const common = require('./common.js');
13
+
14
+ // Directories to always exclude when scanning for i18n content
15
+ const I18N_EXCLUDED_DIRS = new Set(['node_modules', '.git', '.vscode', '.dev-server']);
16
+
17
+ // Translatable attributes in jsonConfig to scan for proper i18n usage.
18
+ // Add new attribute names here to extend the list of attributes checked.
19
+ const TRANSLATABLE_ATTRS = [
20
+ 'label',
21
+ 'textAlive',
22
+ 'textNotAlive',
23
+ 'tooltip',
24
+ 'help',
25
+ 'placeholder',
26
+ 'validatorErrorText',
27
+ ];
28
+
29
+ /**
30
+ * Escape a string for use as a literal in a regular expression.
31
+ *
32
+ * @param {string} str - The string to escape.
33
+ * @returns {string} - The escaped string safe for use in a RegExp constructor.
34
+ */
35
+ function escapeRegex(str) {
36
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
37
+ }
38
+
39
+ /**
40
+ * Discover all i18n directory paths from the repository file list.
41
+ * Recognises both long format ({lang}/translations.json) and short format ({lang}.json).
42
+ *
43
+ * @param {string[]} filesList - list of file paths (each with a leading slash)
44
+ * @returns {string[]} - unique i18n directory paths (with leading slash), e.g. ['/admin/i18n']
45
+ */
46
+ function discoverI18nDirs(filesList) {
47
+ const i18nDirs = new Set();
48
+
49
+ for (const filePath of filesList) {
50
+ // Skip files inside excluded directories
51
+ const parts = filePath.split('/').filter(p => p !== '');
52
+ if (parts.some(p => I18N_EXCLUDED_DIRS.has(p))) {
53
+ continue;
54
+ }
55
+
56
+ // Long format: .../i18n/{lang}/translations.json
57
+ const longMatch = filePath.match(/^(.*\/i18n)\/([^/]+)\/translations\.json$/);
58
+ if (longMatch) {
59
+ i18nDirs.add(longMatch[1]);
60
+ continue;
61
+ }
62
+
63
+ // Short format: .../i18n/{lang}.json
64
+ const shortMatch = filePath.match(/^(.*\/i18n)\/([^/]+)\.json$/);
65
+ if (shortMatch) {
66
+ i18nDirs.add(shortMatch[1]);
67
+ }
68
+ }
69
+
70
+ return [...i18nDirs];
71
+ }
72
+
73
+ /**
74
+ * Return the list of i18n-related file paths that need to be loaded.
75
+ * Called before the main file-loading phase to ensure all i18n files are available.
76
+ *
77
+ * @param {string[]} filesList - List of all repository file paths (each with a leading slash).
78
+ * @returns {string[]} - i18n file paths to include in the readFiles list.
79
+ */
80
+ function getI18nFilesToRead(filesList) {
81
+ const filesToRead = [];
82
+
83
+ for (const filePath of filesList) {
84
+ // Skip files inside excluded directories
85
+ const parts = filePath.split('/').filter(p => p !== '');
86
+ if (parts.some(p => I18N_EXCLUDED_DIRS.has(p))) {
87
+ continue;
88
+ }
89
+
90
+ // Long format: .../i18n/{lang}/translations.json
91
+ if (/\/i18n\/[^/]+\/translations\.json$/.test(filePath)) {
92
+ filesToRead.push(filePath);
93
+ } else if (/\/i18n\/[^/]+\.json$/.test(filePath)) {
94
+ // Short format: .../i18n/{lang}.json
95
+ filesToRead.push(filePath);
96
+ }
97
+ }
98
+
99
+ return filesToRead;
100
+ }
101
+
102
+ /**
103
+ * Determine which language files exist in an i18n directory and in which format.
104
+ *
105
+ * @param {string} i18nDir - Directory path like '/admin/i18n'.
106
+ * @param {string[]} filesList - List of all repository file paths.
107
+ * @returns {{ longFormat: Set<string>, shortFormat: Set<string> }} - Sets of language codes per format.
108
+ */
109
+ function getI18nFormats(i18nDir, filesList) {
110
+ const longFormat = new Set();
111
+ const shortFormat = new Set();
112
+ const escaped = escapeRegex(i18nDir);
113
+
114
+ for (const filePath of filesList) {
115
+ const longMatch = filePath.match(new RegExp(`^${escaped}/([^/]+)/translations\\.json$`));
116
+ if (longMatch) {
117
+ longFormat.add(longMatch[1]);
118
+ continue;
119
+ }
120
+ const shortMatch = filePath.match(new RegExp(`^${escaped}/([^/]+)\\.json$`));
121
+ if (shortMatch) {
122
+ shortFormat.add(shortMatch[1]);
123
+ }
124
+ }
125
+
126
+ return { longFormat, shortFormat };
127
+ }
128
+
129
+ /**
130
+ * Load and parse translation objects for all available languages in an i18n directory.
131
+ *
132
+ * @param {string} i18nDir - The i18n directory path, e.g. '/admin/i18n'.
133
+ * @param {Set<string>} longFormat - languages present in long format
134
+ * @param {Set<string>} shortFormat - languages present in short format
135
+ * @param {object} context - The repochecker context object.
136
+ * @returns {Map<string, object>} - lang → parsed translations object
137
+ */
138
+ function loadTranslations(i18nDir, longFormat, shortFormat, context) {
139
+ const translations = new Map();
140
+
141
+ // Long format: {lang}/translations.json
142
+ for (const lang of longFormat) {
143
+ const key = `${i18nDir}/${lang}/translations.json`;
144
+ if (context[key]) {
145
+ try {
146
+ translations.set(lang, JSON.parse(context[key]));
147
+ } catch {
148
+ // Parse errors are reported elsewhere (E5009)
149
+ }
150
+ }
151
+ }
152
+
153
+ // Short format: {lang}.json – only when not already loaded via long format
154
+ for (const lang of shortFormat) {
155
+ if (!translations.has(lang)) {
156
+ const key = `${i18nDir}/${lang}.json`;
157
+ if (context[key]) {
158
+ try {
159
+ translations.set(lang, JSON.parse(context[key]));
160
+ } catch {
161
+ // Parse errors are reported elsewhere (E5009)
162
+ }
163
+ }
164
+ }
165
+ }
166
+
167
+ return translations;
168
+ }
169
+
170
+ /**
171
+ * Check a single i18n directory for format consistency, language completeness,
172
+ * and translation key consistency.
173
+ *
174
+ * @param {object} context - The repochecker context object.
175
+ * @param {string} i18nDir - Absolute path like '/admin/i18n'.
176
+ */
177
+ function checkI18nDirectory(context, i18nDir) {
178
+ const displayDir = i18nDir.replace(/^\//, '');
179
+ const { allowedLanguages, requiredLanguages } = context.cfg;
180
+ const { longFormat, shortFormat } = getI18nFormats(i18nDir, context.filesList);
181
+
182
+ // E5600: Both formats coexist for the same language in the same directory
183
+ const bothFormats = [...longFormat].filter(lang => shortFormat.has(lang));
184
+ if (bothFormats.length > 0) {
185
+ context.errors.push(
186
+ `[E5600] i18n directory "${displayDir}" contains both long format ({lang}/translations.json) and short format ({lang}.json) for language(s): ${bothFormats.join(', ')}. Please use only one format.`,
187
+ );
188
+ }
189
+
190
+ // S5601: Long format in use → suggest migration to short format
191
+ if (longFormat.size > 0) {
192
+ context.warnings.push(
193
+ `[S5601] i18n directory "${displayDir}" uses long format ({lang}/translations.json). Consider migrating to short format ({lang}.json) using "npm run translate convert".`,
194
+ );
195
+ }
196
+
197
+ // All detected languages (union of both formats)
198
+ const allDetected = new Set([...longFormat, ...shortFormat]);
199
+
200
+ // E5602: Required language missing → error
201
+ for (const lang of requiredLanguages) {
202
+ if (!allDetected.has(lang)) {
203
+ context.errors.push(`[E5602] i18n directory "${displayDir}" is missing required language "${lang}".`);
204
+ }
205
+ }
206
+
207
+ // W5603: Non-required allowed language missing → warning
208
+ for (const lang of allowedLanguages) {
209
+ if (!requiredLanguages.includes(lang) && !allDetected.has(lang)) {
210
+ context.warnings.push(`[W5603] i18n directory "${displayDir}" is missing language "${lang}".`);
211
+ }
212
+ }
213
+
214
+ // Load translations for key-consistency checks
215
+ const translations = loadTranslations(i18nDir, longFormat, shortFormat, context);
216
+ const enTranslations = translations.get('en');
217
+
218
+ if (!enTranslations) {
219
+ common.debug(`No English translations available for "${displayDir}", skipping key-consistency checks.`);
220
+ return;
221
+ }
222
+
223
+ const enKeys = new Set(Object.keys(enTranslations));
224
+
225
+ for (const [lang, langTranslations] of translations) {
226
+ if (lang === 'en') {
227
+ continue;
228
+ }
229
+
230
+ const langKeys = new Set(Object.keys(langTranslations));
231
+
232
+ // W5604: Keys in English not present in other language (missing translations)
233
+ const missingInLang = [...enKeys].filter(k => !langKeys.has(k));
234
+ if (missingInLang.length > 0) {
235
+ context.warnings.push(
236
+ `[W5604] i18n "${displayDir}" language "${lang}" is missing ${missingInLang.length} key(s) present in English: ${missingInLang.slice(0, 5).join(', ')}${missingInLang.length > 5 ? ', ...' : ''}`,
237
+ );
238
+ }
239
+
240
+ // W5605: Keys in other language not present in English (outdated translations)
241
+ const outdated = [...langKeys].filter(k => !enKeys.has(k));
242
+ if (outdated.length > 0) {
243
+ context.warnings.push(
244
+ `[W5605] i18n "${displayDir}" language "${lang}" has ${outdated.length} outdated key(s) not present in English: ${outdated.slice(0, 5).join(', ')}${outdated.length > 5 ? ', ...' : ''}`,
245
+ );
246
+ }
247
+
248
+ // W5606: Too many identical translations (>5 non-trivial identical strings)
249
+ const identical = [...enKeys].filter(
250
+ k =>
251
+ langKeys.has(k) &&
252
+ typeof enTranslations[k] === 'string' &&
253
+ typeof langTranslations[k] === 'string' &&
254
+ enTranslations[k].length > 1 &&
255
+ enTranslations[k] === langTranslations[k],
256
+ );
257
+ if (identical.length > [...enKeys].length * 0.75) {
258
+ context.warnings.push(
259
+ `[W5606] i18n "${displayDir}" language "${lang}" has ${identical.length} translation(s) identical to English (i.e. ${identical[0]}). This may indicate untranslated content.`,
260
+ );
261
+ }
262
+ }
263
+ }
264
+
265
+ /**
266
+ * Recursively collect translatable attribute values from a jsonConfig node.
267
+ *
268
+ * @param {any} node - jsonConfig node to scan
269
+ * @param {string} currentPath - path in the jsonConfig for error reporting
270
+ * @returns {Array<{attr: string, value: any, path: string, noTranslation: boolean}>} - Collected attribute entries.
271
+ */
272
+ function collectTranslatableValues(node, currentPath) {
273
+ if (!node || typeof node !== 'object') {
274
+ return [];
275
+ }
276
+
277
+ const results = [];
278
+
279
+ if (Array.isArray(node)) {
280
+ node.forEach((item, i) => {
281
+ results.push(...collectTranslatableValues(item, `${currentPath}[${i}]`));
282
+ });
283
+ return results;
284
+ }
285
+
286
+ // If this node has noTranslation set, its string values should not be checked
287
+ const noTranslation = node.noTranslation === true;
288
+
289
+ for (const [key, value] of Object.entries(node)) {
290
+ if (TRANSLATABLE_ATTRS.includes(key) && value !== undefined && value !== null) {
291
+ results.push({ attr: key, value, path: currentPath, noTranslation });
292
+ }
293
+
294
+ // Recurse into child objects and arrays
295
+ if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
296
+ results.push(...collectTranslatableValues(value, `${currentPath}/${key}`));
297
+ } else if (Array.isArray(value)) {
298
+ value.forEach((item, i) => {
299
+ if (typeof item === 'object' && item !== null) {
300
+ results.push(...collectTranslatableValues(item, `${currentPath}/${key}[${i}]`));
301
+ }
302
+ });
303
+ }
304
+ }
305
+
306
+ return results;
307
+ }
308
+
309
+ /**
310
+ * Determine the i18n directory associated with a jsonConfig file.
311
+ * The default is the same directory as the jsonConfig file + '/i18n'.
312
+ * If the jsonConfig has an `i18n` string attribute, that path is used instead
313
+ * (interpreted as relative to the repository root).
314
+ *
315
+ * @param {string} configFile - file path like '/admin/jsonConfig.json'
316
+ * @param {object} jsonConfig - parsed jsonConfig object
317
+ * @returns {string} - resolved i18n directory path like '/admin/i18n'
318
+ */
319
+ function getI18nDirForJsonConfig(context, configFile, jsonConfig) {
320
+ const configDir = configFile.replace(/\/[^/]+$/, '') || ''; // e.g. '/admin', or '' for root-level files
321
+ if (typeof jsonConfig.i18n === 'string' && jsonConfig.i18n.trim() !== '') {
322
+ const customPath = jsonConfig.i18n.trim();
323
+ if (!customPath.endsWith('/i18n')){
324
+ context.errors.push(
325
+ `[E5618] "Custom path specified at i18n attribute (${customPath}) must end with '/i18n'`,
326
+ );
327
+ }
328
+ // Interpret as absolute path from repo root (with leading slash) or relative to admin
329
+ return customPath.startsWith('/') ? customPath : `/admin/${customPath}`;
330
+ }
331
+
332
+ // Default: directory of the jsonConfig file + '/i18n'
333
+ return `${configDir}/i18n`;
334
+ }
335
+
336
+ /**
337
+ * Check translatable attributes in a jsonConfig for proper i18n handling.
338
+ *
339
+ * @param {object} context - The repochecker context object.
340
+ * @param {string} configFile - file path like '/admin/jsonConfig.json'
341
+ * @param {object} jsonConfig - parsed jsonConfig object
342
+ * @param {string} i18nDir - associated i18n directory path like '/admin/i18n'
343
+ */
344
+ function checkJsonConfigTranslations(context, configFile, jsonConfig, i18nDir) {
345
+ const displayConfig = configFile.replace(/^\//, '');
346
+ const { allowedLanguages, requiredLanguages } = context.cfg;
347
+ const i18nMode = jsonConfig.i18n;
348
+
349
+ // Load English translations for string-key checking
350
+ let enTranslations = null;
351
+ const enLongKey = `${i18nDir}/en/translations.json`;
352
+ const enShortKey = `${i18nDir}/en.json`;
353
+ if (context[enLongKey]) {
354
+ try {
355
+ enTranslations = JSON.parse(context[enLongKey]);
356
+ } catch {
357
+ /* parse errors are reported elsewhere */
358
+ }
359
+ } else if (context[enShortKey]) {
360
+ try {
361
+ enTranslations = JSON.parse(context[enShortKey]);
362
+ } catch {
363
+ /* parse errors are reported elsewhere */
364
+ }
365
+ }
366
+
367
+ // Determine whether any i18n files exist at the expected directory
368
+ const escaped = escapeRegex(i18nDir);
369
+ const i18nDirExists = context.filesList.some(f => new RegExp(`^${escaped}/`).test(f));
370
+
371
+ // W5615: i18n enabled but the i18n directory is absent
372
+ if (i18nMode === true || typeof i18nMode === 'string') {
373
+ if (!i18nDirExists) {
374
+ context.warnings.push(
375
+ `[W5615] "${displayConfig}" has i18n enabled but no i18n directory found at "${i18nDir.replace(/^\//, '')}". Please create translation files.`,
376
+ );
377
+ }
378
+ }
379
+
380
+ // W5614: i18n=false but an i18n directory exists (will not be used)
381
+ if (i18nMode === false) {
382
+ if (i18nDirExists) {
383
+ context.warnings.push(
384
+ `[W5614] "${displayConfig}" has i18n=false but an i18n directory exists at "${i18nDir.replace(/^\//, '')}". This i18n directory will not be used by this jsonConfig.`,
385
+ );
386
+ }
387
+ }
388
+
389
+ // Scan for translatable attributes only when i18n is explicitly configured
390
+ // (skip when i18n is not set to avoid flooding adapters that use words.js or other mechanisms)
391
+ if (i18nMode === undefined || i18nMode === null) {
392
+ return;
393
+ }
394
+
395
+ const translatables = collectTranslatableValues(jsonConfig, displayConfig);
396
+
397
+ for (const { attr, value, path, noTranslation } of translatables) {
398
+ // Skip attributes where the component declares noTranslation: true
399
+ if (noTranslation) {
400
+ continue;
401
+ }
402
+
403
+ if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
404
+ // Value is an inline i18n object (e.g. { en: "Name", de: "Name" })
405
+ if (i18nMode === true || typeof i18nMode === 'string') {
406
+ // When i18n files are used, translatable attributes should be string keys
407
+ // context.warnings.push(
408
+ // `[W5616] "${path}" attribute "${attr}" defines inline i18n object while i18n is enabled. Consider using a translation key string instead.`,
409
+ // );
410
+ } else {
411
+ // i18n=false: check that required languages are present in the object
412
+ for (const lang of requiredLanguages) {
413
+ if (!Object.prototype.hasOwnProperty.call(value, lang)) {
414
+ context.errors.push(
415
+ `[E5610] "${path}" attribute "${attr}" is missing required language "${lang}" in i18n object.`,
416
+ );
417
+ }
418
+ }
419
+ for (const lang of allowedLanguages) {
420
+ if (!requiredLanguages.includes(lang) && !Object.prototype.hasOwnProperty.call(value, lang)) {
421
+ context.warnings.push(
422
+ `[W5611] "${path}" attribute "${attr}" is missing language "${lang}" in i18n object.`,
423
+ );
424
+ }
425
+ }
426
+ }
427
+ } else if (typeof value === 'string') {
428
+ if (i18nMode === false) {
429
+ // When i18n=false, translatable attributes should be inline objects
430
+ context.warnings.push(
431
+ `[W5617] "${path}" attribute "${attr}" uses a plain string while jsonConfig has i18n=false. Consider using an inline i18n object instead.`,
432
+ );
433
+ } else if (enTranslations !== null) {
434
+ // i18n enabled: check that the string is a valid key in the English translations
435
+ if (!Object.prototype.hasOwnProperty.call(enTranslations, value)) {
436
+ if (value.match(/[a-zA-Z]/) && value.length >= 3) {
437
+ // do not force translations of labels containing no characters
438
+ context.warnings.push(
439
+ `[W5612] "${path}" attribute "${attr}" uses key "${value}" which is not found in the English translation file at "${i18nDir.replace(/^\//, '')}/en".`,
440
+ );
441
+ }
442
+ }
443
+ }
444
+ }
445
+ }
446
+ }
447
+
448
+ /**
449
+ * Main entry point: check all i18n directories found in the repository and
450
+ * validate jsonConfig files for correct i18n attribute usage.
451
+ *
452
+ * @param {object} context - The repochecker context object.
453
+ */
454
+ function checkAllI18n(context) {
455
+ //console.log('\n[5600 - 5699] checkAllI18n');
456
+
457
+ // 1. Check every discovered i18n directory
458
+ const i18nDirs = discoverI18nDirs(context.filesList);
459
+ common.debug(`Discovered ${i18nDirs.length} i18n director(ies): ${i18nDirs.join(', ')}`);
460
+
461
+ for (const i18nDir of i18nDirs) {
462
+ checkI18nDirectory(context, i18nDir);
463
+ }
464
+
465
+ // 2. Check jsonConfig files for correct i18n attribute usage and translatable attribute consistency
466
+ const jsonConfigFiles = ['/admin/jsonConfig.json', '/admin/jsonConfig.json5'];
467
+
468
+ for (const configFile of jsonConfigFiles) {
469
+ if (!context[configFile]) {
470
+ continue;
471
+ }
472
+
473
+ let jsonConfig;
474
+ try {
475
+ jsonConfig = configFile.endsWith('.json5')
476
+ ? JSON5.parse(context[configFile])
477
+ : JSON.parse(context[configFile]);
478
+ } catch {
479
+ // Parse errors are reported elsewhere (E5007)
480
+ continue;
481
+ }
482
+
483
+ const i18nDir = getI18nDirForJsonConfig(context, configFile, jsonConfig);
484
+ checkJsonConfigTranslations(context, configFile, jsonConfig, i18nDir);
485
+ }
486
+ }
487
+
488
+ exports.checkAllI18n = checkAllI18n;
489
+ exports.getI18nFilesToRead = getI18nFilesToRead;
490
+
491
+ // List of error and warning codes used by this module
492
+ // ----------------------------------------------------
493
+
494
+ // [E5600] i18n directory contains both long and short format for the same language
495
+ // [S5601] Suggest migrating from long format to short format using npm run translate convert
496
+ // [E5602] i18n directory is missing a required language
497
+ // [W5603] i18n directory is missing a non-required language
498
+ // [W5604] English translation key not present in another language (missing translation)
499
+ // [W5605] Translation key in non-English file not present in English (outdated translation)
500
+ // [W5606] More than 5 translations are identical between English and another language
501
+ // [E5610] jsonConfig translatable attribute i18n object missing a required language
502
+ // [W5611] jsonConfig translatable attribute i18n object missing a non-required language
503
+ // [W5612] jsonConfig translatable attribute string key not found in English translation file
504
+ // [W5614] jsonConfig has i18n=false but an i18n directory exists (will not be used)
505
+ // [W5615] jsonConfig has i18n enabled but the expected i18n directory does not exist
506
+ // [W5616] jsonConfig has i18n enabled but a translatable attribute uses an inline i18n object
507
+ // [W5617] jsonConfig has i18n=false but a translatable attribute uses a plain string
508
+ // [E5618] "Custom path specified at i18n attribute (${customPath}) must end with '/i18n'
@@ -93,6 +93,38 @@ async function checkGithubRepo(context) {
93
93
  context.errors.push(`[E8003] Archived repositories are not allowed.`);
94
94
  }
95
95
 
96
+ let releases = [];
97
+ try {
98
+ const releasesResponse = await axios(`${context.githubUrlApi}/releases?per_page=20`);
99
+ releases = Array.isArray(releasesResponse.data) ? releasesResponse.data : [];
100
+ } catch (e) {
101
+ common.error(`error downloading release info from ${context.githubUrlApi}/releases - ${e}`);
102
+ }
103
+
104
+ if (!releases.length) {
105
+ context.warnings.push(
106
+ '[S8005] No GitHub release found. Please use GitHub releases for easier identification of the current release and consider using "@iobroker/action-deploy".',
107
+ );
108
+ } else if (context.npmLatestVersion) {
109
+ const latestGithubRelease =
110
+ releases.find(release => !release.draft && !release.prerelease) ||
111
+ releases.find(release => !release.draft) ||
112
+ releases[0];
113
+ const latestGithubTag = latestGithubRelease && latestGithubRelease.tag_name ? latestGithubRelease.tag_name : '';
114
+ const normalizedGithubTag = latestGithubTag.replace(/^v/i, '');
115
+ const normalizedNpmVersion = context.npmLatestVersion.replace(/^v/i, '');
116
+
117
+ if (normalizedGithubTag !== normalizedNpmVersion) {
118
+ context.warnings.push(
119
+ `[W8005] Latest GitHub release tag (${latestGithubTag}) does not match latest npm version (${context.npmLatestVersion}).`,
120
+ );
121
+ } else {
122
+ context.checks.push(
123
+ `Latest GitHub release tag ${latestGithubTag} matches latest npm version ${context.npmLatestVersion}`,
124
+ );
125
+ }
126
+ }
127
+
96
128
  const issues = await getAllIssues(context);
97
129
  for (const issue of issues) {
98
130
  // if (issue.pull_request) {
@@ -138,5 +170,7 @@ exports.checkGithubRepo = checkGithubRepo;
138
170
  // [E8001] No repository about text found. Please go to "${context.githubUrlOriginal}", press the settings button beside the about title and add the description.
139
171
  // [E8002] No topics found in the repository. Please go to "${context.githubUrlOriginal}", press the settings button beside the about title and add some topics.
140
172
  // [E8003] Archived repositories are not allowed.
173
+ // [W8005] Latest GitHub release tag does not match latest npm version.
174
+ // [S8005] No GitHub release found. Please use GitHub releases and consider using "@iobroker/action-deploy".
141
175
  //
142
176
  // [E8900 - E8999] Dependabot checks - see M8900__Dependabot.js
package/lib/config.js CHANGED
@@ -469,7 +469,7 @@ const testingNodeJs = {
469
469
  };
470
470
 
471
471
  const npmUpdateSuggestions = {
472
- defaultMinimumAgeDays: 90,
472
+ defaultMinimumAgeDays: 180,
473
473
  newAdapterMinimumAgeDays: 7,
474
474
  standardPackages: [],
475
475
  blacklistedPackages: ['@types/node'], // do not check
@@ -34,7 +34,8 @@ const mapSeverity4New = {
34
34
  W1084: 'E', // [W1084] "common.title" is deprecated and replaced by "common.titleLang".
35
35
  W2007: 'E', // [W2007] Version 0.7.0-beta.2 is tagged as "latest" at npm
36
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.
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.
38
+ W3027: 'E', // [W3027] Workflow "test-and-release.yml": job "adapter-tests" OS matrix is missing: windows-latest, macos-latest. Consider adding tests for all of: ubuntu-latest, windows-latest, macos-latest
38
39
  W5512: 'E', // [W5512] admin/jsonConfig.json schema validation error: ...
39
40
  W6020: 'E', // [W6020] Consider adding a CHANGELOG_OLD.md file to store older changelog entries.
40
41
  W6021: 'E', // [W6021] "## License" is not the last section in README.md.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.14.1",
2
+ "version": "5.15.0",
3
3
  "name": "@iobroker/repochecker",
4
4
  "dependencies": {
5
5
  "ajv": "^8.20.0",