@iobroker/repochecker 2.6.1 → 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 +13 -0
- package/doc/issues.json +37 -1
- package/index.js +235 -102
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,6 +20,19 @@ 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
|
+
|
|
23
36
|
### 2.6.1 (2024-06-24)
|
|
24
37
|
* (mcm1957) Check "[W156] Adapter should support admin 5 UI (jsonConfig)" checks for reactUi now.
|
|
25
38
|
|
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
|
},
|
|
@@ -617,9 +647,15 @@
|
|
|
617
647
|
"W522": {
|
|
618
648
|
"title": "Please consider migrating to admin 5 UI (jsonConfig)."
|
|
619
649
|
},
|
|
650
|
+
"W606": {
|
|
651
|
+
"title": "Could not retrieve timestamp of LATEST revision at npm."
|
|
652
|
+
},
|
|
620
653
|
"W801": {
|
|
621
654
|
"title": ".npmignore not found"
|
|
622
655
|
},
|
|
656
|
+
"W853": {
|
|
657
|
+
"title": ".npmignore found - consider using package.json object `files` instead."
|
|
658
|
+
},
|
|
623
659
|
"W901": {
|
|
624
660
|
"title": ".gitignore not found"
|
|
625
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) {
|
|
@@ -1382,6 +1396,8 @@ function checkIOPackageJson(context) {
|
|
|
1382
1396
|
|
|
1383
1397
|
if (Object.keys(context.ioPackageJson.common.news).length > 20) {
|
|
1384
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.');
|
|
1385
1401
|
}
|
|
1386
1402
|
|
|
1387
1403
|
Object.keys(context.ioPackageJson.common.news).forEach(version => {
|
|
@@ -1729,6 +1745,20 @@ function checkNpm(context) {
|
|
|
1729
1745
|
}
|
|
1730
1746
|
}
|
|
1731
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
|
+
}
|
|
1732
1762
|
return context;
|
|
1733
1763
|
// max number is E202
|
|
1734
1764
|
});
|
|
@@ -1743,43 +1773,44 @@ function checkTests(context) {
|
|
|
1743
1773
|
return Promise.resolve(context);
|
|
1744
1774
|
}
|
|
1745
1775
|
|
|
1746
|
-
const travisURL = `${context.githubUrlOriginal.replace('github.com', 'api.travis-ci.org')}.png`;
|
|
1747
|
-
|
|
1748
|
-
return axios(travisURL)
|
|
1749
|
-
.then(response => {
|
|
1750
|
-
if (!response.data) {
|
|
1751
|
-
context.errors.push('[E300] Not found on travis. Please setup travis or use github actions (preferred)');
|
|
1752
|
-
return context;
|
|
1753
|
-
}
|
|
1754
|
-
if (!response.headers || !response.headers['content-disposition']) {
|
|
1755
|
-
context.errors.push('[E300] Not found on travis. Please setup travis or use github actions (preferred)');
|
|
1756
|
-
return context;
|
|
1757
|
-
}
|
|
1758
|
-
// inline; filename="passing.png"
|
|
1759
|
-
const m = response.headers['content-disposition'].match(/filename="(.+)"$/);
|
|
1760
|
-
if (!m) {
|
|
1761
|
-
context.errors.push('[E300] Not found on travis. Please setup travis or use github actions (preferred)');
|
|
1762
|
-
return context;
|
|
1763
|
-
}
|
|
1764
|
-
|
|
1765
|
-
if (m[1] === 'unknown.png') {
|
|
1766
|
-
context.errors.push('[E300] Not found on travis. Please setup travis or use github actions (preferred)');
|
|
1767
|
-
return context;
|
|
1768
|
-
}
|
|
1769
|
-
|
|
1770
|
-
context.checks.push('Found on travis-ci');
|
|
1771
|
-
|
|
1772
|
-
context.warnings.push('[W302] Use github actions instead of travis-ci');
|
|
1773
|
-
|
|
1774
|
-
if (m[1] !== 'passing.png') {
|
|
1775
|
-
context.errors.push('[E301] Tests on Travis-ci.org are broken. Please fix.');
|
|
1776
|
-
} else {
|
|
1777
|
-
context.checks.push('Tests are OK on travis-ci');
|
|
1778
|
-
}
|
|
1779
|
-
|
|
1780
|
-
return context;
|
|
1781
|
-
// max number is E302
|
|
1782
|
-
});
|
|
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);
|
|
1783
1814
|
}
|
|
1784
1815
|
|
|
1785
1816
|
// E4xx
|
|
@@ -2062,6 +2093,7 @@ function checkCode(context) {
|
|
|
2062
2093
|
'admin/blockly.js',
|
|
2063
2094
|
|
|
2064
2095
|
'src-admin/package.json', // check if react is used
|
|
2096
|
+
'src-widgets/package.json', // check if react is used
|
|
2065
2097
|
'src/package.json', // check if react is used
|
|
2066
2098
|
];
|
|
2067
2099
|
allowedLanguages.forEach(lang =>
|
|
@@ -2150,15 +2182,39 @@ function checkCode(context) {
|
|
|
2150
2182
|
})
|
|
2151
2183
|
.then(context => {
|
|
2152
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
|
+
}
|
|
2153
2195
|
if (context['/src-admin/package.json']) {
|
|
2154
2196
|
//console.log('"src-admin/package.json" exists');
|
|
2155
2197
|
let packageJson = JSON.parse(context['/src-admin/package.json']);
|
|
2156
2198
|
if (packageJson.devDependencies && packageJson.devDependencies['@iobroker/adapter-react-v5'] ){
|
|
2157
|
-
|
|
2199
|
+
console.log('REACT detected at src-admin/package devDependencies');
|
|
2158
2200
|
usesReact = true;
|
|
2159
2201
|
}
|
|
2160
2202
|
if (packageJson.dependencies && packageJson.dependencies['@iobroker/adapter-react-v5'] ){
|
|
2161
|
-
|
|
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');
|
|
2162
2218
|
usesReact = true;
|
|
2163
2219
|
}
|
|
2164
2220
|
}
|
|
@@ -2174,9 +2230,6 @@ function checkCode(context) {
|
|
|
2174
2230
|
usesReact = true;
|
|
2175
2231
|
}
|
|
2176
2232
|
}
|
|
2177
|
-
if (context.packageJson.devDependencies && context.packageJson.devDependencies['@iobroker/adapter-react'] ){
|
|
2178
|
-
usesReact = true;
|
|
2179
|
-
}
|
|
2180
2233
|
|
|
2181
2234
|
if (! usesReact && !context.ioPackageJson.common.noConfig &&
|
|
2182
2235
|
(!context.ioPackageJson.common.adminUI ||
|
|
@@ -2278,6 +2331,10 @@ function checkCode(context) {
|
|
|
2278
2331
|
context.errors.push('[E503] "iob_npm.done" found in repo! Remove that file');
|
|
2279
2332
|
}
|
|
2280
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
|
+
|
|
2281
2338
|
if (context['/.travis.yml']) {
|
|
2282
2339
|
context.hasTravis = true;
|
|
2283
2340
|
}
|
|
@@ -2301,10 +2358,12 @@ function checkCode(context) {
|
|
|
2301
2358
|
|
|
2302
2359
|
if (context.packageJson.main && context.packageJson.main.endsWith('.js')) {
|
|
2303
2360
|
if (!context['/' + context.packageJson.main]) {
|
|
2304
|
-
|
|
2361
|
+
if (!context.ioPackageJson.common.nogit) {
|
|
2362
|
+
context.errors.push(`[E519] "${context.packageJson.main}" found in package.json, but not found as file`);
|
|
2363
|
+
}
|
|
2305
2364
|
} else {
|
|
2306
2365
|
if (context['/' + context.packageJson.main].includes('setInterval(') && !context[`/${context.packageJson.main}`].includes('clearInterval(')) {
|
|
2307
|
-
if (context.ioPackageJson.compact) {
|
|
2366
|
+
if (context.ioPackageJson.common.compact) {
|
|
2308
2367
|
// if compact mode supported, it is critical
|
|
2309
2368
|
context.errors.push(`[E504] setInterval found in "${context.packageJson.main}", but no clearInterval detected`);
|
|
2310
2369
|
} else {
|
|
@@ -2312,7 +2371,7 @@ function checkCode(context) {
|
|
|
2312
2371
|
}
|
|
2313
2372
|
}
|
|
2314
2373
|
if (context['/' + context.packageJson.main].includes('setTimeout(') && !context['/' + context.packageJson.main].includes('clearTimeout(')) {
|
|
2315
|
-
if (context.ioPackageJson.compact) {
|
|
2374
|
+
if (context.ioPackageJson.common.compact) {
|
|
2316
2375
|
// if compact mode supported, it is critical
|
|
2317
2376
|
context.errors.push(`[E505] setTimeout found in "${context.packageJson.main}", but no clearTimeout detected`);
|
|
2318
2377
|
} else {
|
|
@@ -2342,38 +2401,12 @@ function checkCommits(context) {
|
|
|
2342
2401
|
.then(data => {
|
|
2343
2402
|
const m = data.match(/Commits on [\w\s\d]+, (\d\d\d\d)/);
|
|
2344
2403
|
if (m) {
|
|
2345
|
-
context.lastCommitYear = m[1];
|
|
2404
|
+
context.lastCommitYear = Number(m[1]);
|
|
2346
2405
|
}
|
|
2347
2406
|
return context;
|
|
2348
2407
|
});
|
|
2349
2408
|
}
|
|
2350
2409
|
|
|
2351
|
-
// E8xx
|
|
2352
|
-
function checkGithubRepo(context) {
|
|
2353
|
-
return new Promise((resolve) => {
|
|
2354
|
-
console.log('\ncheckGithubRepo [E8xx]');
|
|
2355
|
-
|
|
2356
|
-
if (!context.githubApiData.description) {
|
|
2357
|
-
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.`);
|
|
2358
|
-
} else {
|
|
2359
|
-
context.checks.push('Github repository about found.');
|
|
2360
|
-
}
|
|
2361
|
-
|
|
2362
|
-
if (!context.githubApiData.topics || context.githubApiData.topics.length === 0) {
|
|
2363
|
-
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.`);
|
|
2364
|
-
} else {
|
|
2365
|
-
context.checks.push('Github repository about found.');
|
|
2366
|
-
}
|
|
2367
|
-
|
|
2368
|
-
if (context.githubApiData.archived) {
|
|
2369
|
-
context.errors.push(`[E803] Archived repositories are not allowed.`);
|
|
2370
|
-
}
|
|
2371
|
-
|
|
2372
|
-
// max E803
|
|
2373
|
-
resolve(context);
|
|
2374
|
-
});
|
|
2375
|
-
}
|
|
2376
|
-
|
|
2377
2410
|
// E6xx
|
|
2378
2411
|
function checkReadme(context) {
|
|
2379
2412
|
// https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/README.md
|
|
@@ -2398,15 +2431,48 @@ function checkReadme(context) {
|
|
|
2398
2431
|
}
|
|
2399
2432
|
}
|
|
2400
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
|
+
|
|
2401
2450
|
const pos = data.indexOf('## License');
|
|
2402
2451
|
if (pos === -1) {
|
|
2403
2452
|
context.errors.push('[E604] No "## License" found in README.md');
|
|
2404
2453
|
} else {
|
|
2405
2454
|
context.checks.push('## License found in README.md');
|
|
2406
2455
|
const text = data.substring(pos);
|
|
2407
|
-
const year = new Date().getFullYear()
|
|
2408
|
-
|
|
2409
|
-
|
|
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/);
|
|
2410
2476
|
if (m) {
|
|
2411
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`);
|
|
2412
2478
|
} else {
|
|
@@ -2440,10 +2506,42 @@ function checkLicenseFile(context) {
|
|
|
2440
2506
|
} else {
|
|
2441
2507
|
context.checks.push('LICENSE file found');
|
|
2442
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
|
+
|
|
2443
2523
|
if (context.packageJson.license === 'MIT') {
|
|
2444
|
-
const
|
|
2445
|
-
|
|
2446
|
-
|
|
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/);
|
|
2447
2545
|
if (m) {
|
|
2448
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`);
|
|
2449
2547
|
} else {
|
|
@@ -2460,12 +2558,38 @@ function checkLicenseFile(context) {
|
|
|
2460
2558
|
});
|
|
2461
2559
|
}
|
|
2462
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
|
+
|
|
2463
2587
|
function paddingNum(num) {
|
|
2464
2588
|
if (num >= 10) return num;
|
|
2465
2589
|
return '0' + num;
|
|
2466
2590
|
}
|
|
2467
2591
|
|
|
2468
|
-
//
|
|
2592
|
+
// E85x
|
|
2469
2593
|
function checkNpmIgnore(context) {
|
|
2470
2594
|
const checkFiles = [
|
|
2471
2595
|
'node_modules/',
|
|
@@ -2495,14 +2619,22 @@ function checkNpmIgnore(context) {
|
|
|
2495
2619
|
];
|
|
2496
2620
|
|
|
2497
2621
|
// https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/.npmignore
|
|
2498
|
-
console.log('\checkNpmIgnore [
|
|
2622
|
+
console.log('\checkNpmIgnore [E85x]');
|
|
2499
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
|
+
}
|
|
2500
2629
|
return Promise.resolve(context);
|
|
2501
2630
|
}
|
|
2502
2631
|
|
|
2632
|
+
// package.json files section is NOT used
|
|
2503
2633
|
if (!context.filesList.includes('.npmignore')) {
|
|
2504
|
-
context.warnings.push(`[
|
|
2634
|
+
context.warnings.push(`[E852] .npmignore not found`);
|
|
2505
2635
|
} else {
|
|
2636
|
+
context.warnings.push(`[W853] .npmignore found - consider using package.json object "files" instead.`);
|
|
2637
|
+
|
|
2506
2638
|
const rules = (context['/.npmignore'] || '').split('\n').map(line => line.trim().replace('\r', '')).filter(line => line);
|
|
2507
2639
|
let tooComplexToCheck = false;
|
|
2508
2640
|
rules.forEach((name, i) => {
|
|
@@ -2521,11 +2653,11 @@ function checkNpmIgnore(context) {
|
|
|
2521
2653
|
|
|
2522
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.
|
|
2523
2655
|
/*if (!rules.includes('node_modules') && !rules.includes('/node_modules') && !rules.includes('/node_modules/*') && !rules.includes('node_modules/*')) {
|
|
2524
|
-
!check && context.errors.push(`[
|
|
2656
|
+
!check && context.errors.push(`[E854] node_modules not found in `.npmignore``);
|
|
2525
2657
|
}*/
|
|
2526
2658
|
if (!tooComplexToCheck) {
|
|
2527
2659
|
if (!rules.includes('iob_npm.done') && !rules.includes('/iob_npm.done')) {
|
|
2528
|
-
!check && context.errors.push(`[
|
|
2660
|
+
!check && context.errors.push(`[E853] iob_npm.done not found in .npmignore`);
|
|
2529
2661
|
}
|
|
2530
2662
|
|
|
2531
2663
|
checkFiles.forEach((file, i) => {
|
|
@@ -2539,7 +2671,7 @@ function checkNpmIgnore(context) {
|
|
|
2539
2671
|
}
|
|
2540
2672
|
});
|
|
2541
2673
|
|
|
2542
|
-
!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`);
|
|
2543
2675
|
}
|
|
2544
2676
|
});
|
|
2545
2677
|
}
|
|
@@ -2659,6 +2791,7 @@ function check(request, ctx, callback) {
|
|
|
2659
2791
|
})
|
|
2660
2792
|
.catch(err => {
|
|
2661
2793
|
console.error(`GLOBAL ERROR: ${err.toString()}, ${JSON.stringify(err)}`);
|
|
2794
|
+
context.errors.push(`[E999] GLOBAL ERROR: ${err.toString()}, ${JSON.stringify(err)}`);
|
|
2662
2795
|
|
|
2663
2796
|
return callback(null, makeResponse(200, {
|
|
2664
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": {
|