@iobroker/repochecker 5.18.11 → 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 +6 -0
- package/lib/M0000_PackageJson.js +27 -2
- package/lib/M1000_IOPackageJson.js +44 -0
- package/lib/M5600__I18n.js +63 -7
- package/lib/M6000_Readme.js +40 -9
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -25,6 +25,12 @@ 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
|
+
|
|
28
34
|
### 5.18.11 (2026-06-24)
|
|
29
35
|
|
|
30
36
|
- (mcm1957) blacklisting for dependency versionchecking checking added
|
package/lib/M0000_PackageJson.js
CHANGED
|
@@ -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)}; ...
|
package/lib/M5600__I18n.js
CHANGED
|
@@ -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:
|
|
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]
|
|
360
|
+
countWords(enTranslations[k]) >= MIN_WORDS_FOR_W5606 &&
|
|
316
361
|
enTranslations[k] === langTranslations[k],
|
|
317
362
|
);
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
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]
|
|
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
|
package/lib/M6000_Readme.js
CHANGED
|
@@ -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(
|
|
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(
|
|
647
|
+
).test(dataForInstallCheck) ||
|
|
621
648
|
// Install from custom URL
|
|
622
|
-
new RegExp(`install\\s+from\\s+custom\\s+url`, 'i').test(
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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(
|
|
633
|
-
/install\s+the\s+adapter\s+via\s+iobroker\s+admin\s+as\s+a\s+zip\s+file/i.test(
|
|
634
|
-
/install\s+from\s+own\s+url/i.test(
|
|
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