@iobroker/repochecker 2.6.0 → 2.7.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 +16 -0
- package/doc/issues.json +40 -1
- package/index.js +262 -101
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,6 +20,22 @@ Branch (`master/main/dev`) is optional.
|
|
|
20
20
|
-->
|
|
21
21
|
|
|
22
22
|
## Changelog
|
|
23
|
+
### 2.7.0 (2024-07-26)
|
|
24
|
+
* (mcm1957) Some non trivial keywords related to adapter are enforced now [#234].
|
|
25
|
+
* (mcm1957) Severity if [E105] / [W105] has been corrected [#204].
|
|
26
|
+
* (mcm1957) Disallow 'globalDependencies' at package.json [#204].
|
|
27
|
+
* (mcm1957) Several false positives for wwwOnly widgetadapters have been fixed [#230, #222].
|
|
28
|
+
* (mcm1957) Missing .npmignore is now considered an error [#229].
|
|
29
|
+
* (mcm1957) Usage of package.json 'files' section is now recommended.
|
|
30
|
+
* (mcm1957) If more than 7 common.news entries are present a warning is issued now [#232].
|
|
31
|
+
* (mcm1957) Versions listed at common.news are checked to exist at npm now [#226].
|
|
32
|
+
* (mcm1957) 'package-lock.json' is checked to exist at GitHub now [#188].
|
|
33
|
+
* (mcm1957) travis checks have been removed [#237].
|
|
34
|
+
* (mcm1957) Copyright year now honors commit year and npm publish year too [#237].
|
|
35
|
+
|
|
36
|
+
### 2.6.1 (2024-06-24)
|
|
37
|
+
* (mcm1957) Check "[W156] Adapter should support admin 5 UI (jsonConfig)" checks for reactUi now.
|
|
38
|
+
|
|
23
39
|
### 2.6.0 (2024-06-24)
|
|
24
40
|
* (mcm1957) Check has been aded to ensure keywords and common.keywords are present. [#200]
|
|
25
41
|
* (mcm1957) Detection of react has been added, gulpfile.js is accepted for react based UIs now. [#223]
|
package/doc/issues.json
CHANGED
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"title": "Node.js ${requiredNodeVersion} is required as minimum, node.js ${recommendedNodeVersion} is recommended. Please adapt `{'engines' : { 'node' >= '${match.groups.vers}' } }` at package.json."
|
|
133
133
|
},
|
|
134
134
|
"E031": {
|
|
135
|
-
"title": "No devDependencies declared at package.json.
|
|
135
|
+
"title": "No devDependencies declared at package.json. Please correct package.json"
|
|
136
136
|
},
|
|
137
137
|
"E032": {
|
|
138
138
|
"title": "No dependency declared for ${dependency}. Please add `${dependency}`:`${recommendedVersion}` to dependencies at package.json"
|
|
@@ -152,6 +152,9 @@
|
|
|
152
152
|
"E039": {
|
|
153
153
|
"title": "`keywords` must be an array within package.json and contain some useful keywords"
|
|
154
154
|
},
|
|
155
|
+
"E042": {
|
|
156
|
+
"title": "`globalDependencies` is misplaced at package.json. Did you mean `common.globalDependencies` at io-package.json?"
|
|
157
|
+
},
|
|
155
158
|
"E100": {
|
|
156
159
|
"title": "Cannot parse io-package.json"
|
|
157
160
|
},
|
|
@@ -350,6 +353,9 @@
|
|
|
350
353
|
"E201": {
|
|
351
354
|
"title": "Bluefox was not found in the collaborators on NPM!. Please execute in adapter directory: `npm owner add bluefox iobroker.adapterName`"
|
|
352
355
|
},
|
|
356
|
+
"E204": {
|
|
357
|
+
"title": "Version(s) `${missingVersions.join(`, `)}` listed at common.news at io-package.json do not exist at NPM. Please remove from news."
|
|
358
|
+
},
|
|
353
359
|
"E300": {
|
|
354
360
|
"title": "Not found on travis. Please setup travis or use github actions (preferred)"
|
|
355
361
|
},
|
|
@@ -497,12 +503,27 @@
|
|
|
497
503
|
"E804": {
|
|
498
504
|
"title": "node_modules not found in "
|
|
499
505
|
},
|
|
506
|
+
"E851": {
|
|
507
|
+
"title": ".npmignore found but `files` is used at package.json. Please remove .npmignore."
|
|
508
|
+
},
|
|
509
|
+
"E852": {
|
|
510
|
+
"title": ".npmignore not found"
|
|
511
|
+
},
|
|
512
|
+
"E853": {
|
|
513
|
+
"title": "iob_npm.done not found in .npmignore"
|
|
514
|
+
},
|
|
515
|
+
"E854": {
|
|
516
|
+
"title": "node_modules not found in "
|
|
517
|
+
},
|
|
500
518
|
"E902": {
|
|
501
519
|
"title": "node_modules not found in .npmignore"
|
|
502
520
|
},
|
|
503
521
|
"E903": {
|
|
504
522
|
"title": "iob_npm.done not found in .gitignore"
|
|
505
523
|
},
|
|
524
|
+
"E999": {
|
|
525
|
+
"title": "GLOBAL ERROR: ${err.toString()}, ${JSON.stringify(err)}"
|
|
526
|
+
},
|
|
506
527
|
"W027": {
|
|
507
528
|
"title": "{'engines' : { 'node' : '${nodeVal}' } }` is not parseable."
|
|
508
529
|
},
|
|
@@ -522,11 +543,17 @@
|
|
|
522
543
|
"title": "${blacklistPackageJson[blacklist].msg}"
|
|
523
544
|
},
|
|
524
545
|
"W040": {
|
|
546
|
+
"title": "`keywords` within package.json should contain `${recommendedKeywords.join(', ')}`"
|
|
547
|
+
},
|
|
548
|
+
"W041": {
|
|
525
549
|
"title": "`keywords` within package.json should not contain `${forbiddenKeywords.join(', ')}`"
|
|
526
550
|
},
|
|
527
551
|
"W105": {
|
|
528
552
|
"title": "`common.titleLang` should be translated into all supported languages"
|
|
529
553
|
},
|
|
554
|
+
"W106": {
|
|
555
|
+
"title": "`common.titleLang` should not contain word `adapter` in the name. It is clear, that this is adapter. Now: ${JSON.stringify(context.ioPackageJson.common.titleLang)}"
|
|
556
|
+
},
|
|
530
557
|
"W109": {
|
|
531
558
|
"title": "`common.desc` should be translated into all supported languages"
|
|
532
559
|
},
|
|
@@ -539,6 +566,9 @@
|
|
|
539
566
|
"W115": {
|
|
540
567
|
"title": "`common.tier` is required in io-package.json"
|
|
541
568
|
},
|
|
569
|
+
"W130": {
|
|
570
|
+
"title": "Many `common.news` found in io-package.json. Repositorybuilder will truncate at 7 news. Please remove old news."
|
|
571
|
+
},
|
|
542
572
|
"W145": {
|
|
543
573
|
"title": "Each `common.news` should be translated into all supported languages"
|
|
544
574
|
},
|
|
@@ -614,9 +644,18 @@
|
|
|
614
644
|
"W521": {
|
|
615
645
|
"title": "`gulp` found at devDependencies at package.json but no `gulpfile.js` found. Is this dependency really required?"
|
|
616
646
|
},
|
|
647
|
+
"W522": {
|
|
648
|
+
"title": "Please consider migrating to admin 5 UI (jsonConfig)."
|
|
649
|
+
},
|
|
650
|
+
"W606": {
|
|
651
|
+
"title": "Could not retrieve timestamp of LATEST revision at npm."
|
|
652
|
+
},
|
|
617
653
|
"W801": {
|
|
618
654
|
"title": ".npmignore not found"
|
|
619
655
|
},
|
|
656
|
+
"W853": {
|
|
657
|
+
"title": ".npmignore found - consider using package.json object `files` instead."
|
|
658
|
+
},
|
|
620
659
|
"W901": {
|
|
621
660
|
"title": ".gitignore not found"
|
|
622
661
|
}
|
package/index.js
CHANGED
|
@@ -21,6 +21,7 @@ const JSON5 = require('json5');
|
|
|
21
21
|
const compareVersions = require('compare-versions');
|
|
22
22
|
//const Languagedetect = require('languagedetect');
|
|
23
23
|
//const languagedetect = new Languagedetect;
|
|
24
|
+
const execSync = require('node:child_process').execSync;
|
|
24
25
|
|
|
25
26
|
const issues = require('./doc/issues');
|
|
26
27
|
|
|
@@ -49,7 +50,8 @@ const dependencies = {
|
|
|
49
50
|
const devDependencies = {
|
|
50
51
|
"@iobroker/testing": {
|
|
51
52
|
"required":"4.1.3",
|
|
52
|
-
"recommended":"4.1.3"
|
|
53
|
+
"recommended":"4.1.3",
|
|
54
|
+
"onlyWWW":false
|
|
53
55
|
}
|
|
54
56
|
};
|
|
55
57
|
|
|
@@ -456,11 +458,11 @@ function checkPackageJson(context) {
|
|
|
456
458
|
context.checks.push('Adapter name is not reserved');
|
|
457
459
|
}
|
|
458
460
|
|
|
459
|
-
if (!context.packageJson.dependencies) {
|
|
461
|
+
if (!context.ioPackageJson.common.onlyWWW && !context.packageJson.dependencies) {
|
|
460
462
|
context.errors.push('[W030] No dependencies declared at package.json. Is this really correct?');
|
|
461
463
|
}
|
|
462
464
|
if (!context.packageJson.devDependencies) {
|
|
463
|
-
context.errors.push('[E031] No devDependencies declared at package.json.
|
|
465
|
+
context.errors.push('[E031] No devDependencies declared at package.json. Please correct package.json');
|
|
464
466
|
}
|
|
465
467
|
|
|
466
468
|
if ((context.packageJson.dependencies && context.packageJson.dependencies.npm) || (context.packageJson.optionalDependencies && context.packageJson.optionalDependencies.npm)) {
|
|
@@ -536,6 +538,7 @@ function checkPackageJson(context) {
|
|
|
536
538
|
}
|
|
537
539
|
|
|
538
540
|
for (const dependency in devDependencies) {
|
|
541
|
+
if ((devDependencies[dependency].onlyWWW === false) && context.ioPackageJson.common.onlyWWW) continue;
|
|
539
542
|
const requiredVersion = devDependencies[dependency].required;
|
|
540
543
|
const recommendedVersion = devDependencies[dependency].recommended;
|
|
541
544
|
let dependencyVersion = context.packageJson.devDependencies[`${dependency}`] || '';
|
|
@@ -580,21 +583,34 @@ function checkPackageJson(context) {
|
|
|
580
583
|
|
|
581
584
|
if (! context.packageJson.keywords) {
|
|
582
585
|
context.errors.push('[E039] "keywords" must be an array within package.json and contain some useful keywords');
|
|
586
|
+
} else if (!Array.isArray(context.packageJson.keywords)) {
|
|
587
|
+
context.errors.push('[E039] "keywords" must be an array within package.json and contain some useful keywords');
|
|
583
588
|
} else {
|
|
584
589
|
const forbiddenKeywords = [];
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
context.
|
|
590
|
+
const ignoredKeywords = ["iobroker", "smart home", "smarthome", "home automation", "template"];
|
|
591
|
+
const recommendedKeywords = ["ioBroker"];
|
|
592
|
+
//console.log(`[DEBUG] package.keywords: "${context.packageJson.keywords.join(', ')}"`);
|
|
593
|
+
//console.log(`[DEBUG] filtered: "${context.packageJson.keywords.filter(keyword => !ignoredKeywords.includes(keyword.toLowerCase()))}"`);
|
|
594
|
+
if (context.packageJson.keywords.filter(keyword => !ignoredKeywords.includes(keyword.toLowerCase())).length === 0 ) {
|
|
595
|
+
context.errors.push(`[E039] "keywords" within package.json must contain some keywords besides "${context.packageJson.keywords.join(', ')}" related to adapter`);
|
|
596
|
+
}
|
|
597
|
+
if (! recommendedKeywords.filter(keyword => context.packageJson.keywords.includes(keyword)).length > 0) {
|
|
598
|
+
context.warnings.push(`[W040] "keywords" within package.json should contain "${recommendedKeywords.join(', ')}"`);
|
|
599
|
+
}
|
|
600
|
+
if (forbiddenKeywords.filter(keyword => context.packageJson.keywords.map(k => k.toLowerCase()).includes(keyword)).length > 0) {
|
|
601
|
+
context.warnings.push(`[W041] "keywords" within package.json should not contain "${forbiddenKeywords.join(', ')}"`);
|
|
591
602
|
}
|
|
592
603
|
|
|
593
|
-
context.checks.push('"keywords" found in package.json');
|
|
604
|
+
context.checks.push('"keywords" found in package.json and refers to an array');
|
|
594
605
|
}
|
|
595
606
|
|
|
607
|
+
if (context.packageJson.globalDependencies) {
|
|
608
|
+
context.errors.push('[E042] "globalDependencies" is misplaced at package.json. Did you mean "common.globalDependencies" at io-package.json?');
|
|
609
|
+
} else {
|
|
610
|
+
context.checks.push('"globalDependencies" not found in package.json');
|
|
611
|
+
}
|
|
596
612
|
|
|
597
|
-
// max number is
|
|
613
|
+
// max number is W042
|
|
598
614
|
|
|
599
615
|
return context;
|
|
600
616
|
});
|
|
@@ -1021,9 +1037,6 @@ const licenses = [
|
|
|
1021
1037
|
'Zed',
|
|
1022
1038
|
'Zend-2.0',
|
|
1023
1039
|
'Zimbra-1.3',
|
|
1024
|
-
'Zimbra-1.4',
|
|
1025
|
-
'zlib-acknowledgement',
|
|
1026
|
-
'Zlib',
|
|
1027
1040
|
'ZPL-1.1',
|
|
1028
1041
|
'ZPL-2.0',
|
|
1029
1042
|
'ZPL-2.1',
|
|
@@ -1067,6 +1080,7 @@ function checkIOPackageJson(context) {
|
|
|
1067
1080
|
'password',
|
|
1068
1081
|
'passwort',
|
|
1069
1082
|
'pin',
|
|
1083
|
+
'private_pw',
|
|
1070
1084
|
'psk',
|
|
1071
1085
|
'pwd',
|
|
1072
1086
|
'secret',
|
|
@@ -1139,7 +1153,7 @@ function checkIOPackageJson(context) {
|
|
|
1139
1153
|
} else {
|
|
1140
1154
|
let missingLang = checkLanguages(context.ioPackageJson.common.titleLang, requiredLanguages);
|
|
1141
1155
|
if (missingLang.length) {
|
|
1142
|
-
context.warnings.push(`[
|
|
1156
|
+
context.warnings.push(`[W105] Missing mandatory translation into ${missingLang.join()} of "common.titleLang" in io-package.json.`);
|
|
1143
1157
|
}
|
|
1144
1158
|
|
|
1145
1159
|
missingLang = checkLanguages(context.ioPackageJson.common.titleLang, allowedLanguages);
|
|
@@ -1153,17 +1167,17 @@ function checkIOPackageJson(context) {
|
|
|
1153
1167
|
Object.keys(context.ioPackageJson.common.titleLang).forEach(lang => {
|
|
1154
1168
|
const text = context.ioPackageJson.common.titleLang[lang];
|
|
1155
1169
|
if (text.match(/iobroker/i)) {
|
|
1156
|
-
context.errors.push(`[
|
|
1170
|
+
context.errors.push(`[E106] "common.titleLang" must not have ioBroker in the name. It is clear, for what this adapter was created. Now: ${JSON.stringify(context.ioPackageJson.common.titleLang)}`);
|
|
1157
1171
|
} else {
|
|
1158
1172
|
context.checks.push('"common.titleLang" has no ioBroker in it in io-package.json');
|
|
1159
1173
|
}
|
|
1160
1174
|
|
|
1161
1175
|
if (text.match(/\sadapter|adapter\s/i)) {
|
|
1162
|
-
context.
|
|
1176
|
+
context.warnings.push(`[W106] "common.titleLang" should not contain word "adapter" in the name. It is clear, that this is adapter. Now: ${JSON.stringify(context.ioPackageJson.common.titleLang)}`);
|
|
1163
1177
|
} else {
|
|
1164
1178
|
context.checks.push('"common.titleLang" has no "adapter" in it in io-package.json');
|
|
1165
1179
|
}
|
|
1166
|
-
})
|
|
1180
|
+
})
|
|
1167
1181
|
}
|
|
1168
1182
|
|
|
1169
1183
|
if (!context.ioPackageJson.common.version) {
|
|
@@ -1260,9 +1274,10 @@ function checkIOPackageJson(context) {
|
|
|
1260
1274
|
context.checks.push('"common.materialize" or "common.adminUI.config" found in io-package.json');
|
|
1261
1275
|
}
|
|
1262
1276
|
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1277
|
+
// check moved to W520
|
|
1278
|
+
//if (!context.ioPackageJson.common.adminUI || (context.ioPackageJson.common.adminUI.config !== 'json' && context.ioPackageJson.common.adminUI.config !== 'none')) {
|
|
1279
|
+
// context.warnings.push('[W156] Adapter should support admin 5 UI (jsonConfig) if you do not use a React based UI');
|
|
1280
|
+
//}
|
|
1266
1281
|
} else {
|
|
1267
1282
|
context.checks.push('adapter has no admin config');
|
|
1268
1283
|
|
|
@@ -1381,6 +1396,8 @@ function checkIOPackageJson(context) {
|
|
|
1381
1396
|
|
|
1382
1397
|
if (Object.keys(context.ioPackageJson.common.news).length > 20) {
|
|
1383
1398
|
context.errors.push('[E130] Too many "common.news" found in io-package.json. Must be less than 20. Please remove old news.');
|
|
1399
|
+
} else if (Object.keys(context.ioPackageJson.common.news).length > 7) {
|
|
1400
|
+
context.warnings.push('[W130] Many "common.news" found in io-package.json. Repositorybuilder will truncate at 7 news. Please remove old news.');
|
|
1384
1401
|
}
|
|
1385
1402
|
|
|
1386
1403
|
Object.keys(context.ioPackageJson.common.news).forEach(version => {
|
|
@@ -1728,6 +1745,20 @@ function checkNpm(context) {
|
|
|
1728
1745
|
}
|
|
1729
1746
|
}
|
|
1730
1747
|
|
|
1748
|
+
if (context.ioPackageJson && context.ioPackageJson.common && context.ioPackageJson.common.news) {
|
|
1749
|
+
let missingVersions = [];
|
|
1750
|
+
for (const vers in context.ioPackageJson.common.news) {
|
|
1751
|
+
//console.log(`[DEBUG] news for ${vers}`);
|
|
1752
|
+
if (!body.versions[vers]) {
|
|
1753
|
+
missingVersions.push(vers);
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
if (missingVersions.length) {
|
|
1757
|
+
context.errors.push(`[E204] Version(s) "${missingVersions.join(", ")}" listed at common.news at io-package.json do not exist at NPM. Please remove from news.`);
|
|
1758
|
+
} else {
|
|
1759
|
+
context.checks.push(`All versions listed at news exist at npm`);
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1731
1762
|
return context;
|
|
1732
1763
|
// max number is E202
|
|
1733
1764
|
});
|
|
@@ -1742,43 +1773,44 @@ function checkTests(context) {
|
|
|
1742
1773
|
return Promise.resolve(context);
|
|
1743
1774
|
}
|
|
1744
1775
|
|
|
1745
|
-
const travisURL = `${context.githubUrlOriginal.replace('github.com', 'api.travis-ci.org')}.png`;
|
|
1746
|
-
|
|
1747
|
-
return axios(travisURL)
|
|
1748
|
-
.then(response => {
|
|
1749
|
-
if (!response.data) {
|
|
1750
|
-
context.errors.push('[E300] Not found on travis. Please setup travis or use github actions (preferred)');
|
|
1751
|
-
return context;
|
|
1752
|
-
}
|
|
1753
|
-
if (!response.headers || !response.headers['content-disposition']) {
|
|
1754
|
-
context.errors.push('[E300] Not found on travis. Please setup travis or use github actions (preferred)');
|
|
1755
|
-
return context;
|
|
1756
|
-
}
|
|
1757
|
-
// inline; filename="passing.png"
|
|
1758
|
-
const m = response.headers['content-disposition'].match(/filename="(.+)"$/);
|
|
1759
|
-
if (!m) {
|
|
1760
|
-
context.errors.push('[E300] Not found on travis. Please setup travis or use github actions (preferred)');
|
|
1761
|
-
return context;
|
|
1762
|
-
}
|
|
1763
|
-
|
|
1764
|
-
if (m[1] === 'unknown.png') {
|
|
1765
|
-
context.errors.push('[E300] Not found on travis. Please setup travis or use github actions (preferred)');
|
|
1766
|
-
return context;
|
|
1767
|
-
}
|
|
1768
|
-
|
|
1769
|
-
context.checks.push('Found on travis-ci');
|
|
1770
|
-
|
|
1771
|
-
context.warnings.push('[W302] Use github actions instead of travis-ci');
|
|
1772
|
-
|
|
1773
|
-
if (m[1] !== 'passing.png') {
|
|
1774
|
-
context.errors.push('[E301] Tests on Travis-ci.org are broken. Please fix.');
|
|
1775
|
-
} else {
|
|
1776
|
-
context.checks.push('Tests are OK on travis-ci');
|
|
1777
|
-
}
|
|
1778
|
-
|
|
1779
|
-
return context;
|
|
1780
|
-
// max number is E302
|
|
1781
|
-
});
|
|
1776
|
+
// const travisURL = `${context.githubUrlOriginal.replace('github.com', 'api.travis-ci.org')}.png`;
|
|
1777
|
+
//
|
|
1778
|
+
// return axios(travisURL)
|
|
1779
|
+
// .then(response => {
|
|
1780
|
+
// if (!response.data) {
|
|
1781
|
+
// context.errors.push('[E300] Not found on travis. Please setup travis or use github actions (preferred)');
|
|
1782
|
+
// return context;
|
|
1783
|
+
// }
|
|
1784
|
+
// if (!response.headers || !response.headers['content-disposition']) {
|
|
1785
|
+
// context.errors.push('[E300] Not found on travis. Please setup travis or use github actions (preferred)');
|
|
1786
|
+
// return context;
|
|
1787
|
+
// }
|
|
1788
|
+
// // inline; filename="passing.png"
|
|
1789
|
+
// const m = response.headers['content-disposition'].match(/filename="(.+)"$/);
|
|
1790
|
+
// if (!m) {
|
|
1791
|
+
// context.errors.push('[E300] Not found on travis. Please setup travis or use github actions (preferred)');
|
|
1792
|
+
// return context;
|
|
1793
|
+
// }
|
|
1794
|
+
//
|
|
1795
|
+
// if (m[1] === 'unknown.png') {
|
|
1796
|
+
// context.errors.push('[E300] Not found on travis. Please setup travis or use github actions (preferred)');
|
|
1797
|
+
// return context;
|
|
1798
|
+
// }
|
|
1799
|
+
//
|
|
1800
|
+
// context.checks.push('Found on travis-ci');
|
|
1801
|
+
//
|
|
1802
|
+
// context.warnings.push('[W302] Use github actions instead of travis-ci');
|
|
1803
|
+
//
|
|
1804
|
+
// if (m[1] !== 'passing.png') {
|
|
1805
|
+
// context.errors.push('[E301] Tests on Travis-ci.org are broken. Please fix.');
|
|
1806
|
+
// } else {
|
|
1807
|
+
// context.checks.push('Tests are OK on travis-ci');
|
|
1808
|
+
// }
|
|
1809
|
+
//
|
|
1810
|
+
// return context;
|
|
1811
|
+
// // max number is E302
|
|
1812
|
+
// });
|
|
1813
|
+
return Promise.resolve(context);
|
|
1782
1814
|
}
|
|
1783
1815
|
|
|
1784
1816
|
// E4xx
|
|
@@ -2060,7 +2092,9 @@ function checkCode(context) {
|
|
|
2060
2092
|
'admin/jsonCustom.json5',
|
|
2061
2093
|
'admin/blockly.js',
|
|
2062
2094
|
|
|
2063
|
-
'src-admin/package.json', //
|
|
2095
|
+
'src-admin/package.json', // check if react is used
|
|
2096
|
+
'src-widgets/package.json', // check if react is used
|
|
2097
|
+
'src/package.json', // check if react is used
|
|
2064
2098
|
];
|
|
2065
2099
|
allowedLanguages.forEach(lang =>
|
|
2066
2100
|
readFiles.push(`admin/i18n/${lang}/translations.json`));
|
|
@@ -2148,14 +2182,61 @@ function checkCode(context) {
|
|
|
2148
2182
|
})
|
|
2149
2183
|
.then(context => {
|
|
2150
2184
|
let usesReact = false;
|
|
2185
|
+
if (context.packageJson.devDependencies &&
|
|
2186
|
+
(context.packageJson.devDependencies['@iobroker/adapter-react-v5'] || context.packageJson.devDependencies['react'])) {
|
|
2187
|
+
console.log('REACT detected at package devDependencies');
|
|
2188
|
+
usesReact = true;
|
|
2189
|
+
};
|
|
2190
|
+
if (context.packageJson.dependencies &&
|
|
2191
|
+
(context.packageJson.dependencies['@iobroker/adapter-react-v5'] || context.packageJson.dependencies['react'])) {
|
|
2192
|
+
console.log('REACT detected at package dependencies');
|
|
2193
|
+
usesReact = true;
|
|
2194
|
+
}
|
|
2151
2195
|
if (context['/src-admin/package.json']) {
|
|
2152
2196
|
//console.log('"src-admin/package.json" exists');
|
|
2153
2197
|
let packageJson = JSON.parse(context['/src-admin/package.json']);
|
|
2154
2198
|
if (packageJson.devDependencies && packageJson.devDependencies['@iobroker/adapter-react-v5'] ){
|
|
2199
|
+
console.log('REACT detected at src-admin/package devDependencies');
|
|
2200
|
+
usesReact = true;
|
|
2201
|
+
}
|
|
2202
|
+
if (packageJson.dependencies && packageJson.dependencies['@iobroker/adapter-react-v5'] ){
|
|
2203
|
+
console.log('REACT detected at src-admin/package dependencies');
|
|
2204
|
+
usesReact = true;
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
if (context['/src-widgets/package.json']) {
|
|
2208
|
+
//console.log('"src-widgets/package.json" exists');
|
|
2209
|
+
let packageJson = JSON.parse(context['/src-widgets/package.json']);
|
|
2210
|
+
if (packageJson.devDependencies && (
|
|
2211
|
+
packageJson.devDependencies['@iobroker/adapter-react-v5'] || packageJson.devDependencies['react'])) {
|
|
2212
|
+
console.log('REACT detected at src-widgets/package devDependencies');
|
|
2213
|
+
usesReact = true;
|
|
2214
|
+
}
|
|
2215
|
+
if (packageJson.dependencies && (
|
|
2216
|
+
packageJson.dependencies['@iobroker/adapter-react-v5'] || packageJson.dependencies['react'])) {
|
|
2217
|
+
console.log('REACT detected at src-widgets/package dependencies');
|
|
2218
|
+
usesReact = true;
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
if (context['/src/package.json']) {
|
|
2222
|
+
//console.log('"src/package.json" exists');
|
|
2223
|
+
let packageJson = JSON.parse(context['/src/package.json']);
|
|
2224
|
+
if (packageJson.devDependencies && packageJson.devDependencies['@iobroker/adapter-react-v5'] ){
|
|
2225
|
+
// console.log('REACT detected');
|
|
2226
|
+
usesReact = true;
|
|
2227
|
+
}
|
|
2228
|
+
if (packageJson.dependencies && packageJson.dependencies['@iobroker/adapter-react-v5'] ){
|
|
2155
2229
|
// console.log('REACT detected');
|
|
2156
2230
|
usesReact = true;
|
|
2157
2231
|
}
|
|
2158
2232
|
}
|
|
2233
|
+
|
|
2234
|
+
if (! usesReact && !context.ioPackageJson.common.noConfig &&
|
|
2235
|
+
(!context.ioPackageJson.common.adminUI ||
|
|
2236
|
+
(context.ioPackageJson.common.adminUI.config !== 'json' && context.ioPackageJson.common.adminUI.config !== 'none')
|
|
2237
|
+
)) {
|
|
2238
|
+
context.warnings.push('[W522] Please consider migrating to admin 5 UI (jsonConfig).');
|
|
2239
|
+
}
|
|
2159
2240
|
|
|
2160
2241
|
if (context.ioPackageJson.common.materialize || (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'materialize')) {
|
|
2161
2242
|
if (context['/admin/index_m.html'] && context['/admin/index_m.html'].includes('selectID.js') && !context.filesList.includes('admin/img/info-big.png')) {
|
|
@@ -2250,6 +2331,10 @@ function checkCode(context) {
|
|
|
2250
2331
|
context.errors.push('[E503] "iob_npm.done" found in repo! Remove that file');
|
|
2251
2332
|
}
|
|
2252
2333
|
|
|
2334
|
+
if (!context['/package-lock.json']) {
|
|
2335
|
+
context.warnings.push('[W522] "package-lock.json" not found in repo! Please remove from .gitignore!');
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2253
2338
|
if (context['/.travis.yml']) {
|
|
2254
2339
|
context.hasTravis = true;
|
|
2255
2340
|
}
|
|
@@ -2273,10 +2358,12 @@ function checkCode(context) {
|
|
|
2273
2358
|
|
|
2274
2359
|
if (context.packageJson.main && context.packageJson.main.endsWith('.js')) {
|
|
2275
2360
|
if (!context['/' + context.packageJson.main]) {
|
|
2276
|
-
|
|
2361
|
+
if (!context.ioPackageJson.common.nogit) {
|
|
2362
|
+
context.errors.push(`[E519] "${context.packageJson.main}" found in package.json, but not found as file`);
|
|
2363
|
+
}
|
|
2277
2364
|
} else {
|
|
2278
2365
|
if (context['/' + context.packageJson.main].includes('setInterval(') && !context[`/${context.packageJson.main}`].includes('clearInterval(')) {
|
|
2279
|
-
if (context.ioPackageJson.compact) {
|
|
2366
|
+
if (context.ioPackageJson.common.compact) {
|
|
2280
2367
|
// if compact mode supported, it is critical
|
|
2281
2368
|
context.errors.push(`[E504] setInterval found in "${context.packageJson.main}", but no clearInterval detected`);
|
|
2282
2369
|
} else {
|
|
@@ -2284,7 +2371,7 @@ function checkCode(context) {
|
|
|
2284
2371
|
}
|
|
2285
2372
|
}
|
|
2286
2373
|
if (context['/' + context.packageJson.main].includes('setTimeout(') && !context['/' + context.packageJson.main].includes('clearTimeout(')) {
|
|
2287
|
-
if (context.ioPackageJson.compact) {
|
|
2374
|
+
if (context.ioPackageJson.common.compact) {
|
|
2288
2375
|
// if compact mode supported, it is critical
|
|
2289
2376
|
context.errors.push(`[E505] setTimeout found in "${context.packageJson.main}", but no clearTimeout detected`);
|
|
2290
2377
|
} else {
|
|
@@ -2314,38 +2401,12 @@ function checkCommits(context) {
|
|
|
2314
2401
|
.then(data => {
|
|
2315
2402
|
const m = data.match(/Commits on [\w\s\d]+, (\d\d\d\d)/);
|
|
2316
2403
|
if (m) {
|
|
2317
|
-
context.lastCommitYear = m[1];
|
|
2404
|
+
context.lastCommitYear = Number(m[1]);
|
|
2318
2405
|
}
|
|
2319
2406
|
return context;
|
|
2320
2407
|
});
|
|
2321
2408
|
}
|
|
2322
2409
|
|
|
2323
|
-
// E8xx
|
|
2324
|
-
function checkGithubRepo(context) {
|
|
2325
|
-
return new Promise((resolve) => {
|
|
2326
|
-
console.log('\ncheckGithubRepo [E8xx]');
|
|
2327
|
-
|
|
2328
|
-
if (!context.githubApiData.description) {
|
|
2329
|
-
context.errors.push(`[E801] No repository about text found. Please go to "${context.githubUrlOriginal}", press the settings button beside the about title and add the description.`);
|
|
2330
|
-
} else {
|
|
2331
|
-
context.checks.push('Github repository about found.');
|
|
2332
|
-
}
|
|
2333
|
-
|
|
2334
|
-
if (!context.githubApiData.topics || context.githubApiData.topics.length === 0) {
|
|
2335
|
-
context.errors.push(`[E802] No topics found in the repository. Please go to "${context.githubUrlOriginal}", press the settings button beside the about title and add some topics.`);
|
|
2336
|
-
} else {
|
|
2337
|
-
context.checks.push('Github repository about found.');
|
|
2338
|
-
}
|
|
2339
|
-
|
|
2340
|
-
if (context.githubApiData.archived) {
|
|
2341
|
-
context.errors.push(`[E803] Archived repositories are not allowed.`);
|
|
2342
|
-
}
|
|
2343
|
-
|
|
2344
|
-
// max E803
|
|
2345
|
-
resolve(context);
|
|
2346
|
-
});
|
|
2347
|
-
}
|
|
2348
|
-
|
|
2349
2410
|
// E6xx
|
|
2350
2411
|
function checkReadme(context) {
|
|
2351
2412
|
// https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/README.md
|
|
@@ -2370,15 +2431,48 @@ function checkReadme(context) {
|
|
|
2370
2431
|
}
|
|
2371
2432
|
}
|
|
2372
2433
|
|
|
2434
|
+
let npmYear = 0;
|
|
2435
|
+
try {
|
|
2436
|
+
const result = execSync(`npm view iobroker.${context.adapterName} --json`, { encoding: 'utf-8' });
|
|
2437
|
+
const npmJson = JSON.parse(result);
|
|
2438
|
+
//console.log(`[DEBUG] ${JSON.stringify(npmJson)}`);
|
|
2439
|
+
if (npmJson['dist-tags'] && npmJson['dist-tags'].latest) {
|
|
2440
|
+
const latest = npmJson['dist-tags'].latest;
|
|
2441
|
+
const timeStr = npmJson.time[latest];
|
|
2442
|
+
npmYear = new Date(timeStr).getFullYear();
|
|
2443
|
+
console.log(`[DEBUG] ${latest} - ${timeStr} - ${npmYear}`);
|
|
2444
|
+
}
|
|
2445
|
+
} catch (e) {
|
|
2446
|
+
context.Warnings.push('[W606] Could not retrieve timestamp of LATEST revision at npm.');
|
|
2447
|
+
console.log(`Error executing "npm view" - ${e}`);
|
|
2448
|
+
}
|
|
2449
|
+
|
|
2373
2450
|
const pos = data.indexOf('## License');
|
|
2374
2451
|
if (pos === -1) {
|
|
2375
2452
|
context.errors.push('[E604] No "## License" found in README.md');
|
|
2376
2453
|
} else {
|
|
2377
2454
|
context.checks.push('## License found in README.md');
|
|
2378
2455
|
const text = data.substring(pos);
|
|
2379
|
-
const year = new Date().getFullYear()
|
|
2380
|
-
|
|
2381
|
-
|
|
2456
|
+
const year = new Date().getFullYear();
|
|
2457
|
+
const commitYear = context.lastCommitYear || 0;
|
|
2458
|
+
let readmeYear = 0;
|
|
2459
|
+
let m = text.match(/\d\d\d\d-(\d\d\d\d)/);
|
|
2460
|
+
if (m) {
|
|
2461
|
+
readmeYear = Number(m[1]);
|
|
2462
|
+
} else {
|
|
2463
|
+
m = text.match(/(\d\d\d\d)/);
|
|
2464
|
+
if (m) {
|
|
2465
|
+
readmeYear = Number(m[1]);
|
|
2466
|
+
}
|
|
2467
|
+
}
|
|
2468
|
+
console.log(`README year ${readmeYear}`);
|
|
2469
|
+
console.log(`Current year ${year}`);
|
|
2470
|
+
console.log(`Commit year ${commitYear}`);
|
|
2471
|
+
console.log(`NPM year ${npmYear}`);
|
|
2472
|
+
|
|
2473
|
+
let valid = (readmeYear === year || readmeYear >= commitYear || readmeYear >=npmYear);
|
|
2474
|
+
if (!valid) {
|
|
2475
|
+
const m = text.match(/(\d\d\commitd\d)-\d\d\d\d/);
|
|
2382
2476
|
if (m) {
|
|
2383
2477
|
context.errors.push(`[E605] No actual year found in copyright. Please add "Copyright (c) ${m[1]}-${year} ${getAuthor(context.packageJson.author)}" at the end of README.md`);
|
|
2384
2478
|
} else {
|
|
@@ -2412,10 +2506,42 @@ function checkLicenseFile(context) {
|
|
|
2412
2506
|
} else {
|
|
2413
2507
|
context.checks.push('LICENSE file found');
|
|
2414
2508
|
|
|
2509
|
+
let npmYear = 0;
|
|
2510
|
+
try {
|
|
2511
|
+
const result = execSync(`npm view iobroker.${context.adapterName} --json`, { encoding: 'utf-8' });
|
|
2512
|
+
const npmJson = JSON.parse(result);
|
|
2513
|
+
//console.log(`[DEBUG] ${JSON.stringify(npmJson)}`);
|
|
2514
|
+
if (npmJson['dist-tags'] && npmJson['dist-tags'].latest) {
|
|
2515
|
+
const latest = npmJson['dist-tags'].latest;
|
|
2516
|
+
const timeStr = npmJson.time[latest];
|
|
2517
|
+
npmYear = new Date(timeStr).getFullYear();
|
|
2518
|
+
}
|
|
2519
|
+
} catch (e) {
|
|
2520
|
+
console.log(`Error executing "npm view" - ${e}`);
|
|
2521
|
+
}
|
|
2522
|
+
|
|
2415
2523
|
if (context.packageJson.license === 'MIT') {
|
|
2416
|
-
const
|
|
2417
|
-
|
|
2418
|
-
|
|
2524
|
+
const text = data;
|
|
2525
|
+
const year = new Date().getFullYear();
|
|
2526
|
+
const commitYear = context.lastCommitYear || 0;
|
|
2527
|
+
let licenseYear = 0;
|
|
2528
|
+
let m = text.match(/\d\d\d\d-(\d\d\d\d)/);
|
|
2529
|
+
if (m) {
|
|
2530
|
+
licenseYear = Number(m[1]);
|
|
2531
|
+
} else {
|
|
2532
|
+
m = text.match(/(\d\d\d\d)/);
|
|
2533
|
+
if (m) {
|
|
2534
|
+
licenseYear = Number(m[1]);
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
console.log(`License year ${licenseYear}`);
|
|
2538
|
+
console.log(`Current year ${year}`);
|
|
2539
|
+
console.log(`Commit year ${commitYear}`);
|
|
2540
|
+
console.log(`NPM year ${npmYear}`);
|
|
2541
|
+
|
|
2542
|
+
let valid = (licenseYear === year || licenseYear >= commitYear || licenseYear >=npmYear);
|
|
2543
|
+
if (!valid) {
|
|
2544
|
+
const m = text.match(/(\d\d\d\d)-\d\d\d\d/);
|
|
2419
2545
|
if (m) {
|
|
2420
2546
|
context.errors.push(`[E701] No actual year found in LICENSE. Please add "Copyright (c) ${m[1]}-${year} ${getAuthor(context.packageJson.author)}" at the start of LICENSE`);
|
|
2421
2547
|
} else {
|
|
@@ -2432,12 +2558,38 @@ function checkLicenseFile(context) {
|
|
|
2432
2558
|
});
|
|
2433
2559
|
}
|
|
2434
2560
|
|
|
2561
|
+
// E80x
|
|
2562
|
+
function checkGithubRepo(context) {
|
|
2563
|
+
return new Promise((resolve) => {
|
|
2564
|
+
console.log('\ncheckGithubRepo [E8xx]');
|
|
2565
|
+
|
|
2566
|
+
if (!context.githubApiData.description) {
|
|
2567
|
+
context.errors.push(`[E801] No repository about text found. Please go to "${context.githubUrlOriginal}", press the settings button beside the about title and add the description.`);
|
|
2568
|
+
} else {
|
|
2569
|
+
context.checks.push('Github repository about found.');
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
if (!context.githubApiData.topics || context.githubApiData.topics.length === 0) {
|
|
2573
|
+
context.errors.push(`[E802] No topics found in the repository. Please go to "${context.githubUrlOriginal}", press the settings button beside the about title and add some topics.`);
|
|
2574
|
+
} else {
|
|
2575
|
+
context.checks.push('Github repository about found.');
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
if (context.githubApiData.archived) {
|
|
2579
|
+
context.errors.push(`[E803] Archived repositories are not allowed.`);
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2582
|
+
// max E803 - limited to 849
|
|
2583
|
+
resolve(context);
|
|
2584
|
+
});
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2435
2587
|
function paddingNum(num) {
|
|
2436
2588
|
if (num >= 10) return num;
|
|
2437
2589
|
return '0' + num;
|
|
2438
2590
|
}
|
|
2439
2591
|
|
|
2440
|
-
//
|
|
2592
|
+
// E85x
|
|
2441
2593
|
function checkNpmIgnore(context) {
|
|
2442
2594
|
const checkFiles = [
|
|
2443
2595
|
'node_modules/',
|
|
@@ -2467,14 +2619,22 @@ function checkNpmIgnore(context) {
|
|
|
2467
2619
|
];
|
|
2468
2620
|
|
|
2469
2621
|
// https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/.npmignore
|
|
2470
|
-
console.log('\checkNpmIgnore [
|
|
2622
|
+
console.log('\checkNpmIgnore [E85x]');
|
|
2471
2623
|
if (context.packageJson.files && context.packageJson.files.length) {
|
|
2624
|
+
if (context.filesList.includes('.npmignore')) {
|
|
2625
|
+
context.warnings.push(`[E851] .npmignore found but "files" is used at package.json. Please remove .npmignore.`);
|
|
2626
|
+
} else {
|
|
2627
|
+
context.checks.push('package.json "files" already used.');
|
|
2628
|
+
}
|
|
2472
2629
|
return Promise.resolve(context);
|
|
2473
2630
|
}
|
|
2474
2631
|
|
|
2632
|
+
// package.json files section is NOT used
|
|
2475
2633
|
if (!context.filesList.includes('.npmignore')) {
|
|
2476
|
-
context.warnings.push(`[
|
|
2634
|
+
context.warnings.push(`[E852] .npmignore not found`);
|
|
2477
2635
|
} else {
|
|
2636
|
+
context.warnings.push(`[W853] .npmignore found - consider using package.json object "files" instead.`);
|
|
2637
|
+
|
|
2478
2638
|
const rules = (context['/.npmignore'] || '').split('\n').map(line => line.trim().replace('\r', '')).filter(line => line);
|
|
2479
2639
|
let tooComplexToCheck = false;
|
|
2480
2640
|
rules.forEach((name, i) => {
|
|
@@ -2493,11 +2653,11 @@ function checkNpmIgnore(context) {
|
|
|
2493
2653
|
|
|
2494
2654
|
// There's no need to put node_modules in `.npmignore`. npm will never publish node_modules in the package, except if one of the modules is explicitly mentioned in bundledDependencies.
|
|
2495
2655
|
/*if (!rules.includes('node_modules') && !rules.includes('/node_modules') && !rules.includes('/node_modules/*') && !rules.includes('node_modules/*')) {
|
|
2496
|
-
!check && context.errors.push(`[
|
|
2656
|
+
!check && context.errors.push(`[E854] node_modules not found in `.npmignore``);
|
|
2497
2657
|
}*/
|
|
2498
2658
|
if (!tooComplexToCheck) {
|
|
2499
2659
|
if (!rules.includes('iob_npm.done') && !rules.includes('/iob_npm.done')) {
|
|
2500
|
-
!check && context.errors.push(`[
|
|
2660
|
+
!check && context.errors.push(`[E853] iob_npm.done not found in .npmignore`);
|
|
2501
2661
|
}
|
|
2502
2662
|
|
|
2503
2663
|
checkFiles.forEach((file, i) => {
|
|
@@ -2511,7 +2671,7 @@ function checkNpmIgnore(context) {
|
|
|
2511
2671
|
}
|
|
2512
2672
|
});
|
|
2513
2673
|
|
|
2514
|
-
!check && context.errors.push(`[E8${paddingNum(i +
|
|
2674
|
+
!check && context.errors.push(`[E8${paddingNum(i + 61)}] file ${file} found in repository, but not found in .npmignore`);
|
|
2515
2675
|
}
|
|
2516
2676
|
});
|
|
2517
2677
|
}
|
|
@@ -2631,6 +2791,7 @@ function check(request, ctx, callback) {
|
|
|
2631
2791
|
})
|
|
2632
2792
|
.catch(err => {
|
|
2633
2793
|
console.error(`GLOBAL ERROR: ${err.toString()}, ${JSON.stringify(err)}`);
|
|
2794
|
+
context.errors.push(`[E999] GLOBAL ERROR: ${err.toString()}, ${JSON.stringify(err)}`);
|
|
2634
2795
|
|
|
2635
2796
|
return callback(null, makeResponse(200, {
|
|
2636
2797
|
result: 'Errors found',
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.7.0",
|
|
3
3
|
"name": "@iobroker/repochecker",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"axios": "^1.7.2",
|
|
6
6
|
"compare-versions": "^6.1.0",
|
|
7
7
|
"image-size": "^1.1.1",
|
|
8
|
-
"unzipper": "^0.
|
|
8
|
+
"unzipper": "^0.12.1",
|
|
9
9
|
"json5": "^2.2.3"
|
|
10
10
|
},
|
|
11
11
|
"publishConfig": {
|