@iobroker/repochecker 5.0.0-alpha.0 → 5.0.0-alpha.2
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 +19 -3
- package/doc/issues.json +10 -0
- package/index.js +2 -1
- package/lib/M0000_PackageJson.js +138 -33
- package/lib/M1000_IOPackageJson.js +22 -4
- package/lib/M2000_Npm.js +47 -4
- package/lib/M4000_Repository.js +15 -8
- package/lib/M5000_Code.js +43 -2
- package/lib/M6000_Readme.js +52 -16
- package/lib/M7000_License.js +38 -11
- package/lib/M9000_GitNpmIgnore.js +6 -14
- package/lib/common.js +9 -1
- package/lib/config.js +1 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -31,10 +31,26 @@ npx @iobroker/repochecker https://github.com/ioBroker/ioBroker.javascript --loca
|
|
|
31
31
|
Placeholder for the next version (at the beginning of the line):
|
|
32
32
|
### **WORK IN PROGRESS**
|
|
33
33
|
-->
|
|
34
|
-
### 5.0.0-alpha.
|
|
34
|
+
### 5.0.0-alpha.2 (2025-10-02)
|
|
35
|
+
- (mcm1957) Suppress W6010 if adapter not yet published at npm. [#567]
|
|
36
|
+
- (@copilot) Added check for deprecated common.jsonConfig property - warns if adminUI exists (W1109), errors if adminUI missing (E1109)
|
|
37
|
+
- (@copilot) Added check (W0063) for unneeded devDependencies when @iobroker/testing >= 5.1.1 is installed
|
|
38
|
+
- (@copilot) Added check for conflicting JavaScript file extensions (.js, .cjs, .mjs) in the same directory (E5034)
|
|
39
|
+
- (@copilot) Improved copyright year check to find all years in multiple copyright entries and use the newest one
|
|
40
|
+
- (@copilot) Added check for missing trailing spaces in multiple copyright lines (W6009, W7003)
|
|
41
|
+
- (mcm1957) Strict mode requirements have been loosend at schema validation.
|
|
42
|
+
- (mcm1957) Do not log missing jsonConfig schema at vscode is no jsonConfig is used. [#548]
|
|
43
|
+
- (mcm1957) News entry at io-package.json is no longer required for alpha release. [#532]
|
|
44
|
+
- (mcm1957) Report missing README changelog for alpha releases as suggestion only. [#533]
|
|
45
|
+
- (mcm1957) Release of @iobroker/testing has been updated to 5.1.1.
|
|
46
|
+
- (mcm1957) Text for dependency update suggestion has been changed to make more clear that this should be really done. [#515]
|
|
47
|
+
- (mcm1957) Suggestion to migrate to jsonConfig has been changed to suggest jsonConfig or react based UI. [#524]
|
|
48
|
+
- (mcm1957) Alpha release are no longer reported as missing at npm / latest. [#425]
|
|
49
|
+
- (mcm1957) Suggestions to avoid fixed dependencies has been compressed to a maximum of one suggestion even if multiple ffixed dependencies exist [#512].
|
|
50
|
+
- (mcm1957) E4033 is always an error [#541].
|
|
51
|
+
- (mcm1957) Empty adaptername in finding has been fixed [#549].
|
|
52
|
+
- (mcm1957) Text for 9006 has been changed (.commitinfo hint) [#542].
|
|
35
53
|
- (@copilot) Renumbered all error, warning and suggestion codes from 3-digit to 4-digit format according to new numbering system
|
|
36
|
-
|
|
37
|
-
### 4.3.0-alpha.0 (2025-09-29)
|
|
38
54
|
- (@copilot) Added version format validation check (E061) for invalid semver format according to ioBroker requirements
|
|
39
55
|
- (@copilot) Added structured GitHub issue templates for bug reports, false positives, new checks, check changes, and enhancements
|
|
40
56
|
- (@copilot) Fixed deprecated function checking for adapter methods called outside class context
|
package/doc/issues.json
CHANGED
|
@@ -422,9 +422,19 @@
|
|
|
422
422
|
"E606": {
|
|
423
423
|
"title": "Current adapter version ${context.packageJson.version} not found in README.md"
|
|
424
424
|
},
|
|
425
|
+
"W609": {
|
|
426
|
+
"title": "Multiple copyright lines in README.md missing trailing spaces",
|
|
427
|
+
"explanation": "When a LICENSE section in README.md contains multiple copyright lines, each line (except the last) must end with two spaces. In Markdown, two trailing spaces create a line break, ensuring proper formatting of multiple copyright holders.",
|
|
428
|
+
"resolving": "Add two spaces at the end of each copyright line except the last one in the LICENSE section of README.md."
|
|
429
|
+
},
|
|
425
430
|
"E701": {
|
|
426
431
|
"title": "NO LICENSE file found"
|
|
427
432
|
},
|
|
433
|
+
"W703": {
|
|
434
|
+
"title": "Multiple copyright lines in LICENSE file missing trailing spaces",
|
|
435
|
+
"explanation": "When the LICENSE file contains multiple copyright lines, each line (except the last) must end with two spaces. In Markdown-formatted LICENSE files, two trailing spaces create a line break, ensuring proper formatting of multiple copyright holders.",
|
|
436
|
+
"resolving": "Add two spaces at the end of each copyright line except the last one in the LICENSE file."
|
|
437
|
+
},
|
|
428
438
|
"E801": {
|
|
429
439
|
"title": "No repository about text found. Please go to GitHub, press the settings button beside the about title and add the description."
|
|
430
440
|
},
|
package/index.js
CHANGED
|
@@ -77,7 +77,7 @@ function getGithubApiData(context) {
|
|
|
77
77
|
.get(context.githubUrlApi)
|
|
78
78
|
.then(response => {
|
|
79
79
|
context.githubApiData = response.data;
|
|
80
|
-
|
|
80
|
+
common.debug(`API Data: ${JSON.stringify(context.githubApiData)}`);
|
|
81
81
|
|
|
82
82
|
if (!context.branch) {
|
|
83
83
|
context.branch = context.githubApiData.default_branch; // main vs. master
|
|
@@ -147,6 +147,7 @@ function check(request, ctx, callback) {
|
|
|
147
147
|
.then(context => M8000_Github.getCommitInfos(context))
|
|
148
148
|
.then(context => M0000_PackageJson.getPackageJson(context))
|
|
149
149
|
.then(context => M1000_IOPackageJson.getIOPackageJson(context))
|
|
150
|
+
.then(context => M2000_Npm.getNpm(context))
|
|
150
151
|
.then(context => config.updateConfig(context))
|
|
151
152
|
.then(context => config.logEnvironment(context))
|
|
152
153
|
.then(context => M0000_PackageJson.checkPackageJson(context))
|
package/lib/M0000_PackageJson.js
CHANGED
|
@@ -24,6 +24,7 @@ const dependenciesPackageJson = {
|
|
|
24
24
|
'@iobroker/adapter-core': {
|
|
25
25
|
required: '3.2.3',
|
|
26
26
|
recommended: '3.3.2',
|
|
27
|
+
actual: '3.3.2',
|
|
27
28
|
onlyWWW: false,
|
|
28
29
|
},
|
|
29
30
|
};
|
|
@@ -33,19 +34,22 @@ const devDependenciesPackageJson = {
|
|
|
33
34
|
'@alcalzone/release-script': {
|
|
34
35
|
required: '3.8.0',
|
|
35
36
|
recommended: '3.8.0',
|
|
37
|
+
actual: '3.8.0',
|
|
36
38
|
optional: true,
|
|
37
39
|
suggested: true,
|
|
38
40
|
},
|
|
39
41
|
'@iobroker/adapter-dev': {
|
|
40
42
|
required: '1.3.0',
|
|
41
43
|
recommended: '1.4.0',
|
|
44
|
+
actual: '1.5.0',
|
|
42
45
|
onlyWWW: false,
|
|
43
46
|
optional: true,
|
|
44
47
|
suggested: true,
|
|
45
48
|
},
|
|
46
49
|
'@iobroker/eslint-config': {
|
|
47
50
|
required: '2.0.0',
|
|
48
|
-
recommended: '2.
|
|
51
|
+
recommended: '2.2.0',
|
|
52
|
+
actual: '2.2.0',
|
|
49
53
|
onlyWWW: false,
|
|
50
54
|
optional: true,
|
|
51
55
|
suggested: true,
|
|
@@ -53,12 +57,14 @@ const devDependenciesPackageJson = {
|
|
|
53
57
|
'@iobroker/legacy-testing': {
|
|
54
58
|
required: '2.0.2',
|
|
55
59
|
recommended: '2.0.2',
|
|
60
|
+
actual: '2.0.2',
|
|
56
61
|
onlyWWW: false,
|
|
57
62
|
optional: true,
|
|
58
63
|
},
|
|
59
64
|
'@iobroker/testing': {
|
|
60
65
|
required: '4.1.3',
|
|
61
|
-
recommended: '5.1.
|
|
66
|
+
recommended: '5.1.1',
|
|
67
|
+
actual: '5.1.1',
|
|
62
68
|
onlyWWW: false,
|
|
63
69
|
alternatives: ['@iobroker/legacy-testing'],
|
|
64
70
|
},
|
|
@@ -292,6 +298,24 @@ async function getPackageJson(context) {
|
|
|
292
298
|
context.errors.push(`[E0001] Cannot parse package.json: ${e}`);
|
|
293
299
|
}
|
|
294
300
|
}
|
|
301
|
+
|
|
302
|
+
// calculate adapternam here as it is needed by others
|
|
303
|
+
|
|
304
|
+
let m;
|
|
305
|
+
m = context.githubApiData.name.match(/^ioBroker\.(.*)$/);
|
|
306
|
+
if (!m || !m[1]) {
|
|
307
|
+
m = context.githubApiData.name.match(/^iobroker\.(.*)$/);
|
|
308
|
+
}
|
|
309
|
+
let adapterName = '';
|
|
310
|
+
if (!m || !m[1]) {
|
|
311
|
+
context.errors.push(`[E0004] No valid adapter name found in URL: ${context.githubUrlOriginal}`);
|
|
312
|
+
} else {
|
|
313
|
+
context.checks.push('Adapter name found in the URL');
|
|
314
|
+
adapterName = m[1].replace(/\/master$/, '').replace(/\/main$/, '');
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
context.adapterName = adapterName !== '' ? adapterName : 'unknown';
|
|
318
|
+
|
|
295
319
|
return context;
|
|
296
320
|
}
|
|
297
321
|
|
|
@@ -300,13 +324,16 @@ async function checkPackageJson(context) {
|
|
|
300
324
|
|
|
301
325
|
let passed;
|
|
302
326
|
|
|
303
|
-
if (!context.githubUrlOriginal.match(/\/iobroker\./i)) {
|
|
327
|
+
//if (!context.githubUrlOriginal.match(/\/iobroker\./i)) {
|
|
328
|
+
//console.log(`DEBUG: ${context.githubApiData.name}`)
|
|
329
|
+
if (!context.githubApiData.name.match(/^iobroker\./i)) {
|
|
304
330
|
context.errors.push('[E0002] No "ioBroker." found in the name of repository');
|
|
305
331
|
} else {
|
|
306
332
|
context.checks.push('"ioBroker" was found in the name of repository');
|
|
307
333
|
}
|
|
308
334
|
|
|
309
|
-
if (context.githubUrlOriginal.includes('/iobroker.')) {
|
|
335
|
+
//if (context.githubUrlOriginal.includes('/iobroker.')) {
|
|
336
|
+
if (context.githubApiData.name.match(/^iobroker\./)) {
|
|
310
337
|
context.errors.push(
|
|
311
338
|
'[E0003] Repository must have name ioBroker.adaptername, but now io"b"roker is in lowercase',
|
|
312
339
|
);
|
|
@@ -314,16 +341,23 @@ async function checkPackageJson(context) {
|
|
|
314
341
|
context.checks.push('Repository has name ioBroker.adaptername (not iobroker.adaptername)');
|
|
315
342
|
}
|
|
316
343
|
|
|
317
|
-
const m = context.githubUrlOriginal.match(/\/ioBroker\.(.*)$/);
|
|
318
|
-
let
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
344
|
+
// //const m = context.githubUrlOriginal.match(/\/ioBroker\.(.*)$/);
|
|
345
|
+
// let m;
|
|
346
|
+
// m = context.githubApiData.name.match(/^ioBroker\.(.*)$/);
|
|
347
|
+
// if (!m || !m[1]) {
|
|
348
|
+
// m = context.githubApiData.name.match(/^iobroker\.(.*)$/);
|
|
349
|
+
// }
|
|
350
|
+
// let adapterName = '';
|
|
351
|
+
// if (!m || !m[1]) {
|
|
352
|
+
// context.errors.push(`[E0004] No valid adapter name found in URL: ${context.githubUrlOriginal}`);
|
|
353
|
+
// } else {
|
|
354
|
+
// context.checks.push('Adapter name found in the URL');
|
|
355
|
+
// adapterName = m[1].replace(/\/master$/, '').replace(/\/main$/, '');
|
|
356
|
+
// }
|
|
357
|
+
|
|
358
|
+
// context.adapterName = adapterName !== '' ? adapterName : 'unknown';
|
|
325
359
|
|
|
326
|
-
|
|
360
|
+
const adapterName = context.adapterName;
|
|
327
361
|
|
|
328
362
|
if (adapterName.match(/[A-Z]/)) {
|
|
329
363
|
context.errors.push('[E0005] Adapter name must be lowercase');
|
|
@@ -460,12 +494,12 @@ async function checkPackageJson(context) {
|
|
|
460
494
|
context.checks.push('Repository found in package.json');
|
|
461
495
|
|
|
462
496
|
const allowedRepoUrls = [
|
|
463
|
-
context.githubApiData.html_url, // https://github.com/klein0r/ioBroker.luftdaten
|
|
464
|
-
`git+${context.githubApiData.html_url}`, // git+https://github.com/klein0r/ioBroker.luftdaten
|
|
465
|
-
context.githubApiData.git_url, // git://github.com/klein0r/ioBroker.luftdaten.git
|
|
466
|
-
context.githubApiData.ssh_url, // git@github.com:klein0r/ioBroker.luftdaten.git
|
|
467
|
-
context.githubApiData.clone_url, // https://github.com/klein0r/ioBroker.luftdaten.git
|
|
468
|
-
`git+${context.githubApiData.clone_url}`, // git+https://github.com/klein0r/ioBroker.luftdaten.git
|
|
497
|
+
context.githubApiData.html_url.replace('/iobroker.', '/ioBroker.'), // https://github.com/klein0r/ioBroker.luftdaten
|
|
498
|
+
`git+${context.githubApiData.html_url.replace('/iobroker.', '/ioBroker.')}`, // git+https://github.com/klein0r/ioBroker.luftdaten
|
|
499
|
+
context.githubApiData.git_url.replace('/iobroker.', '/ioBroker.'), // git://github.com/klein0r/ioBroker.luftdaten.git
|
|
500
|
+
context.githubApiData.ssh_url.replace('/iobroker.', '/ioBroker.'), // git@github.com:klein0r/ioBroker.luftdaten.git
|
|
501
|
+
context.githubApiData.clone_url.replace('/iobroker.', '/ioBroker.'), // https://github.com/klein0r/ioBroker.luftdaten.git
|
|
502
|
+
`git+${context.githubApiData.clone_url.replace('/iobroker.', '/ioBroker.')}`, // git+https://github.com/klein0r/ioBroker.luftdaten.git
|
|
469
503
|
];
|
|
470
504
|
|
|
471
505
|
// https://docs.npmjs.com/cli/v7/configuring-npm/package-json#repository
|
|
@@ -480,7 +514,7 @@ async function checkPackageJson(context) {
|
|
|
480
514
|
|
|
481
515
|
if (!allowedRepoUrls.includes(context.packageJson.repository.url)) {
|
|
482
516
|
context.errors.push(
|
|
483
|
-
`[E0019] Invalid repository URL in package.json: ${context.packageJson.repository.url}. Expected: ${context.githubApiData.
|
|
517
|
+
`[E0019] Invalid repository URL in package.json: ${context.packageJson.repository.url}. Expected: ${context.githubApiData.clone_url}`,
|
|
484
518
|
);
|
|
485
519
|
} else {
|
|
486
520
|
context.checks.push('Repository URL is valid in package.json');
|
|
@@ -488,7 +522,7 @@ async function checkPackageJson(context) {
|
|
|
488
522
|
} else if (context.packageJson.repository && typeof context.packageJson.repository === 'string') {
|
|
489
523
|
if (!allowedRepoUrls.includes(context.packageJson.repository)) {
|
|
490
524
|
context.errors.push(
|
|
491
|
-
`[E0019] Invalid repository URL in package.json: ${context.packageJson.repository}. Expected: ${context.githubApiData.
|
|
525
|
+
`[E0019] Invalid repository URL in package.json: ${context.packageJson.repository}. Expected: ${context.githubApiData.clone_url}`,
|
|
492
526
|
);
|
|
493
527
|
} else {
|
|
494
528
|
context.checks.push('Repository URL is valid in package.json');
|
|
@@ -790,6 +824,7 @@ async function checkPackageJson(context) {
|
|
|
790
824
|
|
|
791
825
|
const requiredVersion = dependenciesPackageJson[dependency].required;
|
|
792
826
|
const recommendedVersion = dependenciesPackageJson[dependency].recommended;
|
|
827
|
+
const actualVersion = dependenciesPackageJson[dependency].actual;
|
|
793
828
|
const alternatives = dependenciesPackageJson[dependency].alternatives || [];
|
|
794
829
|
const optional = !!dependenciesPackageJson[dependency].optional;
|
|
795
830
|
const suggested = !!dependenciesPackageJson[dependency].suggested;
|
|
@@ -803,11 +838,15 @@ async function checkPackageJson(context) {
|
|
|
803
838
|
// if dependency exists, version requirements must be met
|
|
804
839
|
if (!compareVersions.compare(dependencyVersion, requiredVersion, '>=')) {
|
|
805
840
|
context.errors.push(
|
|
806
|
-
`[E0033] ${dependency} ${dependencyVersion} specified. ${requiredVersion} is required as minimum, ${
|
|
841
|
+
`[E0033] ${dependency} ${dependencyVersion} specified. ${requiredVersion} is required as minimum, ${actualVersion} (or newer) is current. Please update dependencies at package.json`,
|
|
807
842
|
);
|
|
808
843
|
} else if (!compareVersions.compare(dependencyVersion, recommendedVersion, '>=')) {
|
|
809
844
|
context.warnings.push(
|
|
810
|
-
`[W0034] ${dependency} ${dependencyVersion} specified. ${
|
|
845
|
+
`[W0034] ${dependency} ${dependencyVersion} specified. ${actualVersion} (or newer) is current. Please update dependencies at package.json`,
|
|
846
|
+
);
|
|
847
|
+
} else if (!compareVersions.compare(dependencyVersion, actualVersion, '>=')) {
|
|
848
|
+
context.warnings.push(
|
|
849
|
+
`[S0064] ${dependency} ${dependencyVersion} specified. Newer version ${actualVersion} exists.`,
|
|
811
850
|
);
|
|
812
851
|
} else {
|
|
813
852
|
context.checks.push(`dependency ${dependency} ${dependencyVersion} is ok`);
|
|
@@ -846,6 +885,7 @@ async function checkPackageJson(context) {
|
|
|
846
885
|
|
|
847
886
|
const requiredVersion = devDependenciesPackageJson[dependency].required;
|
|
848
887
|
const recommendedVersion = devDependenciesPackageJson[dependency].recommended;
|
|
888
|
+
const actualVersion = devDependenciesPackageJson[dependency].actual;
|
|
849
889
|
const alternatives = devDependenciesPackageJson[dependency].alternatives || [];
|
|
850
890
|
const optional = !!devDependenciesPackageJson[dependency].optional;
|
|
851
891
|
const suggested = !!devDependenciesPackageJson[dependency].suggested;
|
|
@@ -859,17 +899,21 @@ async function checkPackageJson(context) {
|
|
|
859
899
|
// if dependency exists, version requirements must be met
|
|
860
900
|
if (!compareVersions.compare(dependencyVersion, requiredVersion, '>=')) {
|
|
861
901
|
context.errors.push(
|
|
862
|
-
`[E0036] ${dependency} ${dependencyVersion} specified. ${requiredVersion} is required as minimum, ${
|
|
902
|
+
`[E0036] ${dependency} ${dependencyVersion} specified. ${requiredVersion} is required as minimum, ${actualVersion} (or newer) is current. Please update devDependencies at package.json`,
|
|
863
903
|
);
|
|
864
904
|
} else if (!compareVersions.compare(dependencyVersion, recommendedVersion, '>=')) {
|
|
865
905
|
context.warnings.push(
|
|
866
|
-
`[W0037] ${dependency} ${dependencyVersion} specified. ${
|
|
906
|
+
`[W0037] ${dependency} ${dependencyVersion} specified. ${actualVersion} (or newer) is current. Please update devDependencies at package.json`,
|
|
907
|
+
);
|
|
908
|
+
} else if (!compareVersions.compare(dependencyVersion, actualVersion, '>=')) {
|
|
909
|
+
context.warnings.push(
|
|
910
|
+
`[S0064] ${dependency} ${dependencyVersion} specified. Newer version ${actualVersion} exists.`,
|
|
867
911
|
);
|
|
868
912
|
} else {
|
|
869
913
|
context.checks.push(`devDependency ${dependency} ${dependencyVersion} is ok`);
|
|
870
914
|
}
|
|
871
915
|
} else {
|
|
872
|
-
// if dependency does not
|
|
916
|
+
// if dependency does not exist - check if alternate exists
|
|
873
917
|
let found = '';
|
|
874
918
|
for (const alternative of alternatives) {
|
|
875
919
|
if (context.packageJson.devDependencies[`${alternative}`]) {
|
|
@@ -885,13 +929,58 @@ async function checkPackageJson(context) {
|
|
|
885
929
|
}
|
|
886
930
|
} else {
|
|
887
931
|
context.errors.push(
|
|
888
|
-
`[E0035] No devDependency declared for ${dependency}. Please add "${dependency}":"${
|
|
932
|
+
`[E0035] No devDependency declared for ${dependency}. Please add "${dependency}":"${actualVersion}" to devDependencies at package.json`,
|
|
889
933
|
);
|
|
890
934
|
}
|
|
891
935
|
}
|
|
892
936
|
}
|
|
893
937
|
context.checks.push('required devDependencies have been checked.');
|
|
894
938
|
|
|
939
|
+
// Check for unneeded devDependencies when @iobroker/testing >= 5.1.1 is installed
|
|
940
|
+
if (context.packageJson.devDependencies['@iobroker/testing']) {
|
|
941
|
+
const testingVersion = context.packageJson.devDependencies['@iobroker/testing'].replace(/[\^~]/, '').trim();
|
|
942
|
+
try {
|
|
943
|
+
if (compareVersions.compare(testingVersion, '5.1.1', '>=')) {
|
|
944
|
+
// List of packages that are redundant when @iobroker/testing >= 5.1.1 is installed
|
|
945
|
+
const redundantPackages = [
|
|
946
|
+
'@types/chai',
|
|
947
|
+
'chai',
|
|
948
|
+
'@types/chai-as-promised',
|
|
949
|
+
'chai-as-promised',
|
|
950
|
+
'@types/mocha',
|
|
951
|
+
'mocha',
|
|
952
|
+
'@types/sinon',
|
|
953
|
+
'sinon',
|
|
954
|
+
// '@types/proxyquire',
|
|
955
|
+
// 'proxyquire',
|
|
956
|
+
'@types/sinon-chai',
|
|
957
|
+
'sinon-chai',
|
|
958
|
+
];
|
|
959
|
+
|
|
960
|
+
let pkgs = [];
|
|
961
|
+
for (const pkg of redundantPackages) {
|
|
962
|
+
if (context.packageJson.devDependencies[pkg]) {
|
|
963
|
+
pkgs.push(pkg);
|
|
964
|
+
}
|
|
965
|
+
if (pkgs.length >= 4) {
|
|
966
|
+
context.warnings.push(
|
|
967
|
+
`[W0063] "${pkgs.join(', ')}" are included by "@iobroker/testing". Remove from devDependencies at package.json`,
|
|
968
|
+
);
|
|
969
|
+
pkgs = [];
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
if (pkgs.length) {
|
|
973
|
+
context.warnings.push(
|
|
974
|
+
`[W0063] "${pkgs.join(', ')}" are included in "@iobroker/testing". Remove from devDependencies at package.json`,
|
|
975
|
+
);
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
} catch (e) {
|
|
979
|
+
// Version comparison failed, skip this check
|
|
980
|
+
common.debug(`Could not compare @iobroker/testing version: ${e}`);
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
|
|
895
984
|
const enforcedDependencies = [
|
|
896
985
|
'@iobroker/adapter-core',
|
|
897
986
|
'@alcalzone/release-script',
|
|
@@ -901,6 +990,7 @@ async function checkPackageJson(context) {
|
|
|
901
990
|
'@iobroker/adapter-dev',
|
|
902
991
|
'@iobroker/testing',
|
|
903
992
|
];
|
|
993
|
+
let forcedDependencyFlag = false;
|
|
904
994
|
for (const dependency in context.packageJson.dependencies) {
|
|
905
995
|
const dependencyVersion = context.packageJson.dependencies[dependency];
|
|
906
996
|
if (dependencyVersion.toLowerCase().includes('github.com')) {
|
|
@@ -926,13 +1016,20 @@ async function checkPackageJson(context) {
|
|
|
926
1016
|
`[E0044] dependency must not require a specific version. Use "~1.2.3" or "^1.2.3" syntax. Please update "${dependency}:${context.packageJson.dependencies[dependency]}"`,
|
|
927
1017
|
);
|
|
928
1018
|
} else {
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
1019
|
+
forcedDependencyFlag = true;
|
|
1020
|
+
// context.warnings.push(
|
|
1021
|
+
// `[S0047] dependency should not require a specific version. Use "~1.2.3" or "^1.2.3" syntax. Please update "${dependency}:${context.packageJson.dependencies[dependency]}"`,
|
|
1022
|
+
// );
|
|
932
1023
|
}
|
|
933
1024
|
}
|
|
934
1025
|
}
|
|
1026
|
+
if (forcedDependencyFlag) {
|
|
1027
|
+
context.warnings.push(
|
|
1028
|
+
`[S0047] At least one dependency at package.json requires a specific version. Consider using "~1.2.3" or "^1.2.3" syntax unless freezing dependencies is really desired.`,
|
|
1029
|
+
);
|
|
1030
|
+
}
|
|
935
1031
|
|
|
1032
|
+
let forcedDevDependencyFlag = false;
|
|
936
1033
|
for (const dependency in context.packageJson.devDependencies) {
|
|
937
1034
|
const dependencyVersion = context.packageJson.devDependencies[dependency];
|
|
938
1035
|
if (dependencyVersion.toLowerCase().includes('github.com')) {
|
|
@@ -958,12 +1055,18 @@ async function checkPackageJson(context) {
|
|
|
958
1055
|
`[E0046] devDependency must not require a specific version. Use "~1.2.3" or "^1.2.3" syntax. Please update "${dependency}:${dependencyVersion}"`,
|
|
959
1056
|
);
|
|
960
1057
|
} else {
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
1058
|
+
forcedDevDependencyFlag = true;
|
|
1059
|
+
// context.warnings.push(
|
|
1060
|
+
// `[W0048] devDependency should not require a specific version. Use "~1.2.3" or "^1.2.3" syntax. Please update "${dependency}:${context.packageJson.devDependencies[dependency]}"`,
|
|
1061
|
+
// );
|
|
964
1062
|
}
|
|
965
1063
|
}
|
|
966
1064
|
}
|
|
1065
|
+
if (forcedDevDependencyFlag) {
|
|
1066
|
+
context.warnings.push(
|
|
1067
|
+
`[S0048] At least one devDpendency at package.json requires a specific version. Consider using "~1.2.3" or "^1.2.3" syntax unless freezing dependencies is really desired.`,
|
|
1068
|
+
);
|
|
1069
|
+
}
|
|
967
1070
|
|
|
968
1071
|
if (!context.packageJson.keywords || !Array.isArray(context.packageJson.keywords)) {
|
|
969
1072
|
context.errors.push('[E0039] "keywords" must be an array within package.json and contain some useful keywords');
|
|
@@ -1088,3 +1191,5 @@ exports.validateReleaseFormat = validateReleaseFormat;
|
|
|
1088
1191
|
// [0060] ${dependency} listed as dependency and as devDependency.
|
|
1089
1192
|
// [0061] Invalid version format "${context.packageJson.version}". Version must follow semver format: MAJOR.MINOR.PATCH or MAJOR.MINOR.PATCH-PRERELEASE.NUMBER (e.g., "1.2.3" or "1.2.3-alpha.4"). No leading zeros allowed, prerelease identifiers must contain only letters, numbers, and hyphens.
|
|
1090
1193
|
// [0062] No devDependency declared for ${dependency}. Please consider adding "${dependency}":"${recommendedVersion}" to devDependencies at package.json`
|
|
1194
|
+
// [0063] "${pkg}" is already included in "@iobroker/testing" >= 5.1.1. Please remove from devDependencies at package.json
|
|
1195
|
+
// [0064] ${dependency} ${dependencyVersion} specified. Newer version ${actualVersion} exists.
|
|
@@ -116,7 +116,7 @@ async function validateIOPackageSchema(context) {
|
|
|
116
116
|
|
|
117
117
|
// Initialize AJV validator
|
|
118
118
|
// @ts-expect-error not constructable - but working
|
|
119
|
-
const ajv = new Ajv({ allErrors: true, verbose: true });
|
|
119
|
+
const ajv = new Ajv({ allErrors: true, verbose: true, strictTypes: false });
|
|
120
120
|
const validate = ajv.compile(schema);
|
|
121
121
|
|
|
122
122
|
// Validate io-package.json against schema
|
|
@@ -326,6 +326,20 @@ async function checkIOPackageJson(context) {
|
|
|
326
326
|
context.checks.push('"common.materializeTab" does not exist in io-package.json');
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
+
if (context.ioPackageJson.common.jsonConfig) {
|
|
330
|
+
if (context.ioPackageJson.common.adminUI) {
|
|
331
|
+
context.warnings.push(
|
|
332
|
+
'[W1109] "common.jsonConfig" replaced by "common.adminUI.config:json" at io-package.json. Please remove.',
|
|
333
|
+
);
|
|
334
|
+
} else {
|
|
335
|
+
context.errors.push(
|
|
336
|
+
'[E1110] "common.jsonConfig" is deprecated and must be replaced by "common.adminUI.config:json" configuration at io-package.json.',
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
} else {
|
|
340
|
+
context.checks.push('"common.jsonConfig" does not exist in io-package.json');
|
|
341
|
+
}
|
|
342
|
+
|
|
329
343
|
if (!context.ioPackageJson.common.titleLang) {
|
|
330
344
|
context.errors.push('[E1004] No "common.titleLang" found in io-package.json');
|
|
331
345
|
} else {
|
|
@@ -676,9 +690,11 @@ async function checkIOPackageJson(context) {
|
|
|
676
690
|
});
|
|
677
691
|
|
|
678
692
|
if (!context.ioPackageJson.common.news[context.ioPackageJson.common.version]) {
|
|
679
|
-
context.
|
|
680
|
-
|
|
681
|
-
|
|
693
|
+
if (!common.isAlphaVersion(context.ioPackageJson.common.version)) {
|
|
694
|
+
context.errors.push(
|
|
695
|
+
`[E1036] No "common.news" found for actual version ${context.ioPackageJson.common.version} in io-package.json`,
|
|
696
|
+
);
|
|
697
|
+
}
|
|
682
698
|
}
|
|
683
699
|
|
|
684
700
|
let missingLang = [];
|
|
@@ -1292,3 +1308,5 @@ exports.checkIOPackageJson = checkIOPackageJson;
|
|
|
1292
1308
|
// [1105] Schema validation: ${errorMsg}
|
|
1293
1309
|
// [1107] Could not download io-package.json schema for validation
|
|
1294
1310
|
// [1108] Schema validation failed: ${error.message}
|
|
1311
|
+
// [1109] "common.jsonConfig" is deprecated and has been replaced by "common.adminUI" at io-package.json. Please remove.
|
|
1312
|
+
// [1110] "common.jsonConfig" is deprecated and must be replaced by "common.adminUI" configuration at io-package.json.
|
package/lib/M2000_Npm.js
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
const axios = require('axios');
|
|
11
11
|
const compareVersions = require('compare-versions');
|
|
12
12
|
|
|
13
|
+
const common = require('./common.js');
|
|
14
|
+
|
|
13
15
|
// disable axios caching
|
|
14
16
|
axios.defaults.headers = {
|
|
15
17
|
'Cache-Control': 'no-cache',
|
|
@@ -19,6 +21,32 @@ axios.defaults.headers = {
|
|
|
19
21
|
|
|
20
22
|
// const common = require('./common.js');
|
|
21
23
|
|
|
24
|
+
async function getNpm(context) {
|
|
25
|
+
console.log('\n[init] checking npm');
|
|
26
|
+
let body;
|
|
27
|
+
try {
|
|
28
|
+
const response = await axios(`https://registry.npmjs.org/iobroker.${context.adapterName}`);
|
|
29
|
+
body = response.data;
|
|
30
|
+
} catch {
|
|
31
|
+
/* */
|
|
32
|
+
}
|
|
33
|
+
// bug in NPM some modules could be accessed via normal web page, but not by API
|
|
34
|
+
if (!body) {
|
|
35
|
+
try {
|
|
36
|
+
const _response = await axios(`https://www.npmjs.com/package/iobroker.${context.adapterName}`);
|
|
37
|
+
if (!_response.data) {
|
|
38
|
+
context.cfg.npmExists = false;
|
|
39
|
+
return context;
|
|
40
|
+
}
|
|
41
|
+
} catch (e) {
|
|
42
|
+
context.cfg.npmExists = false;
|
|
43
|
+
return context;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
context.cfg.npmExists = true;
|
|
47
|
+
return context;
|
|
48
|
+
}
|
|
49
|
+
|
|
22
50
|
async function checkNpm(context) {
|
|
23
51
|
console.log('\n[E2000 - E2999] checkNpm');
|
|
24
52
|
let body;
|
|
@@ -33,7 +61,9 @@ async function checkNpm(context) {
|
|
|
33
61
|
try {
|
|
34
62
|
const _response = await axios(`https://www.npmjs.com/package/iobroker.${context.adapterName}`);
|
|
35
63
|
if (!_response.data) {
|
|
36
|
-
context.errors.push(
|
|
64
|
+
context.errors.push(
|
|
65
|
+
`[E2000] Package iobroker.${context.adapterName} found on npm. Please publish at npm`,
|
|
66
|
+
);
|
|
37
67
|
return context;
|
|
38
68
|
}
|
|
39
69
|
body = _response.data;
|
|
@@ -70,13 +100,25 @@ async function checkNpm(context) {
|
|
|
70
100
|
`[E2003] Version of package.json (${context.packageJson.version}) lower than latest version on NPM (${(body['dist-tags'] && body['dist-tags'].latest) || JSON.stringify(body)})`,
|
|
71
101
|
);
|
|
72
102
|
} else {
|
|
73
|
-
context.
|
|
74
|
-
|
|
75
|
-
|
|
103
|
+
if (!common.isAlphaVersion(context.packageJson.version)) {
|
|
104
|
+
context.warnings.push(
|
|
105
|
+
`[W2002] Version of package.json (${context.packageJson.version}) doesn't match latest version on NPM (${(body['dist-tags'] && body['dist-tags'].latest) || JSON.stringify(body)})`,
|
|
106
|
+
);
|
|
107
|
+
} else {
|
|
108
|
+
context.checks.push(`Alpha version ${context.packageJson.version} not checked`);
|
|
109
|
+
}
|
|
76
110
|
}
|
|
77
111
|
} else {
|
|
78
112
|
context.checks.push(`Version of package.json ${context.packageJson.version} matches latest version on NPM`);
|
|
79
113
|
}
|
|
114
|
+
|
|
115
|
+
if (body['dist-tags'] && body['dist-tags'].latest) {
|
|
116
|
+
if (!context.ioPackageJson.common.news[body['dist-tags'].latest]) {
|
|
117
|
+
context.errors.push(
|
|
118
|
+
`[E2005] No "common.news" in io-package.json found for version ${body['dist-tags'].latest} marked as "latest" at npm`,
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
80
122
|
}
|
|
81
123
|
|
|
82
124
|
if (context.ioPackageJson && context.ioPackageJson.common && context.ioPackageJson.common.news) {
|
|
@@ -109,6 +151,7 @@ async function checkNpm(context) {
|
|
|
109
151
|
}
|
|
110
152
|
|
|
111
153
|
exports.checkNpm = checkNpm;
|
|
154
|
+
exports.getNpm = getNpm;
|
|
112
155
|
|
|
113
156
|
// List of error and warnings used at this module
|
|
114
157
|
// ----------------------------------------------
|
package/lib/M4000_Repository.js
CHANGED
|
@@ -303,8 +303,8 @@ async function checkRepository(context) {
|
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
if (!context.stableRepoLive[dependency]) {
|
|
306
|
-
context.
|
|
307
|
-
`[
|
|
306
|
+
context.errors.push(
|
|
307
|
+
`[E4033] Dependency '${dependency}':'${dependencies[dependency]}' not available at stable repository`,
|
|
308
308
|
);
|
|
309
309
|
} else {
|
|
310
310
|
const versDependency = dependencies[dependency];
|
|
@@ -412,21 +412,28 @@ async function checkVSCodeSchemas(context) {
|
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
|
|
415
|
+
let usesJsonConfig =
|
|
416
|
+
(context.ioPackageJson.common.adminUI?.config && context.ioPackageJson.common.adminUI?.config === 'json') ||
|
|
417
|
+
(context.ioPackageJson.common.adminUI?.custom && context.ioPackageJson.common.adminUI?.custom === 'json') ||
|
|
418
|
+
(context.ioPackageJson.common.adminUI?.tab && context.ioPackageJson.common.adminUI?.tab === 'json');
|
|
419
|
+
|
|
420
|
+
common.debug('Adapter uses jsonConfig, lets check vscode setup');
|
|
421
|
+
|
|
415
422
|
// Check for jsonConfig schemas
|
|
416
423
|
const jsonConfigFiles = ['admin/jsonConfig.json', 'admin/jsonCustom.json', 'admin/jsonTab.json'];
|
|
417
424
|
const json5ConfigFiles = ['admin/jsonConfig.json5', 'admin/jsonCustom.json5', 'admin/jsonTab.json5'];
|
|
418
425
|
|
|
419
|
-
// Check if adapter has any json5 files in admin directory
|
|
420
|
-
|
|
421
426
|
// Find schema that matches jsonConfig files
|
|
422
427
|
const jsonConfigSchema = schemas.find(
|
|
423
428
|
schema => schema.fileMatch && jsonConfigFiles.every(file => schema.fileMatch.includes(file)),
|
|
424
429
|
);
|
|
425
430
|
|
|
426
431
|
if (!jsonConfigSchema) {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
432
|
+
if (usesJsonConfig) {
|
|
433
|
+
context.warnings.push(
|
|
434
|
+
`[W4042] Missing schema definition for jsonConfig files in .vscode/settings.json. Add: {"fileMatch": ${JSON.stringify(jsonConfigFiles)}, "url": "${config.schemaUrls.jsonConfig}"}`,
|
|
435
|
+
);
|
|
436
|
+
}
|
|
430
437
|
} else {
|
|
431
438
|
// Check if URL is correct
|
|
432
439
|
if (jsonConfigSchema.url !== config.schemaUrls.jsonConfig) {
|
|
@@ -444,7 +451,7 @@ async function checkVSCodeSchemas(context) {
|
|
|
444
451
|
);
|
|
445
452
|
|
|
446
453
|
if (!json5ConfigSchema) {
|
|
447
|
-
if (context.cfg.usesJson5) {
|
|
454
|
+
if (usesJsonConfig && context.cfg.usesJson5) {
|
|
448
455
|
context.warnings.push(
|
|
449
456
|
`[W4044] Missing schema definition for JSON5 config files in .vscode/settings.json. Adapt: {"fileMatch": ${JSON.stringify(jsonConfigFiles.concat(json5ConfigFiles))}, "url": "${config.schemaUrls.jsonConfig}"}`,
|
|
450
457
|
);
|
package/lib/M5000_Code.js
CHANGED
|
@@ -185,6 +185,46 @@ async function checkCode(context) {
|
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
+
// Check for conflicting JavaScript file extensions in the same directory
|
|
189
|
+
// E5034: Files with the same base name but different extensions (.js, .cjs, .mjs) in the same directory
|
|
190
|
+
const jsExtensions = ['.js', '.cjs', '.mjs'];
|
|
191
|
+
const filesByDirectory = new Map();
|
|
192
|
+
|
|
193
|
+
// Group files by directory and base name
|
|
194
|
+
context.filesList.forEach(filePath => {
|
|
195
|
+
const ext = path.extname(filePath);
|
|
196
|
+
if (jsExtensions.includes(ext)) {
|
|
197
|
+
const dir = path.dirname(filePath);
|
|
198
|
+
const baseName = path.basename(filePath, ext);
|
|
199
|
+
|
|
200
|
+
if (!filesByDirectory.has(dir)) {
|
|
201
|
+
filesByDirectory.set(dir, new Map());
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const dirFiles = filesByDirectory.get(dir);
|
|
205
|
+
if (!dirFiles.has(baseName)) {
|
|
206
|
+
dirFiles.set(baseName, []);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
dirFiles.get(baseName).push({ ext, fullPath: filePath });
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// Check for conflicts
|
|
214
|
+
filesByDirectory.forEach((dirFiles, dir) => {
|
|
215
|
+
dirFiles.forEach(files => {
|
|
216
|
+
if (files.length > 1) {
|
|
217
|
+
const filePaths = files
|
|
218
|
+
.map(f => f.fullPath)
|
|
219
|
+
.sort()
|
|
220
|
+
.join(', ');
|
|
221
|
+
context.warnings.push(
|
|
222
|
+
`[W5034] Files with conflicting extensions found in directory "${dir}": ${filePaths} - Only one JavaScript file extension (.js, .cjs, or .mjs) should be used per file name.`,
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
|
|
188
228
|
let usesReact = false;
|
|
189
229
|
if (
|
|
190
230
|
context.packageJson.devDependencies &&
|
|
@@ -251,7 +291,7 @@ async function checkCode(context) {
|
|
|
251
291
|
(context.ioPackageJson.common.adminUI.config !== 'json' &&
|
|
252
292
|
context.ioPackageJson.common.adminUI.config !== 'none'))
|
|
253
293
|
) {
|
|
254
|
-
context.warnings.push('[S5022] Please consider migrating to admin 5 UI (jsonConfig).');
|
|
294
|
+
context.warnings.push('[S5022] Please consider migrating to admin 5 UI (jsonConfig) or react based UI.');
|
|
255
295
|
}
|
|
256
296
|
|
|
257
297
|
if (
|
|
@@ -793,5 +833,6 @@ exports.checkCode = checkCode;
|
|
|
793
833
|
// [5031] "gulpfile.js" found in repo with @iobroker/adapter-dev. Check if gulp is still needed.
|
|
794
834
|
// [5032] "lib/tools.js" found in repo but not used anywhere. Consider removing this outdated file.
|
|
795
835
|
// [5033] method "${method}()" is deprecated and will be removed with future js-controller version. Please use "set/deleteObject()" instead.
|
|
836
|
+
// [5034] Files with conflicting extensions found in directory "${dir}": ${filePaths} - Only one JavaScript file extension (.js, .cjs, or .mjs) should be used per file name.
|
|
796
837
|
|
|
797
|
-
// [
|
|
838
|
+
// [5500 - ] see M5500_jsonConfig.js
|
package/lib/M6000_Readme.js
CHANGED
|
@@ -18,6 +18,23 @@ function getAuthor(author) {
|
|
|
18
18
|
return author;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Extract all years from a text and return the maximum year found.
|
|
23
|
+
* This handles multiple copyright entries correctly.
|
|
24
|
+
*
|
|
25
|
+
* @param {string} text - The text to search for years
|
|
26
|
+
* @returns {number} The maximum year found, or 0 if no year found
|
|
27
|
+
*/
|
|
28
|
+
function getMaxYearFromText(text) {
|
|
29
|
+
const allYears = [];
|
|
30
|
+
const yearRegex = /\d\d\d\d/g;
|
|
31
|
+
let match;
|
|
32
|
+
while ((match = yearRegex.exec(text)) !== null) {
|
|
33
|
+
allYears.push(Number(match[0]));
|
|
34
|
+
}
|
|
35
|
+
return allYears.length > 0 ? Math.max(...allYears) : 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
21
38
|
async function checkReadme(context) {
|
|
22
39
|
// https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/README.md
|
|
23
40
|
console.log('\n[E6000 - E6999] checkReadme');
|
|
@@ -34,9 +51,15 @@ async function checkReadme(context) {
|
|
|
34
51
|
context.checks.push('README.md contains Changelog');
|
|
35
52
|
|
|
36
53
|
if (!data.includes(`### ${context.packageJson.version}`)) {
|
|
37
|
-
context.
|
|
38
|
-
|
|
39
|
-
|
|
54
|
+
if (!common.isAlphaVersion(context.packageJson.version)) {
|
|
55
|
+
context.errors.push(
|
|
56
|
+
`[E6006] Current adapter version ${context.packageJson.version} not found in README.md`,
|
|
57
|
+
);
|
|
58
|
+
} else {
|
|
59
|
+
context.warnings.push(
|
|
60
|
+
`[S6008] Changelog for version ${context.packageJson.version} should be added to README.md.`,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
40
63
|
} else {
|
|
41
64
|
context.checks.push('README.md contains current adapter version');
|
|
42
65
|
}
|
|
@@ -54,7 +77,9 @@ async function checkReadme(context) {
|
|
|
54
77
|
// console.log(`${latest} - ${timeStr} - ${npmYear}`);
|
|
55
78
|
}
|
|
56
79
|
} catch (e) {
|
|
57
|
-
context.
|
|
80
|
+
if (context.npmExists) {
|
|
81
|
+
context.warnings.push('[W6010] Could not retrieve timestamp of LATEST revision at npm.');
|
|
82
|
+
}
|
|
58
83
|
common.error(`executing "npm view" - ${e}`);
|
|
59
84
|
}
|
|
60
85
|
|
|
@@ -66,17 +91,7 @@ async function checkReadme(context) {
|
|
|
66
91
|
const text = data.substring(pos);
|
|
67
92
|
const year = new Date().getFullYear();
|
|
68
93
|
const commitYear = context.lastCommitYear || 0;
|
|
69
|
-
|
|
70
|
-
let m = text.match(/\d\d\d\d\s*-\s*(\d\d\d\d)/);
|
|
71
|
-
if (m) {
|
|
72
|
-
readmeYear = Number(m[1]);
|
|
73
|
-
}
|
|
74
|
-
m = text.match(/(\d\d\d\d)/); /* both variants could be present */
|
|
75
|
-
if (m) {
|
|
76
|
-
if (Number(m[1]) > readmeYear) {
|
|
77
|
-
readmeYear = Number(m[1]);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
94
|
+
const readmeYear = getMaxYearFromText(text);
|
|
80
95
|
|
|
81
96
|
common.info(
|
|
82
97
|
`years detected: README ${readmeYear} / Current ${year} / Last commit ${commitYear} / NPM ${npmYear}`,
|
|
@@ -108,6 +123,25 @@ async function checkReadme(context) {
|
|
|
108
123
|
} else {
|
|
109
124
|
context.checks.push('Valid copyright year found in README.md');
|
|
110
125
|
}
|
|
126
|
+
|
|
127
|
+
// Check for multiple copyright lines and trailing spaces
|
|
128
|
+
const copyrightLines = text.split('\n').filter(line => line.trim().match(/^Copyright\s+\(c\)/i));
|
|
129
|
+
if (copyrightLines.length > 1) {
|
|
130
|
+
// Check all lines except the last one for trailing double spaces
|
|
131
|
+
const linesWithoutTrailingSpaces = [];
|
|
132
|
+
for (let i = 0; i < copyrightLines.length - 1; i++) {
|
|
133
|
+
if (!copyrightLines[i].match(/\s{2,}$/)) {
|
|
134
|
+
linesWithoutTrailingSpaces.push(i + 1);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (linesWithoutTrailingSpaces.length > 0) {
|
|
138
|
+
context.warnings.push(
|
|
139
|
+
`[W6009] Multiple copyright lines found in README.md but line(s) ${linesWithoutTrailingSpaces.join(', ')} missing trailing spaces. Add two spaces at end of each copyright line (except last) for proper formatting.`,
|
|
140
|
+
);
|
|
141
|
+
} else {
|
|
142
|
+
context.checks.push('Multiple copyright lines in README.md have proper trailing spaces');
|
|
143
|
+
}
|
|
144
|
+
}
|
|
111
145
|
}
|
|
112
146
|
|
|
113
147
|
// languages = languagedetect.detect(data, 3);
|
|
@@ -128,5 +162,7 @@ exports.checkReadme = checkReadme;
|
|
|
128
162
|
// [6004] No "## License" found in README.md
|
|
129
163
|
// [6005] No actual year found in copyright. Please add "Copyright (c) ${m[1]}-${year} ${getAuthor(context.packageJson.author)}" at the end of README.md
|
|
130
164
|
// [6005] No actual year found in copyright. Please add "Copyright (c) ${year} ${getAuthor(context.packageJson.author)}" at the end of README.md
|
|
131
|
-
// [
|
|
165
|
+
// [6010] Could not retrieve timestamp of LATEST revision at npm.
|
|
132
166
|
// [6007] Future year (${readmeYear}) found in copyright. Please use "Copyright (c) ${m[1]}-${year} ${getAuthor(context.packageJson.author)}" at the end of README.md
|
|
167
|
+
// [6008] Changelog for version ${context.packageJson.version} should be added to README.md.
|
|
168
|
+
// [6009] Multiple copyright lines found in README.md but line(s) ${linesWithoutTrailingSpaces.join(', ')} missing trailing spaces. Add two spaces at end of each copyright line (except last) for proper formatting.
|
package/lib/M7000_License.js
CHANGED
|
@@ -18,6 +18,23 @@ function getAuthor(author) {
|
|
|
18
18
|
return author;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Extract all years from a text and return the maximum year found.
|
|
23
|
+
* This handles multiple copyright entries correctly.
|
|
24
|
+
*
|
|
25
|
+
* @param {string} text - The text to search for years
|
|
26
|
+
* @returns {number} The maximum year found, or 0 if no year found
|
|
27
|
+
*/
|
|
28
|
+
function getMaxYearFromText(text) {
|
|
29
|
+
const allYears = [];
|
|
30
|
+
const yearRegex = /\d\d\d\d/g;
|
|
31
|
+
let match;
|
|
32
|
+
while ((match = yearRegex.exec(text)) !== null) {
|
|
33
|
+
allYears.push(Number(match[0]));
|
|
34
|
+
}
|
|
35
|
+
return allYears.length > 0 ? Math.max(...allYears) : 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
21
38
|
async function checkLicenseFile(context) {
|
|
22
39
|
// https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/LICENSE
|
|
23
40
|
console.log('\n[E7000 - E7999] checkLicenseFile');
|
|
@@ -53,17 +70,7 @@ async function checkLicenseFile(context) {
|
|
|
53
70
|
const text = data;
|
|
54
71
|
const year = new Date().getFullYear();
|
|
55
72
|
const commitYear = context.lastCommitYear || 0;
|
|
56
|
-
|
|
57
|
-
let m = text.match(/\d\d\d\d\s*-\s*(\d\d\d\d)/);
|
|
58
|
-
if (m) {
|
|
59
|
-
licenseYear = Number(m[1]);
|
|
60
|
-
}
|
|
61
|
-
m = text.match(/(\d\d\d\d)/);
|
|
62
|
-
if (m) {
|
|
63
|
-
if (Number(m[1]) > licenseYear) {
|
|
64
|
-
licenseYear = Number(m[1]);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
73
|
+
const licenseYear = getMaxYearFromText(text);
|
|
67
74
|
|
|
68
75
|
common.info(
|
|
69
76
|
`years detected: LICENSE ${licenseYear} / Current ${year} / Last commit ${commitYear} / NPM ${npmYear}`,
|
|
@@ -95,6 +102,25 @@ async function checkLicenseFile(context) {
|
|
|
95
102
|
} else {
|
|
96
103
|
context.checks.push(`Valid copyright year ${licenseYear} found in LICENSE`);
|
|
97
104
|
}
|
|
105
|
+
|
|
106
|
+
// Check for multiple copyright lines and trailing spaces
|
|
107
|
+
const copyrightLines = data.split('\n').filter(line => line.trim().match(/^Copyright\s+\(c\)/i));
|
|
108
|
+
if (copyrightLines.length > 1) {
|
|
109
|
+
// Check all lines except the last one for trailing double spaces
|
|
110
|
+
const linesWithoutTrailingSpaces = [];
|
|
111
|
+
for (let i = 0; i < copyrightLines.length - 1; i++) {
|
|
112
|
+
if (!copyrightLines[i].match(/\s{2,}$/)) {
|
|
113
|
+
linesWithoutTrailingSpaces.push(i + 1);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (linesWithoutTrailingSpaces.length > 0) {
|
|
117
|
+
context.warnings.push(
|
|
118
|
+
`[W7003] Multiple copyright lines found in LICENSE but line(s) ${linesWithoutTrailingSpaces.join(', ')} missing trailing spaces. Add two spaces at end of each copyright line (except last) for proper formatting.`,
|
|
119
|
+
);
|
|
120
|
+
} else {
|
|
121
|
+
context.checks.push('Multiple copyright lines in LICENSE have proper trailing spaces');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
98
124
|
}
|
|
99
125
|
}
|
|
100
126
|
return context;
|
|
@@ -109,3 +135,4 @@ exports.checkLicenseFile = checkLicenseFile;
|
|
|
109
135
|
// [7001] No actual year found in LICENSE. Please add "Copyright (c) ${m[1]}-${year} ${getAuthor(context.packageJson.author)}" at the start of LICENSE
|
|
110
136
|
// [7001] No actual year found in LICENSE. Please add "Copyright (c) ${year} ${getAuthor(context.packageJson.author)}" at the start of LICENSE
|
|
111
137
|
// [7002] Cannot read LICENSE file. Please check.');
|
|
138
|
+
// [7003] Multiple copyright lines found in LICENSE but line(s) ${linesWithoutTrailingSpaces.join(', ')} missing trailing spaces. Add two spaces at end of each copyright line (except last) for proper formatting.
|
|
@@ -16,13 +16,6 @@
|
|
|
16
16
|
|
|
17
17
|
// const common = require('./common.js');
|
|
18
18
|
|
|
19
|
-
function paddingNum(num) {
|
|
20
|
-
if (num >= 10) {
|
|
21
|
-
return num;
|
|
22
|
-
}
|
|
23
|
-
return `0${num}`;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
19
|
// 900 - ???
|
|
27
20
|
async function checkGitIgnore(context) {
|
|
28
21
|
console.log('\n[E9000 - E9499] checkGitIgnore');
|
|
@@ -97,7 +90,7 @@ async function checkGitIgnore(context) {
|
|
|
97
90
|
if (!isIgnored) {
|
|
98
91
|
// convert to warning mid of 2026
|
|
99
92
|
context.warnings.push(
|
|
100
|
-
'[S9006] .commitinfo file should be excluded by .gitignore,
|
|
93
|
+
'[S9006] .commitinfo file should be excluded by .gitignore, please add a line with text ".commitinfo" to .gitignore',
|
|
101
94
|
);
|
|
102
95
|
}
|
|
103
96
|
}
|
|
@@ -185,7 +178,7 @@ async function checkNpmIgnore(context) {
|
|
|
185
178
|
// /*!check &&*/ context.errors.push(`[E9505] iob_npm.done not found in .npmignore`);
|
|
186
179
|
// }
|
|
187
180
|
|
|
188
|
-
checkFiles.forEach(
|
|
181
|
+
checkFiles.forEach(file => {
|
|
189
182
|
if (context.filesList.includes(`/${file}`)) {
|
|
190
183
|
// maybe it is with regex
|
|
191
184
|
const check = rules.some(rule => {
|
|
@@ -196,9 +189,7 @@ async function checkNpmIgnore(context) {
|
|
|
196
189
|
});
|
|
197
190
|
|
|
198
191
|
!check &&
|
|
199
|
-
context.errors.push(
|
|
200
|
-
`[E9${paddingNum(i + 61)}] file ${file} found in repository, but not found in .npmignore`,
|
|
201
|
-
);
|
|
192
|
+
context.errors.push(`[E9010] file ${file} found in repository, but not found in .npmignore`);
|
|
202
193
|
}
|
|
203
194
|
});
|
|
204
195
|
}
|
|
@@ -217,11 +208,12 @@ exports.checkNpmIgnore = checkNpmIgnore;
|
|
|
217
208
|
// [9003] iob_npm.done not found in .gitignore
|
|
218
209
|
// [9004] file ${file} found in repository, but not found in .gitignore
|
|
219
210
|
// [9005] .commitinfo file found in repository, please remove it
|
|
211
|
+
// [9006] .commitinfo file should be excluded by .gitignore, consider adding it to .gitignore
|
|
212
|
+
|
|
213
|
+
// [9010] file ${file} found in repository, but not found in .npmignore.
|
|
220
214
|
|
|
221
215
|
// [9501] .npmignore found but "files" is used at package.json. Please remove .npmignore.
|
|
222
216
|
// [9502] .npmignore not found
|
|
223
217
|
// [9503] .npmignore found - consider using package.json object "files" instead.
|
|
224
218
|
// [9504] node_modules not found in `.npmignore`
|
|
225
219
|
// [9505] iob_npm.done not found in .npmignore` ### removed ###
|
|
226
|
-
|
|
227
|
-
// [W9006] .commitinfo file should be excluded by .gitignore, consider adding it to .gitignore
|
package/lib/common.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/*
|
|
3
|
-
This module contains
|
|
3
|
+
This module contains general utility routines for iobroker.repochecker
|
|
4
4
|
|
|
5
5
|
*/
|
|
6
6
|
const axios = require('axios');
|
|
@@ -228,6 +228,13 @@ function getDependencies(deps) {
|
|
|
228
228
|
return ret;
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
+
/*
|
|
232
|
+
return true if version is not a normal proction versoion
|
|
233
|
+
*/
|
|
234
|
+
function isAlphaVersion(version) {
|
|
235
|
+
return !(version && version.match(/^\d+\.\d+\.\d+$/));
|
|
236
|
+
}
|
|
237
|
+
|
|
231
238
|
/*
|
|
232
239
|
return the greater of two semver versions
|
|
233
240
|
*/
|
|
@@ -295,6 +302,7 @@ exports.getFile = getFile;
|
|
|
295
302
|
exports.getFilesList = getFilesList;
|
|
296
303
|
exports.getDependencyArray = getDependencyArray;
|
|
297
304
|
exports.getDependencies = getDependencies;
|
|
305
|
+
exports.isAlphaVersion = isAlphaVersion;
|
|
298
306
|
exports.maxVersion = maxVersion;
|
|
299
307
|
exports.parseSemver = parseSemver;
|
|
300
308
|
exports.validateSemver = validateSemver;
|
package/lib/config.js
CHANGED
|
@@ -479,6 +479,7 @@ function logEnvironment(context) {
|
|
|
479
479
|
common.info(' ');
|
|
480
480
|
common.info('Configuration flags set:');
|
|
481
481
|
common.info(` hasJsonConfig: ${context.cfg.hasJsonConfig ? 'true' : 'false'}`);
|
|
482
|
+
common.info(` npmExists: ${context.cfg.npmExists ? 'true' : 'false'}`);
|
|
482
483
|
common.info(` onlyWWW: ${context.cfg.onlyWWW ? 'true' : 'false'}`);
|
|
483
484
|
common.info(` usesJson5: ${context.cfg.usesJson5 ? 'true' : 'false'}`);
|
|
484
485
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.0.0-alpha.
|
|
2
|
+
"version": "5.0.0-alpha.2",
|
|
3
3
|
"name": "@iobroker/repochecker",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"ajv": "^8.17.1",
|
|
6
|
-
"axios": "^1.
|
|
6
|
+
"axios": "^1.12.2",
|
|
7
7
|
"compare-versions": "^6.1.1",
|
|
8
8
|
"image-size": "^1.2.0",
|
|
9
9
|
"json5": "^2.2.3",
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"@alcalzone/release-script": "^3.8.0",
|
|
14
|
-
"@iobroker/eslint-config": "^2.
|
|
14
|
+
"@iobroker/eslint-config": "^2.2.0",
|
|
15
15
|
"@tsconfig/node20": "^20.1.6",
|
|
16
|
-
"@types/node": "^24.
|
|
17
|
-
"@types/semver": "^7.7.
|
|
16
|
+
"@types/node": "^24.6.1",
|
|
17
|
+
"@types/semver": "^7.7.1"
|
|
18
18
|
},
|
|
19
19
|
"publishConfig": {
|
|
20
20
|
"access": "public"
|