@iobroker/repochecker 5.18.11 → 5.19.1

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,16 @@ Example:
25
25
  Placeholder for the next version (at the beginning of the line):
26
26
  ### **WORK IN PROGRESS**
27
27
  -->
28
+ ### 5.19.1 (2026-06-28)
29
+
30
+ - (mcm1957) checking of untranslated i18n keys has been adapted
31
+
32
+ ### 5.19.0 (2026-06-27)
33
+
34
+ - (mcm1957) github install detection has been enhanced
35
+ - (mcm1957) checking of untranslated i18n keys has been enhanced
36
+ - (mcm1957) disallow npm installation scripts
37
+
28
38
  ### 5.18.11 (2026-06-24)
29
39
 
30
40
  - (mcm1957) blacklisting for dependency versionchecking checking added
@@ -499,6 +499,13 @@ function getNpmUpdateRule(context, packageName) {
499
499
  async function checkNpmDependencyUpdateSuggestions(context) {
500
500
  const blackListedDependencies = [
501
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',
502
509
  ];
503
510
  common.debug(`executing checkNpmDependencyUpdateSuggestions`);
504
511
  const dependencySources = [
@@ -511,7 +518,7 @@ async function checkNpmDependencyUpdateSuggestions(context) {
511
518
  for (const [declaredName, declaredVersion] of Object.entries(sourceDeps)) {
512
519
  const parsed = parseDependencyDeclaration(declaredName, declaredVersion);
513
520
  common.debug(` result: {${parsed.packageName}, ${parsed.packageVersion}}`);
514
- if (blackListedDependencies.includes(parsed.packageName)){
521
+ if (blackListedDependencies.includes(parsed.packageName)) {
515
522
  common.debug(` ${parsed.packageName} is blacklisted, ignored`);
516
523
  continue;
517
524
  }
@@ -916,6 +923,22 @@ async function checkPackageJson(context) {
916
923
  } else {
917
924
  context.checks.push('"lint" script found in package.json');
918
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
+ }
919
942
 
920
943
  if (context.packageJson.maintainers) {
921
944
  context.warnings.push(
@@ -1468,7 +1491,7 @@ async function checkPackageJson(context) {
1468
1491
  const tsConfigNodeDevDependencyMajor = parseInt(tsConfigNodeDevDependencyMatch.groups.major, 10);
1469
1492
  if (tsConfigNodeDevDependencyMajor !== minMajor) {
1470
1493
  shouldAdjustTsConfig = true;
1471
- tsConfigNodeDevDependencyNameNew = `@tsconfig/node${minMajor}`
1494
+ tsConfigNodeDevDependencyNameNew = `@tsconfig/node${minMajor}`;
1472
1495
  context.warnings.push(
1473
1496
  `[W0086] "${tsConfigNodeDevDependencyName}" should match the major node.js version from package.json engines.node (>=${minMajor}). Please update to ${tsConfigNodeDevDependencyNameNew} at package.json.`,
1474
1497
  );
@@ -2100,3 +2123,5 @@ exports.validateReleaseFormat = validateReleaseFormat;
2100
2123
  // [W0089] "/tsconfig.json" extends "${extendsPath}" but package.json uses "${tsConfigNodeDevDependencyName}". Please update/downgrade the devDependency to match the extends package.
2101
2124
  // [W0090] "/tsconfig.json" should be adjusted to match "${tsConfigNodeDevDependencyName}" (for example: "extends": "${tsConfigNodeDevDependencyName}/tsconfig.json").
2102
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)}; ...
@@ -163,6 +163,20 @@ function jobHasStepWithActionInputValue(job, actionPrefix, inputName, expectedVa
163
163
  });
164
164
  }
165
165
 
166
+ function isExplicitlyTrue(value) {
167
+ if (value === true) {
168
+ return true;
169
+ }
170
+ if (typeof value !== 'string') {
171
+ return false;
172
+ }
173
+ return ['true', 'yes', 'on', 'y'].includes(value.trim().toLowerCase());
174
+ }
175
+
176
+ function stepUsesActionPrefix(step, actionPrefix) {
177
+ return typeof step?.uses === 'string' && step.uses.toLowerCase().startsWith(actionPrefix.toLowerCase());
178
+ }
179
+
166
180
  /**
167
181
  * Parses the major version from an action ref string.
168
182
  * Supports values like "v1", "1", "v2.3.4". Returns null for non-numeric refs like branch names.
@@ -751,6 +765,34 @@ async function checkTests(context) {
751
765
  common.debug('testing jobs');
752
766
  const jobs = workflow.jobs || {};
753
767
 
768
+ // W3046 / E3047: "continue-on-error: true" should not be used in test-and-release workflow steps
769
+ const protectedActionPrefixes = [
770
+ 'ioBroker/testing-action-check@',
771
+ 'ioBroker/testing-action-adapter@',
772
+ 'ioBroker/testing-action-deploy@',
773
+ ];
774
+ for (const [jobName, job] of Object.entries(jobs)) {
775
+ if (!Array.isArray(job.steps)) {
776
+ continue;
777
+ }
778
+ for (let i = 0; i < job.steps.length; i++) {
779
+ const step = job.steps[i];
780
+ if (!isExplicitlyTrue(step?.['continue-on-error'])) {
781
+ continue;
782
+ }
783
+
784
+ const stepLabel = typeof step?.name === 'string' && step.name.trim() ? step.name.trim() : `#${i + 1}`;
785
+ const message =
786
+ `Workflow "${WORKFLOW_FILE_SHORT}": job "${jobName}" step "${stepLabel}" uses "continue-on-error: true". ` +
787
+ 'Workflow test-and-release should abort if any error occurs; remove "continue-on-error".';
788
+ if (protectedActionPrefixes.some(prefix => stepUsesActionPrefix(step, prefix))) {
789
+ context.errors.push(`[E3047] ${message}`);
790
+ } else {
791
+ context.warnings.push(`[W3046] ${message}`);
792
+ }
793
+ }
794
+ }
795
+
754
796
  // Compute effective minimum and recommended node.js versions per non-matrix job.
755
797
  // If the engines:node clause in package.json is higher than the config defaults, use that value.
756
798
  const testingCfg = config.testingNodeJs;
@@ -1180,3 +1222,5 @@ exports.checkTests = checkTests;
1180
1222
  // [S3043] Workflow "${WORKFLOW_FILE_SHORT}": job "adapter-tests" uses "ioBroker/testing-action-adapter@${ref}" with a pinned version. Consider locking only the major version.
1181
1223
  // [S3044] Workflow "${WORKFLOW_FILE_SHORT}": job "deploy" uses "ioBroker/testing-action-deploy@${ref}" with a pinned version. Consider locking only the major version.
1182
1224
  // [S3045] Workflow "${WORKFLOW_FILE_SHORT}": job "check-and-lint" should enable linting by setting "lint: true".
1225
+ // [W3046] Workflow "${WORKFLOW_FILE_SHORT}": job "${jobName}" step "${stepLabel}" uses "continue-on-error: true". Workflow test-and-release should abort if any error occurs; remove "continue-on-error".
1226
+ // [E3047] Workflow "${WORKFLOW_FILE_SHORT}": job "${jobName}" step "${stepLabel}" uses "continue-on-error: true". Workflow test-and-release should abort if any error occurs; remove "continue-on-error".
@@ -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 = 5;
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,62 @@ function escapeRegex(str) {
97
99
  return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
98
100
  }
99
101
 
102
+ /**
103
+ * Count actual alphabetic words in a text.
104
+ * Only sequences of alphabetic characters (including accented Latin letters) are counted,
105
+ * so punctuation, brackets, and JSON-like syntax are ignored.
106
+ * This function is intentionally applied to English text only, so Latin Unicode
107
+ * coverage is sufficient.
108
+ *
109
+ * @param {string} text - Text to evaluate.
110
+ * @returns {number} - Number of alphabetic words in the text.
111
+ */
112
+ function countWords(text) {
113
+ const words = text.match(/[a-zA-Z\u00C0-\u024F]+/g);
114
+ return words ? words.length : 0;
115
+ }
116
+
117
+ /**
118
+ * Return true if the text contains a URL (http/https scheme or www. prefix).
119
+ *
120
+ * @param {string} text - Text to evaluate.
121
+ * @returns {boolean} - Whether a URL was found.
122
+ */
123
+ function containsUrl(text) {
124
+ return /https?:\/\/|www\./.test(text);
125
+ }
126
+
127
+ /**
128
+ * Normalize language code to a 2-character representation for compact reporting.
129
+ *
130
+ * @param {string} lang - Language code (e.g. "de", "zh-cn").
131
+ * @returns {string} - Two character language code.
132
+ */
133
+ function toTwoCharLanguageCode(lang) {
134
+ const normalized = typeof lang === 'string' ? lang.trim().toLowerCase() : '';
135
+ if (!normalized) {
136
+ return '??';
137
+ }
138
+ return normalized.slice(0, 2).padEnd(2, '?');
139
+ }
140
+
141
+ /**
142
+ * Format one W5606 language summary entry.
143
+ *
144
+ * @param {{lang: string, count: number, examples: string[]}} entry - Aggregated language data.
145
+ * @returns {string} - Human-readable language summary.
146
+ */
147
+ function formatW5606LanguageEntry(entry) {
148
+ const details = [`${entry.count} ${entry.count === 1 ? 'key' : 'keys'}`];
149
+ if (entry.examples.length === 1) {
150
+ details.push(`example: ${entry.examples[0]}`);
151
+ } else if (entry.examples.length > 1) {
152
+ details.push(`examples: ${entry.examples.join(', ')}`);
153
+ }
154
+
155
+ return `${entry.lang} (${details.join(', ')})`;
156
+ }
157
+
100
158
  /**
101
159
  * Discover all i18n directory paths from the repository file list.
102
160
  * Recognises both long format ({lang}/translations.json) and short format ({lang}.json).
@@ -282,6 +340,7 @@ function checkI18nDirectory(context, i18nDir) {
282
340
  }
283
341
 
284
342
  const enKeys = new Set(Object.keys(enTranslations));
343
+ const untranslatedSummary = [];
285
344
 
286
345
  for (const [lang, langTranslations] of translations) {
287
346
  if (lang === 'en') {
@@ -306,21 +365,33 @@ function checkI18nDirectory(context, i18nDir) {
306
365
  );
307
366
  }
308
367
 
309
- // W5606: Too many identical translations (>5 non-trivial identical strings)
368
+ // W5606: Language has untranslated entries identical to English (>3 words)
310
369
  const identical = [...enKeys].filter(
311
370
  k =>
312
371
  langKeys.has(k) &&
313
372
  typeof enTranslations[k] === 'string' &&
314
373
  typeof langTranslations[k] === 'string' &&
315
- enTranslations[k].length > 1 &&
374
+ !containsUrl(enTranslations[k]) &&
375
+ countWords(enTranslations[k]) > MIN_WORDS_FOR_W5606 &&
316
376
  enTranslations[k] === langTranslations[k],
317
377
  );
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
- );
378
+
379
+ if (identical.length > 0) {
380
+ untranslatedSummary.push({
381
+ lang: toTwoCharLanguageCode(lang),
382
+ count: identical.length,
383
+ examples: identical.slice(0, MAX_W5606_EXAMPLES),
384
+ });
322
385
  }
323
386
  }
387
+
388
+ if (untranslatedSummary.length > 0) {
389
+ context.warnings.push(
390
+ `[W5606] i18n "${displayDir}" seems to contain untranslated entries identical to English (>${
391
+ MIN_WORDS_FOR_W5606
392
+ } words). Affected languages: ${untranslatedSummary.map(formatW5606LanguageEntry).join('; ')}.`,
393
+ );
394
+ }
324
395
  }
325
396
 
326
397
  /**
@@ -599,7 +670,7 @@ exports.getI18nFilesToRead = getI18nFilesToRead;
599
670
  // [W5603] i18n directory is missing a non-required language
600
671
  // [W5604] English translation key not present in another language (missing translation)
601
672
  // [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
673
+ // [W5606] Non-English translations identical to English (>3 words, no URL), grouped by affected language
603
674
  // [E5610] jsonConfig translatable attribute i18n object missing a required language
604
675
  // [W5611] jsonConfig translatable attribute i18n object missing a non-required language
605
676
  // [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
  *
@@ -596,10 +619,14 @@ async function checkReadme(context) {
596
619
  }
597
620
  }
598
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
+
599
626
  // Check for direct npm install instructions
600
627
  const npmInstallRegex = /(?:^|\n)[^\n]*(?:npm\s+install|npm\s+i)\s+iobroker\.[^\s\n]*/i;
601
628
  const cdIoBrokerRegex = /(?:^|\n)[^\n]*cd\s+\/opt\/iobroker/i;
602
- if (npmInstallRegex.test(data) || cdIoBrokerRegex.test(data)) {
629
+ if (npmInstallRegex.test(dataForInstallCheck) || cdIoBrokerRegex.test(dataForInstallCheck)) {
603
630
  context.errors.push(
604
631
  '[E6012] README.md suggests to install using direct npm commands. Adapters must not be installed using direct npm commands. Please remove these instructions.',
605
632
  );
@@ -617,21 +644,25 @@ async function checkReadme(context) {
617
644
  new RegExp(
618
645
  `(?:^|\\n)[^\\n]*(?:iobroker|iob)\\s+url\\s+(?:https?:\\/\\/github\\.com\\/)?${ownerAdapterPattern}`,
619
646
  'i',
620
- ).test(data) ||
647
+ ).test(dataForInstallCheck) ||
621
648
  // Install from custom URL
622
- 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) ||
623
650
  // Installation via Github Cat possible.
624
- new RegExp(`installation\\s+via\\s+github`, 'i').test(data) ||
651
+ new RegExp(`installation\\s+via\\s+github`, 'i').test(dataForInstallCheck) ||
625
652
  // iobroker/iob npm install commands with owner/repo GitHub shorthand
626
653
  new RegExp(`(?:^|\\n)[^\\n]*(?:iobroker|iob)\\s+npm\\s+install\\s+${ownerAdapterPattern}`, 'i').test(
627
- data,
654
+ dataForInstallCheck,
628
655
  ) ||
629
656
  // npm install/i with owner/repo GitHub shorthand
630
- 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
+ ) ||
631
660
  // Generic iobroker url https://github.com (fallback for any GitHub URL)
632
- /(?:^|\n)[^\n]*iobroker\s+url\s+https:\/\/github\.com\//i.test(data) ||
633
- /install\s+the\s+adapter\s+via\s+iobroker\s+admin\s+as\s+a\s+zip\s+file/i.test(data) ||
634
- /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)
635
666
  ) {
636
667
  context.errors.push(
637
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,15 +1,15 @@
1
1
  {
2
- "version": "5.18.11",
2
+ "version": "5.19.1",
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",
10
10
  "json5": "^2.2.3",
11
11
  "minimatch": "^10.0.0",
12
- "semver": "^7.7.4"
12
+ "semver": "^7.8.1"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@alcalzone/release-script": "^5.2.0",