@iobroker/repochecker 5.20.14 → 5.21.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 +45 -0
- package/index.js +87 -3
- package/lib/M0000_PackageJson.js +15 -8
- package/lib/M1000_IOPackageJson.js +82 -3
- package/lib/M2000_Npm.js +4 -13
- package/lib/M3000_Testing.js +29 -6
- package/lib/M4000_Repository.js +7 -14
- package/lib/M5000_Code.js +73 -111
- package/lib/M8000_Github.js +9 -14
- package/lib/M9000_GitNpmIgnore.js +22 -10
- package/lib/common.js +129 -44
- package/lib/config.js +57 -2
- package/lib/postprocessing.js +1 -0
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -26,11 +26,55 @@ Example:
|
|
|
26
26
|
|
|
27
27
|
`npx @iobroker/repochecker https://github.com/ioBroker/ioBroker.repochecker --local`
|
|
28
28
|
|
|
29
|
+
## Using a GitHub token
|
|
30
|
+
|
|
31
|
+
Unauthenticated requests to the GitHub API are rate limited. To raise the limit you can provide a
|
|
32
|
+
[GitHub personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)
|
|
33
|
+
located in a file via the `--env <file>` parameter. The file must exist and use the standard environment file format
|
|
34
|
+
(e.g. `.env`). Only the `GITHUB_TOKEN` variable is read from it - all other content is ignored and the
|
|
35
|
+
file is **never** loaded into the process environment.
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
npx @iobroker/repochecker <repo> [branch] --env <file>
|
|
39
|
+
npx @iobroker/repochecker <repo> [branch] --env=<file>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Behavior:
|
|
43
|
+
|
|
44
|
+
* If the file does not exist or cannot be parsed, an error is logged and the checker exits with a non-zero status.
|
|
45
|
+
* If `GITHUB_TOKEN` is missing or empty, a warning is logged and processing continues as if `--env` had not been specified.
|
|
46
|
+
* If `GITHUB_TOKEN` does not match the expected token format, a warning is logged but the token is used anyway.
|
|
47
|
+
|
|
48
|
+
Example `.env` file:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
52
|
+
```
|
|
53
|
+
|
|
29
54
|
## Changelog
|
|
30
55
|
<!--
|
|
31
56
|
Placeholder for the next version (at the beginning of the line):
|
|
32
57
|
### **WORK IN PROGRESS**
|
|
33
58
|
-->
|
|
59
|
+
### 5.21.1 (2026-09-08)
|
|
60
|
+
|
|
61
|
+
* (mcm1957) minor fixes
|
|
62
|
+
|
|
63
|
+
### 5.21.0 (2026-09-05)
|
|
64
|
+
|
|
65
|
+
* (mcm1957) [E1144] untranslated `common.news` entries are now reported as an error only if the newest release is affected, otherwise a single warning is logged; nothing is reported if only one or two languages are identical to the English text, unless German is identical to English.
|
|
66
|
+
* (mcm1957) [W1145] a warning is now logged if more than two languages have `common.news` translations significantly shorter (more than 40%) than the English original.
|
|
67
|
+
* (mcm1957) `lib/tools.js` is no longer excluded from dependency scanning when it is imported (required) by another source file.
|
|
68
|
+
* (mcm1957) [W5042] is no longer reported for packages provided by `@iobroker/testing` (e.g. `sinon`, `chai`, `mocha`) when `@iobroker/testing` >= 5.1.1 is used.
|
|
69
|
+
* (mcm1957) React usage detection has been moved to the preprocessing stage; the result is now reported as `usesReact` in the environment info log.
|
|
70
|
+
* (mcm1957) [W0095] `publish` and `prepublish` scripts are no longer flagged for react based adapters, as they are legitimately used to build the UI.
|
|
71
|
+
* (mcm1957) New commandline option `--env <file>` added: reads a `GITHUB_TOKEN` from the specified environment file (parsed but never loaded into the environment) and uses it for GitHub authorization. An info log now states which file the environment is read from.
|
|
72
|
+
* (mcm1957) [W3059/E3060] job "adapter-tests" is now checked for the "engine-strict" parameter of "testing-action-adapter"; a warning is raised if it is used and an error if it is set to false.
|
|
73
|
+
* (mcm1957) [S5032] outdated `lib/tools` check now also covers `.mjs` and `.cjs` variants in addition to `.js`.
|
|
74
|
+
* (mcm1957) An optional 'githubToken' query parameter is now accepted and used for GitHub authorization; axios handling has been reworked to use a per-request instance.
|
|
75
|
+
* (mcm1957) Download errors now log the textual message returned by the server (e.g. 'Package size exceeded the configured limit of 50 MB.') in addition to the error code.
|
|
76
|
+
* (mcm1957) `tasks.mjs` and `tasks.cjs` are now excluded from dependency scanning like `tasks.js`.
|
|
77
|
+
|
|
34
78
|
### 5.20.14 (2026-08-30)
|
|
35
79
|
|
|
36
80
|
* (mcm1957) 'allowScripts' is now recognizedd as valid package.json attribute.
|
|
@@ -90,6 +134,7 @@ Example:
|
|
|
90
134
|
|
|
91
135
|
* (Copilot) Add a workflow check that rejects `always()` on standard test-and-release jobs and flags it for review on custom jobs.
|
|
92
136
|
* (Copilot) Warn when tracked files or directories are still covered by `.gitignore` and error if a tracked `/build` directory is ignored.
|
|
137
|
+
* (krobipd) Skip the E9007/W9008 tracked-but-gitignored check in `--local` mode, where the file list is a filesystem walk that includes gitignored build outputs and produces false positives.
|
|
93
138
|
|
|
94
139
|
### 5.19.12 (2026-07-13)
|
|
95
140
|
|
package/index.js
CHANGED
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
|_|
|
|
13
13
|
|
|
14
14
|
*/
|
|
15
|
-
const axios = require('axios');
|
|
16
|
-
|
|
17
15
|
//const issues = require('./doc/issues');
|
|
16
|
+
const fs = require('node:fs');
|
|
17
|
+
const dotenv = require('dotenv');
|
|
18
18
|
const version = require('./package.json').version;
|
|
19
19
|
|
|
20
20
|
// include submodules
|
|
@@ -74,7 +74,7 @@ function getGithubApiData(context) {
|
|
|
74
74
|
return new Promise((resolve, reject) => {
|
|
75
75
|
common.debug('getGithubApiData');
|
|
76
76
|
common.debug(`reading url '${context.githubUrlApi}'`);
|
|
77
|
-
axios
|
|
77
|
+
context.axios
|
|
78
78
|
.get(context.githubUrlApi)
|
|
79
79
|
.then(response => {
|
|
80
80
|
context.githubApiData = response.data;
|
|
@@ -125,6 +125,7 @@ function check(request, ctx, callback) {
|
|
|
125
125
|
|
|
126
126
|
let githubUrl = request.queryStringParameters.url;
|
|
127
127
|
const githubBranch = request.queryStringParameters.branch;
|
|
128
|
+
const githubToken = request.queryStringParameters.githubToken;
|
|
128
129
|
|
|
129
130
|
githubUrl = githubUrl
|
|
130
131
|
.replace('http://', 'https://')
|
|
@@ -144,6 +145,14 @@ function check(request, ctx, callback) {
|
|
|
144
145
|
context.branch = githubBranch || null;
|
|
145
146
|
context.repository = githubUrl.replace('https://github.com/', '');
|
|
146
147
|
|
|
148
|
+
const githubTokenTrimmed = typeof githubToken === 'string' ? githubToken.trim() : '';
|
|
149
|
+
if (githubTokenTrimmed) {
|
|
150
|
+
context.githubToken = githubTokenTrimmed;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// initialize the axios instance (stored at context.axios) before any request is made
|
|
154
|
+
common.initAxios(context);
|
|
155
|
+
|
|
147
156
|
getGithubApiData(context)
|
|
148
157
|
.then(context => M8000_Github.getCommitInfos(context))
|
|
149
158
|
.then(context => M0000_PackageJson.getPackageJson(context))
|
|
@@ -212,11 +221,60 @@ function check(request, ctx, callback) {
|
|
|
212
221
|
// return text;
|
|
213
222
|
// }
|
|
214
223
|
|
|
224
|
+
// Read and validate the GITHUB_TOKEN from an environment file passed via --env.
|
|
225
|
+
// The file is only parsed - it is NEVER loaded into process.env. Only the
|
|
226
|
+
// GITHUB_TOKEN variable is extracted, all other content is ignored.
|
|
227
|
+
// Returns the trimmed token string, or null if no usable token could be retrieved.
|
|
228
|
+
function getGithubTokenFromEnvFile(envFile) {
|
|
229
|
+
common.info(`environment is read from file "${envFile}"`);
|
|
230
|
+
|
|
231
|
+
// The value passed to --env must name an existing file.
|
|
232
|
+
if (!fs.existsSync(envFile) || !fs.statSync(envFile).isFile()) {
|
|
233
|
+
common.error(`--env: file "${envFile}" does not exist`);
|
|
234
|
+
process.exit(1);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Parse the file using dotenv WITHOUT loading it into the environment.
|
|
238
|
+
let parsed;
|
|
239
|
+
try {
|
|
240
|
+
const content = fs.readFileSync(envFile);
|
|
241
|
+
parsed = dotenv.parse(content);
|
|
242
|
+
} catch (e) {
|
|
243
|
+
common.error(`--env: file "${envFile}" could not be parsed as an environment file: ${e.message}`);
|
|
244
|
+
process.exit(1);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Extract only GITHUB_TOKEN, ignore everything else.
|
|
248
|
+
if (!Object.prototype.hasOwnProperty.call(parsed, 'GITHUB_TOKEN')) {
|
|
249
|
+
common.warn(`--env: GITHUB_TOKEN has not been detected in "${envFile}", continuing as if no --env had been specified`);
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const token = (parsed.GITHUB_TOKEN || '').trim();
|
|
254
|
+
if (!token) {
|
|
255
|
+
common.warn(`--env: GITHUB_TOKEN is empty, continuing as if no --env had been specified`);
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Verify the token against the known GitHub personal access token formats.
|
|
260
|
+
// Classic tokens: "ghp_" prefix, 40 characters total.
|
|
261
|
+
// Fine-grained tokens: "github_pat_" prefix, 93 characters total.
|
|
262
|
+
// See https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens
|
|
263
|
+
const isClassic = token.startsWith('ghp_') && token.length === 40;
|
|
264
|
+
const isFineGrained = token.startsWith('github_pat_') && token.length === 93;
|
|
265
|
+
if (!isClassic && !isFineGrained) {
|
|
266
|
+
common.warn(`--env: GITHUB_TOKEN does not match the expected GitHub personal access token format, continuing with this token anyway`);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return token;
|
|
270
|
+
}
|
|
271
|
+
|
|
215
272
|
if (typeof module !== 'undefined' && module.parent) {
|
|
216
273
|
exports.handler = check;
|
|
217
274
|
} else {
|
|
218
275
|
let repoUrl = null;
|
|
219
276
|
let repoBranch = null;
|
|
277
|
+
let githubToken = null;
|
|
220
278
|
|
|
221
279
|
// check options
|
|
222
280
|
if (process.argv.includes('-d')) {
|
|
@@ -251,6 +309,31 @@ if (typeof module !== 'undefined' && module.parent) {
|
|
|
251
309
|
common.setStrict(true);
|
|
252
310
|
}
|
|
253
311
|
|
|
312
|
+
// --env <file> or --env=<file>: read a GITHUB_TOKEN from an environment file (see getGithubTokenFromEnvFile)
|
|
313
|
+
const envIdx = process.argv.findIndex(arg => arg === '--env' || arg.startsWith('--env='));
|
|
314
|
+
if (envIdx !== -1) {
|
|
315
|
+
let envFile;
|
|
316
|
+
if (process.argv[envIdx].startsWith('--env=')) {
|
|
317
|
+
// --env=<file>: value is part of the same argument
|
|
318
|
+
envFile = process.argv[envIdx].slice('--env='.length);
|
|
319
|
+
process.argv.splice(envIdx, 1);
|
|
320
|
+
} else {
|
|
321
|
+
// --env <file>: value is the next argument
|
|
322
|
+
envFile = process.argv[envIdx + 1];
|
|
323
|
+
if (!envFile || envFile.startsWith('-')) {
|
|
324
|
+
common.error('--env: no file specified');
|
|
325
|
+
process.exit(1);
|
|
326
|
+
}
|
|
327
|
+
// remove both '--env' and its value from argv before positional parsing
|
|
328
|
+
process.argv.splice(envIdx, 2);
|
|
329
|
+
}
|
|
330
|
+
if (!envFile) {
|
|
331
|
+
common.error('--env: no file specified');
|
|
332
|
+
process.exit(1);
|
|
333
|
+
}
|
|
334
|
+
githubToken = getGithubTokenFromEnvFile(envFile);
|
|
335
|
+
}
|
|
336
|
+
|
|
254
337
|
// Get url from parameters if possible
|
|
255
338
|
if (process.argv.length > 2) {
|
|
256
339
|
repoUrl = process.argv[2];
|
|
@@ -274,6 +357,7 @@ if (typeof module !== 'undefined' && module.parent) {
|
|
|
274
357
|
queryStringParameters: {
|
|
275
358
|
url: repoUrl,
|
|
276
359
|
branch: repoBranch,
|
|
360
|
+
githubToken: githubToken,
|
|
277
361
|
},
|
|
278
362
|
},
|
|
279
363
|
null,
|
package/lib/M0000_PackageJson.js
CHANGED
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
|
|
11
11
|
const compareVersions = require('compare-versions');
|
|
12
12
|
const semver = require('semver');
|
|
13
|
-
const axios = require('axios');
|
|
14
13
|
|
|
15
14
|
const common = require('./common.js');
|
|
16
15
|
|
|
@@ -23,14 +22,14 @@ const specialAdapters = [
|
|
|
23
22
|
]; // no special handling required for now
|
|
24
23
|
let recommendedNodeVersion = '22'; // This is the minimum node version that should be required at engines clause
|
|
25
24
|
let requiredNodeVersion = '20'; // This is the minimum node version that must be required at engines clause
|
|
26
|
-
const minimumNodeVersion = '
|
|
25
|
+
const minimumNodeVersion = '20'; // This is the minimum node version that must be required by all adapters at engines clause
|
|
27
26
|
|
|
28
27
|
// packages which must or should be required as dependencies
|
|
29
28
|
const dependenciesPackageJson = {
|
|
30
29
|
'@iobroker/adapter-core': {
|
|
31
30
|
required: '3.2.3',
|
|
32
|
-
recommended: '3.4.
|
|
33
|
-
actual: '3.4.
|
|
31
|
+
recommended: '3.4.3',
|
|
32
|
+
actual: '3.4.3',
|
|
34
33
|
onlyWWW: false,
|
|
35
34
|
},
|
|
36
35
|
};
|
|
@@ -125,7 +124,7 @@ const devDependenciesPackageJson = {
|
|
|
125
124
|
'@iobroker/testing': {
|
|
126
125
|
required: '5.2.2',
|
|
127
126
|
recommended: '5.2.2',
|
|
128
|
-
actual: '
|
|
127
|
+
actual: '6.1.0',
|
|
129
128
|
onlyWWW: false,
|
|
130
129
|
alternatives: ['@iobroker/legacy-testing'],
|
|
131
130
|
},
|
|
@@ -281,7 +280,7 @@ const validObjectsPackageJson = [
|
|
|
281
280
|
'directories.bin',
|
|
282
281
|
'directories.man',
|
|
283
282
|
'engines',
|
|
284
|
-
|
|
283
|
+
'exports',
|
|
285
284
|
'files',
|
|
286
285
|
'funding',
|
|
287
286
|
'homepage',
|
|
@@ -564,7 +563,7 @@ async function checkNpmDependencyUpdateSuggestions(context) {
|
|
|
564
563
|
}
|
|
565
564
|
try {
|
|
566
565
|
common.debug(` fetching npm data for ${packageName}`);
|
|
567
|
-
const response = await axios(`https://registry.npmjs.org/${encodeURIComponent(packageName)}`);
|
|
566
|
+
const response = await context.axios(`https://registry.npmjs.org/${encodeURIComponent(packageName)}`);
|
|
568
567
|
const npmData = response.data;
|
|
569
568
|
const latestVersion = npmData?.['dist-tags']?.latest;
|
|
570
569
|
const latestPublishedAt = npmData?.time?.[latestVersion];
|
|
@@ -949,7 +948,12 @@ async function checkPackageJson(context) {
|
|
|
949
948
|
);
|
|
950
949
|
});
|
|
951
950
|
|
|
951
|
+
// react based adapters legitimately use 'publish' and 'prepublish' scripts to build the UI,
|
|
952
|
+
// so these two scripts must not be flagged if the adapter uses react
|
|
953
|
+
const reactAllowedScripts = context.usesReact ? ['prepublish', 'prepublishOnly'] : [];
|
|
954
|
+
|
|
952
955
|
discouragedScripts
|
|
956
|
+
.filter(scriptName => !reactAllowedScripts.includes(scriptName))
|
|
953
957
|
.filter(scriptName => Object.prototype.hasOwnProperty.call(context.packageJson.scripts, scriptName))
|
|
954
958
|
.forEach(scriptName => {
|
|
955
959
|
context.warnings.push(
|
|
@@ -1568,7 +1572,9 @@ async function checkPackageJson(context) {
|
|
|
1568
1572
|
const testingVersion = context.packageJson.devDependencies['@iobroker/testing'].replace(/[\^~]/, '').trim();
|
|
1569
1573
|
try {
|
|
1570
1574
|
if (compareVersions.compare(testingVersion, '5.1.1', '>=')) {
|
|
1571
|
-
// List of packages that are redundant when @iobroker/testing >= 5.1.1 is installed
|
|
1575
|
+
// List of packages that are redundant when @iobroker/testing >= 5.1.1 is installed.
|
|
1576
|
+
// Stored into context.redundantTestingPackages so later modules
|
|
1577
|
+
// (e.g. M5000_Code W5042) can reuse it.
|
|
1572
1578
|
const redundantPackages = [
|
|
1573
1579
|
'@types/chai',
|
|
1574
1580
|
'chai',
|
|
@@ -1583,6 +1589,7 @@ async function checkPackageJson(context) {
|
|
|
1583
1589
|
'@types/sinon-chai',
|
|
1584
1590
|
'sinon-chai',
|
|
1585
1591
|
];
|
|
1592
|
+
context.redundantTestingPackages = redundantPackages;
|
|
1586
1593
|
|
|
1587
1594
|
let pkgs = [];
|
|
1588
1595
|
for (const pkg of redundantPackages) {
|
|
@@ -378,6 +378,58 @@ function getUntranslatedNewsByLanguage(news) {
|
|
|
378
378
|
return untranslatedNewsByLanguage;
|
|
379
379
|
}
|
|
380
380
|
|
|
381
|
+
/**
|
|
382
|
+
* Determine the newest release from a common.news object using semver ordering.
|
|
383
|
+
*
|
|
384
|
+
* @param {Record<string, Record<string, string>>} news common.news object from io-package.json
|
|
385
|
+
* @returns {string | undefined} the highest version found, or undefined if none is valid
|
|
386
|
+
*/
|
|
387
|
+
function getNewestNewsVersion(news) {
|
|
388
|
+
let newestVersion;
|
|
389
|
+
Object.keys(news).forEach(version => {
|
|
390
|
+
try {
|
|
391
|
+
if (newestVersion === undefined || compareVersions.compareVersions(version, newestVersion) > 0) {
|
|
392
|
+
newestVersion = version;
|
|
393
|
+
}
|
|
394
|
+
} catch {
|
|
395
|
+
// ignore malformed version strings, they are reported by E1075
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
return newestVersion;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Collect languages whose news translations are significantly shorter than the English text.
|
|
403
|
+
* A translation counts as "too short" if it is more than 40% shorter than the English original.
|
|
404
|
+
*
|
|
405
|
+
* @param {Record<string, Record<string, string>>} news common.news object from io-package.json
|
|
406
|
+
* @returns {Record<string, string[]>} Object with language keys and affected version arrays
|
|
407
|
+
*/
|
|
408
|
+
function getShortNewsTranslationLanguages(news) {
|
|
409
|
+
const shortNewsByLanguage = {};
|
|
410
|
+
Object.keys(news).forEach(version => {
|
|
411
|
+
const newsEntry = news[version];
|
|
412
|
+
if (!newsEntry || typeof newsEntry !== 'object' || Array.isArray(newsEntry)) {
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
const englishText = newsEntry.en;
|
|
416
|
+
if (typeof englishText !== 'string' || englishText.length === 0) {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
Object.entries(newsEntry).forEach(([language, translation]) => {
|
|
420
|
+
if (language === 'en' || excludedNewsTranslationLanguages.has(language)) {
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
if (typeof translation === 'string' && translation.length < englishText.length * 0.6) {
|
|
424
|
+
const versions = shortNewsByLanguage[language] || [];
|
|
425
|
+
versions.push(version);
|
|
426
|
+
shortNewsByLanguage[language] = versions;
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
});
|
|
430
|
+
return shortNewsByLanguage;
|
|
431
|
+
}
|
|
432
|
+
|
|
381
433
|
async function checkIOPackageJson(context) {
|
|
382
434
|
console.log('\n[E1000 - E1999] checking io-package.json');
|
|
383
435
|
|
|
@@ -986,12 +1038,38 @@ async function checkIOPackageJson(context) {
|
|
|
986
1038
|
|
|
987
1039
|
const untranslatedNewsByLanguage = getUntranslatedNewsByLanguage(context.ioPackageJson.common.news);
|
|
988
1040
|
const untranslatedLanguages = Object.keys(untranslatedNewsByLanguage).sort();
|
|
989
|
-
|
|
1041
|
+
// Only report when more than two languages are identical to the English text,
|
|
1042
|
+
// but always report if German (de) is identical to English.
|
|
1043
|
+
if (untranslatedLanguages.length > 2 || untranslatedLanguages.includes('de')) {
|
|
990
1044
|
const untranslatedDetails = untranslatedLanguages
|
|
991
1045
|
.map(language => `${language}(${untranslatedNewsByLanguage[language].sort().join(', ')})`)
|
|
992
1046
|
.join('; ');
|
|
1047
|
+
const newestVersion = getNewestNewsVersion(context.ioPackageJson.common.news);
|
|
1048
|
+
const newestAffected =
|
|
1049
|
+
newestVersion !== undefined &&
|
|
1050
|
+
untranslatedLanguages.some(language => untranslatedNewsByLanguage[language].includes(newestVersion));
|
|
1051
|
+
if (newestAffected) {
|
|
1052
|
+
// The newest release is affected - this is an error.
|
|
1053
|
+
context.errors.push(
|
|
1054
|
+
`[E1144] Untranslated "common.news" entries detected (identical to English text): ${untranslatedDetails}.`,
|
|
1055
|
+
);
|
|
1056
|
+
} else {
|
|
1057
|
+
// Only older releases are affected - log a single warning.
|
|
1058
|
+
context.warnings.push(
|
|
1059
|
+
`[W1144] Untranslated "common.news" entries detected (identical to English text): ${untranslatedDetails}.`,
|
|
1060
|
+
);
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
// Warn (once) if more than two languages have news translations significantly shorter than the English text.
|
|
1065
|
+
const shortNewsByLanguage = getShortNewsTranslationLanguages(context.ioPackageJson.common.news);
|
|
1066
|
+
const shortNewsLanguages = Object.keys(shortNewsByLanguage).sort();
|
|
1067
|
+
if (shortNewsLanguages.length > 2) {
|
|
1068
|
+
const shortNewsDetails = shortNewsLanguages
|
|
1069
|
+
.map(language => `${language}(${shortNewsByLanguage[language].sort().join(', ')})`)
|
|
1070
|
+
.join('; ');
|
|
993
1071
|
context.warnings.push(
|
|
994
|
-
`[
|
|
1072
|
+
`[W1145] Some "common.news" translations are significantly shorter than the English text: ${shortNewsDetails}. Please check the translations.`,
|
|
995
1073
|
);
|
|
996
1074
|
}
|
|
997
1075
|
|
|
@@ -1893,4 +1971,5 @@ exports.checkIOPackageJson = checkIOPackageJson;
|
|
|
1893
1971
|
// [W1141] io-package.json: instanceObject common.icon must be a string
|
|
1894
1972
|
// [W1142] "notifications[${notification.index}].scope" has unsupported value "${notification.scope}" in io-package.json.
|
|
1895
1973
|
// [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)}; ...
|
|
1974
|
+
// [E1144] Untranslated "common.news" entries detected (identical to English text): ${language(version1, version2)}; ... (error if newest release affected, else W1144)
|
|
1975
|
+
// [W1145] Some "common.news" translations are significantly shorter than the English text: ${language(version1, version2)}; ... Please check the translations.
|
package/lib/M2000_Npm.js
CHANGED
|
@@ -7,26 +7,17 @@
|
|
|
7
7
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
const axios = require('axios');
|
|
11
10
|
const compareVersions = require('compare-versions');
|
|
12
11
|
|
|
13
12
|
const common = require('./common.js');
|
|
14
13
|
|
|
15
|
-
// disable axios caching
|
|
16
|
-
// @ts-expect-error - old code
|
|
17
|
-
axios.defaults.headers = {
|
|
18
|
-
'Cache-Control': 'no-cache',
|
|
19
|
-
Pragma: 'no-cache',
|
|
20
|
-
Expires: '0',
|
|
21
|
-
};
|
|
22
|
-
|
|
23
14
|
// const common = require('./common.js');
|
|
24
15
|
|
|
25
16
|
async function getNpm(context) {
|
|
26
17
|
console.log('\n[init] checking npm');
|
|
27
18
|
let body;
|
|
28
19
|
try {
|
|
29
|
-
const response = await axios(`https://registry.npmjs.org/iobroker.${context.adapterName}`);
|
|
20
|
+
const response = await context.axios(`https://registry.npmjs.org/iobroker.${context.adapterName}`);
|
|
30
21
|
body = response.data;
|
|
31
22
|
} catch (e) {
|
|
32
23
|
if (
|
|
@@ -43,7 +34,7 @@ async function getNpm(context) {
|
|
|
43
34
|
// bug in NPM some modules could be accessed via normal web page, but not by API
|
|
44
35
|
if (!body) {
|
|
45
36
|
try {
|
|
46
|
-
const _response = await axios(`https://www.npmjs.com/package/iobroker.${context.adapterName}`);
|
|
37
|
+
const _response = await context.axios(`https://www.npmjs.com/package/iobroker.${context.adapterName}`);
|
|
47
38
|
if (!_response.data) {
|
|
48
39
|
context.cfg.npmExists = false;
|
|
49
40
|
return context;
|
|
@@ -67,7 +58,7 @@ async function checkNpm(context) {
|
|
|
67
58
|
console.log('\n[E2000 - E2999] checkNpm');
|
|
68
59
|
let body;
|
|
69
60
|
try {
|
|
70
|
-
const response = await axios(`https://registry.npmjs.org/iobroker.${context.adapterName}`);
|
|
61
|
+
const response = await context.axios(`https://registry.npmjs.org/iobroker.${context.adapterName}`);
|
|
71
62
|
body = response.data;
|
|
72
63
|
} catch (e) {
|
|
73
64
|
if (
|
|
@@ -86,7 +77,7 @@ async function checkNpm(context) {
|
|
|
86
77
|
// bug in NPM some modules could be accessed via normal web page, but not by API
|
|
87
78
|
if (!body) {
|
|
88
79
|
try {
|
|
89
|
-
const _response = await axios(`https://www.npmjs.com/package/iobroker.${context.adapterName}`);
|
|
80
|
+
const _response = await context.axios(`https://www.npmjs.com/package/iobroker.${context.adapterName}`);
|
|
90
81
|
if (!_response.data) {
|
|
91
82
|
context.errors.push(
|
|
92
83
|
`[E2000] Package iobroker.${context.adapterName} not found on npm. Please publish at npm`,
|
package/lib/M3000_Testing.js
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
const axios = require('axios');
|
|
11
10
|
const compareVersions = require('compare-versions');
|
|
12
11
|
const yaml = require('js-yaml');
|
|
13
12
|
const semverMajor = require('semver/functions/major');
|
|
@@ -759,7 +758,7 @@ async function fetchRunJobs(context, runId) {
|
|
|
759
758
|
while (true) {
|
|
760
759
|
const url = `${context.githubUrlApi}/actions/runs/${runId}/jobs?per_page=100&page=${page}`;
|
|
761
760
|
common.debug(`Retrieving jobs for run ${runId} (page ${page})`);
|
|
762
|
-
const response = await axios.get(url);
|
|
761
|
+
const response = await context.axios.get(url);
|
|
763
762
|
const jobsPage = response.data?.jobs ?? [];
|
|
764
763
|
jobs.push(...jobsPage);
|
|
765
764
|
if (jobsPage.length < 100) {
|
|
@@ -787,7 +786,7 @@ async function fetchJobLog(context, jobId) {
|
|
|
787
786
|
// console.log('###############');
|
|
788
787
|
// console.log(url);
|
|
789
788
|
common.debug(`Fetching log for job ${jobId}`);
|
|
790
|
-
const response = await axios.get(url, { maxRedirects: 10, responseType: 'text' });
|
|
789
|
+
const response = await context.axios.get(url, { maxRedirects: 10, responseType: 'text' });
|
|
791
790
|
// console.log( response );
|
|
792
791
|
return typeof response.data === 'string' ? response.data : null;
|
|
793
792
|
} catch (e) {
|
|
@@ -967,7 +966,7 @@ async function checkTests(context) {
|
|
|
967
966
|
const url = `${context.githubUrlApi}/actions/workflows/${WORKFLOW_FILE_SHORT}/runs?per_page=100&page=${page}`;
|
|
968
967
|
common.debug(`Retrieving list of workflow runs from url ${url} (page ${page})`);
|
|
969
968
|
|
|
970
|
-
const workflowRunsResponse = await axios(url);
|
|
969
|
+
const workflowRunsResponse = await context.axios(url);
|
|
971
970
|
const runs = workflowRunsResponse.data?.workflow_runs ?? [];
|
|
972
971
|
|
|
973
972
|
workflowRuns.push(...runs);
|
|
@@ -1121,7 +1120,7 @@ async function checkTests(context) {
|
|
|
1121
1120
|
}
|
|
1122
1121
|
}
|
|
1123
1122
|
|
|
1124
|
-
const tagsResponse = await axios(`${context.githubUrlApi}/tags?per_page=100`);
|
|
1123
|
+
const tagsResponse = await context.axios(`${context.githubUrlApi}/tags?per_page=100`);
|
|
1125
1124
|
const tags = Array.isArray(tagsResponse.data) ? tagsResponse.data : [];
|
|
1126
1125
|
|
|
1127
1126
|
const currentRelease =
|
|
@@ -1155,7 +1154,7 @@ async function checkTests(context) {
|
|
|
1155
1154
|
);
|
|
1156
1155
|
} else {
|
|
1157
1156
|
const npmPackageName = `iobroker.${adapterName}`;
|
|
1158
|
-
const npmResponse = await axios(`https://registry.npmjs.org/${npmPackageName}`);
|
|
1157
|
+
const npmResponse = await context.axios(`https://registry.npmjs.org/${npmPackageName}`);
|
|
1159
1158
|
const npmPackageData = npmResponse.data || {};
|
|
1160
1159
|
const npmLatestRelease = npmPackageData['dist-tags'] && npmPackageData['dist-tags'].latest;
|
|
1161
1160
|
// if (npmLatestRelease) {
|
|
@@ -1451,6 +1450,30 @@ async function checkTests(context) {
|
|
|
1451
1450
|
`specifies "integration-test-command". This command should not be changed; the default value should be used.`,
|
|
1452
1451
|
);
|
|
1453
1452
|
}
|
|
1453
|
+
|
|
1454
|
+
// W3059 / E3060: adapter-tests should not override engine-strict in testing-action-adapter
|
|
1455
|
+
const adapterStepWithEngineStrict = jobs['adapter-tests'].steps.find(
|
|
1456
|
+
step =>
|
|
1457
|
+
typeof step.uses === 'string' &&
|
|
1458
|
+
step.uses.startsWith(adapterActionPrefix) &&
|
|
1459
|
+
step.with &&
|
|
1460
|
+
Object.prototype.hasOwnProperty.call(step.with, 'engine-strict'),
|
|
1461
|
+
);
|
|
1462
|
+
if (adapterStepWithEngineStrict) {
|
|
1463
|
+
// engine-strict may be a boolean or a string in the workflow yaml
|
|
1464
|
+
const engineStrictValue = `${adapterStepWithEngineStrict.with['engine-strict']}`.trim().toLowerCase();
|
|
1465
|
+
if (engineStrictValue === 'false') {
|
|
1466
|
+
context.errors.push(
|
|
1467
|
+
`[E3060] "${WORKFLOW_FILE_SHORT}": job "adapter-tests" step using "ioBroker/testing-action-adapter" ` +
|
|
1468
|
+
`sets "engine-strict" to false. Setting engine-strict to false is prohibited as this could hide errors occurring during installation at target systems.`,
|
|
1469
|
+
);
|
|
1470
|
+
} else {
|
|
1471
|
+
context.warnings.push(
|
|
1472
|
+
`[W3059] "${WORKFLOW_FILE_SHORT}": job "adapter-tests" step using "ioBroker/testing-action-adapter" ` +
|
|
1473
|
+
`specifies "engine-strict". This parameter should not be changed; the default value should be used.`,
|
|
1474
|
+
);
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1454
1477
|
}
|
|
1455
1478
|
|
|
1456
1479
|
// W3024 / E3025 / W3026: check node.js version matrix for adapter-tests
|
package/lib/M4000_Repository.js
CHANGED
|
@@ -7,24 +7,16 @@
|
|
|
7
7
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
const axios = require('axios');
|
|
11
10
|
const compareVersions = require('compare-versions');
|
|
12
11
|
const JSON5 = require('json5');
|
|
13
12
|
|
|
14
|
-
// disable axios caching
|
|
15
|
-
// axios.defaults.headers = {
|
|
16
|
-
// 'Cache-Control': 'no-cache',
|
|
17
|
-
// Pragma: 'no-cache',
|
|
18
|
-
// Expires: '0',
|
|
19
|
-
// };
|
|
20
|
-
|
|
21
13
|
const common = require('./common.js');
|
|
22
14
|
const config = require('./config.js');
|
|
23
15
|
|
|
24
16
|
async function getLatestRepo(context) {
|
|
25
17
|
console.log('[init] getting latest repository info');
|
|
26
18
|
try {
|
|
27
|
-
const response = await axios(
|
|
19
|
+
const response = await context.axios(
|
|
28
20
|
'https://raw.githubusercontent.com/ioBroker/ioBroker.repositories/master/sources-dist.json',
|
|
29
21
|
);
|
|
30
22
|
const body = response.data;
|
|
@@ -35,7 +27,8 @@ async function getLatestRepo(context) {
|
|
|
35
27
|
}
|
|
36
28
|
}
|
|
37
29
|
} catch (e) {
|
|
38
|
-
common.
|
|
30
|
+
const message = common.getResponseMessage(e);
|
|
31
|
+
common.error(`Cannot download latest repository info: ${e}${message ? ` - ${message}` : ''}`);
|
|
39
32
|
}
|
|
40
33
|
return context;
|
|
41
34
|
}
|
|
@@ -48,7 +41,7 @@ async function checkRepository(context) {
|
|
|
48
41
|
let body;
|
|
49
42
|
// download latest repo (if not already retrieved by preprocessing)
|
|
50
43
|
if (!context.latestRepo) {
|
|
51
|
-
const response = await axios(
|
|
44
|
+
const response = await context.axios(
|
|
52
45
|
'https://raw.githubusercontent.com/ioBroker/ioBroker.repositories/master/sources-dist.json',
|
|
53
46
|
);
|
|
54
47
|
body = response.data;
|
|
@@ -122,7 +115,7 @@ async function checkRepository(context) {
|
|
|
122
115
|
}
|
|
123
116
|
|
|
124
117
|
// download stable repo
|
|
125
|
-
let _response = await axios(
|
|
118
|
+
let _response = await context.axios(
|
|
126
119
|
'https://raw.githubusercontent.com/ioBroker/ioBroker.repositories/master/sources-dist-stable.json',
|
|
127
120
|
);
|
|
128
121
|
body = _response.data;
|
|
@@ -191,7 +184,7 @@ async function checkRepository(context) {
|
|
|
191
184
|
}
|
|
192
185
|
}
|
|
193
186
|
|
|
194
|
-
_response = await axios('https://download.iobroker.net/sources-dist-latest.json');
|
|
187
|
+
_response = await context.axios('https://download.iobroker.net/sources-dist-latest.json');
|
|
195
188
|
body = _response.data;
|
|
196
189
|
if (!body) {
|
|
197
190
|
context.errors.push('[E4029] Cannot download https://download.iobroker.net/sources-dist-latest.json');
|
|
@@ -200,7 +193,7 @@ async function checkRepository(context) {
|
|
|
200
193
|
context.latestRepoLive = body;
|
|
201
194
|
}
|
|
202
195
|
|
|
203
|
-
_response = await axios('https://download.iobroker.net/sources-dist.json');
|
|
196
|
+
_response = await context.axios('https://download.iobroker.net/sources-dist.json');
|
|
204
197
|
body = _response.data;
|
|
205
198
|
if (!body) {
|
|
206
199
|
context.errors.push('[E4030] Cannot download https://download.iobroker.net/sources-dist.json');
|