@iobroker/repochecker 5.18.10 → 5.19.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,17 @@ Example:
25
25
  Placeholder for the next version (at the beginning of the line):
26
26
  ### **WORK IN PROGRESS**
27
27
  -->
28
+ ### 5.19.0 (2026-06-27)
29
+
30
+ - (mcm1957) github install detection has been enhanced
31
+ - (mcm1957) checking of untranslated i18n keys has been enhanced
32
+ - (mcm1957) disallow npm installation scripts
33
+
34
+ ### 5.18.11 (2026-06-24)
35
+
36
+ - (mcm1957) blacklisting for dependency versionchecking checking added
37
+ - (mcm1957) handling of i18n attirbute at jsonConfig has been adapted
38
+
28
39
  ### 5.18.10 (2026-06-23)
29
40
 
30
41
  - (mcm1957) some more directories have been excluded from dependency scan
@@ -497,6 +497,16 @@ function getNpmUpdateRule(context, packageName) {
497
497
  * @returns {Promise<object>} Updated context with dependency update suggestions
498
498
  */
499
499
  async function checkNpmDependencyUpdateSuggestions(context) {
500
+ const blackListedDependencies = [
501
+ '@iobroker/adapter-core',
502
+ '@alcalzone/release-script',
503
+ '@alcalzone/release-script-plugin-iobroker',
504
+ '@alcalzone/release-script-plugin-license',
505
+ '@alcalzone/release-script-plugin-manual-review',
506
+ '@iobroker/adapter-dev',
507
+ '@iobroker/eslint-config',
508
+ '@iobroker/testing',
509
+ ];
500
510
  common.debug(`executing checkNpmDependencyUpdateSuggestions`);
501
511
  const dependencySources = [
502
512
  ['dependencies', context.packageJson.dependencies || {}],
@@ -508,6 +518,11 @@ async function checkNpmDependencyUpdateSuggestions(context) {
508
518
  for (const [declaredName, declaredVersion] of Object.entries(sourceDeps)) {
509
519
  const parsed = parseDependencyDeclaration(declaredName, declaredVersion);
510
520
  common.debug(` result: {${parsed.packageName}, ${parsed.packageVersion}}`);
521
+ if (blackListedDependencies.includes(parsed.packageName)) {
522
+ common.debug(` ${parsed.packageName} is blacklisted, ignored`);
523
+ continue;
524
+ }
525
+
511
526
  if (!semver.validRange(parsed.packageVersion)) {
512
527
  common.debug(` ${parsed.packageVersion} is invalid, ignored`);
513
528
  continue;
@@ -571,7 +586,10 @@ async function checkNpmDependencyUpdateSuggestions(context) {
571
586
 
572
587
  const issueCode = updateRule.level === 'W' ? 'W0083' : 'S0082';
573
588
  const ageThreshold = Math.floor(packageAgeDays / 50) * 50;
574
- const ageInfo = ageThreshold >= 50 ? ` The newer version has been published for more than ${ageThreshold} days.` : '';
589
+ const ageInfo =
590
+ ageThreshold >= 50
591
+ ? ` The newer version has been published for more than ${ageThreshold} days.`
592
+ : '';
575
593
  context.warnings.push(
576
594
  `[${issueCode}] A newer version (${latestVersion}) for package "${packageName}" (${sourceType}) exists.${ageInfo} Please evaluate if upgrading from ${packageVersion} to ${latestVersion} is possible.`,
577
595
  );
@@ -905,6 +923,22 @@ async function checkPackageJson(context) {
905
923
  } else {
906
924
  context.checks.push('"lint" script found in package.json');
907
925
  }
926
+ if (context.packageJson.scripts && typeof context.packageJson.scripts === 'object') {
927
+ if (Object.prototype.hasOwnProperty.call(context.packageJson.scripts, 'preinstall')) {
928
+ context.warnings.push(
929
+ '[W0092] "preinstall" script found in package.json. Usage of npm install lifecycle scripts should be avoided.',
930
+ );
931
+ }
932
+
933
+ const forbiddenInstallScripts = ['install', 'postinstall'].filter(scriptName =>
934
+ Object.prototype.hasOwnProperty.call(context.packageJson.scripts, scriptName),
935
+ );
936
+ if (forbiddenInstallScripts.length) {
937
+ context.errors.push(
938
+ `[E0093] Script(s) ${forbiddenInstallScripts.map(scriptName => `"${scriptName}"`).join(', ')} found in package.json. Remove npm install lifecycle scripts.`,
939
+ );
940
+ }
941
+ }
908
942
 
909
943
  if (context.packageJson.maintainers) {
910
944
  context.warnings.push(
@@ -1457,7 +1491,7 @@ async function checkPackageJson(context) {
1457
1491
  const tsConfigNodeDevDependencyMajor = parseInt(tsConfigNodeDevDependencyMatch.groups.major, 10);
1458
1492
  if (tsConfigNodeDevDependencyMajor !== minMajor) {
1459
1493
  shouldAdjustTsConfig = true;
1460
- tsConfigNodeDevDependencyNameNew = `@tsconfig/node${minMajor}`
1494
+ tsConfigNodeDevDependencyNameNew = `@tsconfig/node${minMajor}`;
1461
1495
  context.warnings.push(
1462
1496
  `[W0086] "${tsConfigNodeDevDependencyName}" should match the major node.js version from package.json engines.node (>=${minMajor}). Please update to ${tsConfigNodeDevDependencyNameNew} at package.json.`,
1463
1497
  );
@@ -2089,3 +2123,5 @@ exports.validateReleaseFormat = validateReleaseFormat;
2089
2123
  // [W0089] "/tsconfig.json" extends "${extendsPath}" but package.json uses "${tsConfigNodeDevDependencyName}". Please update/downgrade the devDependency to match the extends package.
2090
2124
  // [W0090] "/tsconfig.json" should be adjusted to match "${tsConfigNodeDevDependencyName}" (for example: "extends": "${tsConfigNodeDevDependencyName}/tsconfig.json").
2091
2125
  // [E0091] Could not read "/tsconfig.json": ${e.message || e}
2126
+ // [W0092] "preinstall" script found in package.json. Usage of npm install lifecycle scripts should be avoided.
2127
+ // [E0093] Script(s) ${forbiddenInstallScripts.map(scriptName => `"${scriptName}"`).join(', ')} found in package.json. Remove npm install lifecycle scripts except "preinstall".
@@ -37,6 +37,7 @@ const recommendedAdminVersion = '7.6.20';
37
37
  let requiredAdminVersion = '7.6.17'; // set to 6.17.14 if jsonConfig is used
38
38
  const adaptersAllowedToUseNondeletable = [];
39
39
  const generallyAllowedNotificationScopes = [];
40
+ const excludedNewsTranslationLanguages = new Set(['zh-cn']);
40
41
 
41
42
  const blacklistIOPackageJson = {
42
43
  $schema: {
@@ -346,6 +347,37 @@ function checkNotificationScopes(notifications, adapterName, allowedScopes) {
346
347
  return { missingScopeNotifications, unsupportedScopeNotifications };
347
348
  }
348
349
 
350
+ /**
351
+ * Collect news entries where non-English language text equals the English text.
352
+ *
353
+ * @param {Record<string, Record<string, string>>} news common.news object from io-package.json
354
+ * @returns {Record<string, string[]>} Object with language keys and affected version arrays
355
+ */
356
+ function getUntranslatedNewsByLanguage(news) {
357
+ const untranslatedNewsByLanguage = {};
358
+ Object.keys(news).forEach(version => {
359
+ const newsEntry = news[version];
360
+ if (!newsEntry || typeof newsEntry !== 'object' || Array.isArray(newsEntry)) {
361
+ return;
362
+ }
363
+ const englishText = newsEntry.en;
364
+ if (typeof englishText !== 'string') {
365
+ return;
366
+ }
367
+ Object.entries(newsEntry).forEach(([language, translation]) => {
368
+ if (language === 'en' || excludedNewsTranslationLanguages.has(language)) {
369
+ return;
370
+ }
371
+ if (typeof translation === 'string' && translation === englishText) {
372
+ const versions = untranslatedNewsByLanguage[language] || [];
373
+ versions.push(version);
374
+ untranslatedNewsByLanguage[language] = versions;
375
+ }
376
+ });
377
+ });
378
+ return untranslatedNewsByLanguage;
379
+ }
380
+
349
381
  async function checkIOPackageJson(context) {
350
382
  console.log('\n[E1000 - E1999] checking io-package.json');
351
383
 
@@ -952,6 +984,17 @@ async function checkIOPackageJson(context) {
952
984
  );
953
985
  }
954
986
 
987
+ const untranslatedNewsByLanguage = getUntranslatedNewsByLanguage(context.ioPackageJson.common.news);
988
+ const untranslatedLanguages = Object.keys(untranslatedNewsByLanguage).sort();
989
+ if (untranslatedLanguages.length) {
990
+ const untranslatedDetails = untranslatedLanguages
991
+ .map(language => `${language}(${untranslatedNewsByLanguage[language].sort().join(', ')})`)
992
+ .join('; ');
993
+ context.errors.push(
994
+ `[E1144] Untranslated "common.news" entries detected (identical to English text): ${untranslatedDetails}.`,
995
+ );
996
+ }
997
+
955
998
  missingLang = [];
956
999
  Object.keys(context.ioPackageJson.common.news).forEach(version => {
957
1000
  missingLang = missingLang.concat(
@@ -1850,3 +1893,4 @@ exports.checkIOPackageJson = checkIOPackageJson;
1850
1893
  // [W1141] io-package.json: instanceObject common.icon must be a string
1851
1894
  // [W1142] "notifications[${notification.index}].scope" has unsupported value "${notification.scope}" in io-package.json.
1852
1895
  // [E1143] package.json "main" points to a TypeScript file. Please set "common.compact": false in io-package.json.
1896
+ // [E1144] Untranslated "common.news" entries detected (identical to English text): ${language(version1, version2)}; ...
package/lib/M5000_Code.js CHANGED
@@ -1021,9 +1021,9 @@ async function checkCode(context) {
1021
1021
  }
1022
1022
  });
1023
1023
  } else if (i18nAttr === false) {
1024
- context.warnings.push(`[W5015] Why did you decide to disable i18n support?`);
1024
+ context.warnings.push(`[W5015] Why did you decide to disable i18n support at jsonConfig.json(5)?`);
1025
1025
  } else {
1026
- context.warnings.push(`[W5022] Why did you decide not to use i18n support?`);
1026
+ context.warnings.push(`[S5022] Consider adding explicit i18n attribute to jsonConfig.json(5)`);
1027
1027
  }
1028
1028
 
1029
1029
  M5500__jsonConfig.checkJsonConfig(
@@ -33,6 +33,8 @@ const TRANSLATABLE_ATTRS = [
33
33
  'validatorErrorText',
34
34
  ];
35
35
  const MAX_W5612_WARNINGS = 10;
36
+ const MAX_W5606_EXAMPLES = 2;
37
+ const MIN_WORDS_FOR_W5606 = 3;
36
38
  const MAX_56XX_ISSUES_PER_CODE = 10;
37
39
  const ISSUE_CODE_56XX_REGEX = /^\[((?:E|W|S)56\d{2})\]/;
38
40
 
@@ -97,6 +99,48 @@ function escapeRegex(str) {
97
99
  return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
98
100
  }
99
101
 
102
+ /**
103
+ * Count words in a text (words are whitespace-separated tokens).
104
+ *
105
+ * @param {string} text - Text to evaluate.
106
+ * @returns {number} - Number of words in the text.
107
+ */
108
+ function countWords(text) {
109
+ const trimmed = text.trim();
110
+ return trimmed ? trimmed.split(/\s+/).length : 0;
111
+ }
112
+
113
+ /**
114
+ * Normalize language code to a 2-character representation for compact reporting.
115
+ *
116
+ * @param {string} lang - Language code (e.g. "de", "zh-cn").
117
+ * @returns {string} - Two character language code.
118
+ */
119
+ function toTwoCharLanguageCode(lang) {
120
+ const normalized = typeof lang === 'string' ? lang.trim().toLowerCase() : '';
121
+ if (!normalized) {
122
+ return '??';
123
+ }
124
+ return normalized.slice(0, 2).padEnd(2, '?');
125
+ }
126
+
127
+ /**
128
+ * Format one W5606 language summary entry.
129
+ *
130
+ * @param {{lang: string, count: number, examples: string[]}} entry - Aggregated language data.
131
+ * @returns {string} - Human-readable language summary.
132
+ */
133
+ function formatW5606LanguageEntry(entry) {
134
+ const details = [`${entry.count} ${entry.count === 1 ? 'key' : 'keys'}`];
135
+ if (entry.examples.length === 1) {
136
+ details.push(`example: ${entry.examples[0]}`);
137
+ } else if (entry.examples.length > 1) {
138
+ details.push(`examples: ${entry.examples.join(', ')}`);
139
+ }
140
+
141
+ return `${entry.lang} (${details.join(', ')})`;
142
+ }
143
+
100
144
  /**
101
145
  * Discover all i18n directory paths from the repository file list.
102
146
  * Recognises both long format ({lang}/translations.json) and short format ({lang}.json).
@@ -282,6 +326,7 @@ function checkI18nDirectory(context, i18nDir) {
282
326
  }
283
327
 
284
328
  const enKeys = new Set(Object.keys(enTranslations));
329
+ const untranslatedSummary = [];
285
330
 
286
331
  for (const [lang, langTranslations] of translations) {
287
332
  if (lang === 'en') {
@@ -306,21 +351,32 @@ function checkI18nDirectory(context, i18nDir) {
306
351
  );
307
352
  }
308
353
 
309
- // W5606: Too many identical translations (>5 non-trivial identical strings)
354
+ // W5606: Language has untranslated entries identical to English (>=3 words)
310
355
  const identical = [...enKeys].filter(
311
356
  k =>
312
357
  langKeys.has(k) &&
313
358
  typeof enTranslations[k] === 'string' &&
314
359
  typeof langTranslations[k] === 'string' &&
315
- enTranslations[k].length > 1 &&
360
+ countWords(enTranslations[k]) >= MIN_WORDS_FOR_W5606 &&
316
361
  enTranslations[k] === langTranslations[k],
317
362
  );
318
- if (identical.length > [...enKeys].length * 0.75) {
319
- context.warnings.push(
320
- `[W5606] i18n "${displayDir}" language "${lang}" has ${identical.length} translation(s) identical to English (i.e. ${identical[0]}). This may indicate untranslated content.`,
321
- );
363
+
364
+ if (identical.length > 0) {
365
+ untranslatedSummary.push({
366
+ lang: toTwoCharLanguageCode(lang),
367
+ count: identical.length,
368
+ examples: identical.slice(0, MAX_W5606_EXAMPLES),
369
+ });
322
370
  }
323
371
  }
372
+
373
+ if (untranslatedSummary.length > 0) {
374
+ context.warnings.push(
375
+ `[W5606] i18n "${displayDir}" seems to contain untranslated entries identical to English (>=${
376
+ MIN_WORDS_FOR_W5606
377
+ } words). Affected languages: ${untranslatedSummary.map(formatW5606LanguageEntry).join('; ')}.`,
378
+ );
379
+ }
324
380
  }
325
381
 
326
382
  /**
@@ -599,7 +655,7 @@ exports.getI18nFilesToRead = getI18nFilesToRead;
599
655
  // [W5603] i18n directory is missing a non-required language
600
656
  // [W5604] English translation key not present in another language (missing translation)
601
657
  // [W5605] Translation key in non-English file not present in English (outdated translation)
602
- // [W5606] More than 5 translations are identical between English and another language
658
+ // [W5606] Non-English translations identical to English (>=3 words), grouped by affected language
603
659
  // [E5610] jsonConfig translatable attribute i18n object missing a required language
604
660
  // [W5611] jsonConfig translatable attribute i18n object missing a non-required language
605
661
  // [W5612] jsonConfig translatable attribute string key not found in English translation file
@@ -238,6 +238,29 @@ function stripMarkdownForLanguageDetection(text) {
238
238
  return text;
239
239
  }
240
240
 
241
+ /**
242
+ * Strip markdown inline formatting for install-instruction text scanning.
243
+ * Removes fenced/inline code blocks, expands links to "text URL" so that URL
244
+ * checks still work, and removes bold/italic emphasis markers so that formatted
245
+ * text like `install from **[GitHub](url)**` is still detected.
246
+ *
247
+ * @param {string} text - Raw markdown text
248
+ * @returns {string} Text with inline formatting stripped
249
+ */
250
+ function stripMarkdownInlineFormatting(text) {
251
+ // Remove fenced code blocks (``` ... ```)
252
+ text = text.replace(/```[\s\S]*?```/g, '');
253
+ // Remove inline code (`...`)
254
+ text = text.replace(/`[^`\n]*`/g, '');
255
+ // Expand links [text](url) -> "text url" (preserve both visible text and URL for checks)
256
+ text = text.replace(/\[([^\]]*)\]\(([^)]*)\)/g, '$1 $2');
257
+ // Remove bold+italic (***) and bold (**) markers
258
+ text = text.replace(/\*{2,3}/g, '');
259
+ // Remove bold+italic (___) and bold (__) markers
260
+ text = text.replace(/_{2,3}/g, '');
261
+ return text;
262
+ }
263
+
241
264
  /**
242
265
  * Check if text is written in English by counting distinct common English words found.
243
266
  *
@@ -390,7 +413,8 @@ async function checkReadme(context) {
390
413
  if (
391
414
  !header.includes('WORK IN PROGRESS') &&
392
415
  !header.includes('CHANGELOG_OLD.md') &&
393
- !header.includes('Older versions')
416
+ !header.toLowerCase().includes('older versions') &&
417
+ !header.toLowerCase().includes('older changelog')
394
418
  ) {
395
419
  invalidVersionHeaders.push(header);
396
420
  }
@@ -595,10 +619,14 @@ async function checkReadme(context) {
595
619
  }
596
620
  }
597
621
 
622
+ // Strip markdown inline formatting so that bold/italic-wrapped install instructions
623
+ // (e.g. `install from **[GitHub](url)**`) are still detected by the checks below.
624
+ const dataForInstallCheck = stripMarkdownInlineFormatting(data);
625
+
598
626
  // Check for direct npm install instructions
599
627
  const npmInstallRegex = /(?:^|\n)[^\n]*(?:npm\s+install|npm\s+i)\s+iobroker\.[^\s\n]*/i;
600
628
  const cdIoBrokerRegex = /(?:^|\n)[^\n]*cd\s+\/opt\/iobroker/i;
601
- if (npmInstallRegex.test(data) || cdIoBrokerRegex.test(data)) {
629
+ if (npmInstallRegex.test(dataForInstallCheck) || cdIoBrokerRegex.test(dataForInstallCheck)) {
602
630
  context.errors.push(
603
631
  '[E6012] README.md suggests to install using direct npm commands. Adapters must not be installed using direct npm commands. Please remove these instructions.',
604
632
  );
@@ -616,21 +644,25 @@ async function checkReadme(context) {
616
644
  new RegExp(
617
645
  `(?:^|\\n)[^\\n]*(?:iobroker|iob)\\s+url\\s+(?:https?:\\/\\/github\\.com\\/)?${ownerAdapterPattern}`,
618
646
  'i',
619
- ).test(data) ||
647
+ ).test(dataForInstallCheck) ||
620
648
  // Install from custom URL
621
- new RegExp(`install\\s+from\\s+custom\\s+url`, 'i').test(data) ||
649
+ new RegExp(`install\\s+from\\s+custom\\s+url`, 'i').test(dataForInstallCheck) ||
622
650
  // Installation via Github Cat possible.
623
- new RegExp(`installation\\s+via\\s+github`, 'i').test(data) ||
651
+ new RegExp(`installation\\s+via\\s+github`, 'i').test(dataForInstallCheck) ||
624
652
  // iobroker/iob npm install commands with owner/repo GitHub shorthand
625
653
  new RegExp(`(?:^|\\n)[^\\n]*(?:iobroker|iob)\\s+npm\\s+install\\s+${ownerAdapterPattern}`, 'i').test(
626
- data,
654
+ dataForInstallCheck,
627
655
  ) ||
628
656
  // npm install/i with owner/repo GitHub shorthand
629
- new RegExp(`(?:^|\\n)[^\\n]*npm\\s+(?:install|i)\\s+${ownerAdapterPattern}`, 'i').test(data) ||
657
+ new RegExp(`(?:^|\\n)[^\\n]*npm\\s+(?:install|i)\\s+${ownerAdapterPattern}`, 'i').test(
658
+ dataForInstallCheck,
659
+ ) ||
630
660
  // Generic iobroker url https://github.com (fallback for any GitHub URL)
631
- /(?:^|\n)[^\n]*iobroker\s+url\s+https:\/\/github\.com\//i.test(data) ||
632
- /install\s+the\s+adapter\s+via\s+iobroker\s+admin\s+as\s+a\s+zip\s+file/i.test(data) ||
633
- /install\s+from\s+own\s+url/i.test(data)
661
+ /(?:^|\n)[^\n]*iobroker\s+url\s+https:\/\/github\.com\//i.test(dataForInstallCheck) ||
662
+ /install\s+the\s+adapter\s+via\s+iobroker\s+admin\s+as\s+a\s+zip\s+file/i.test(dataForInstallCheck) ||
663
+ /install\s+from\s+own\s+url/i.test(dataForInstallCheck) ||
664
+ // Install from a GitHub URL (e.g. `install from **[GitHub](https://github.com/...)**`)
665
+ /install\s+from\s+(?:[^\n]*\s)?https?:\/\/github\.com\//i.test(dataForInstallCheck)
634
666
  ) {
635
667
  context.errors.push(
636
668
  '[E6013] README.md suggests to install the adapter directly from GitHub, directly from npm or using npm commands. Installation from GitHub is discouraged. Please remove these instructions.',
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
- "version": "5.18.10",
2
+ "version": "5.19.0",
3
3
  "name": "@iobroker/repochecker",
4
4
  "dependencies": {
5
5
  "ajv": "^8.20.0",
6
- "axios": "^1.15.2",
6
+ "axios": "^1.16.0",
7
7
  "compare-versions": "^6.1.1",
8
8
  "image-size": "^1.2.0",
9
9
  "js-yaml": "^4.1.1",