@iobroker/repochecker 5.0.0-alpha.1 → 5.0.0-alpha.3

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 CHANGED
@@ -31,7 +31,13 @@ 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.1 (2025-09-29)
34
+ ### 5.0.0-alpha.3 (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)
35
41
  - (mcm1957) Strict mode requirements have been loosend at schema validation.
36
42
  - (mcm1957) Do not log missing jsonConfig schema at vscode is no jsonConfig is used. [#548]
37
43
  - (mcm1957) News entry at io-package.json is no longer required for alpha release. [#532]
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
@@ -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))
@@ -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.1.0',
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
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
 
@@ -317,21 +341,23 @@ async function checkPackageJson(context) {
317
341
  context.checks.push('Repository has name ioBroker.adaptername (not iobroker.adaptername)');
318
342
  }
319
343
 
320
- //const m = context.githubUrlOriginal.match(/\/ioBroker\.(.*)$/);
321
- let m;
322
- m = context.githubApiData.name.match(/^ioBroker\.(.*)$/);
323
- if (!m || !m[1]) {
324
- m = context.githubApiData.name.match(/^iobroker\.(.*)$/);
325
- }
326
- let adapterName = '';
327
- if (!m || !m[1]) {
328
- context.errors.push(`[E0004] No valid adapter name found in URL: ${context.githubUrlOriginal}`);
329
- } else {
330
- context.checks.push('Adapter name found in the URL');
331
- adapterName = m[1].replace(/\/master$/, '').replace(/\/main$/, '');
332
- }
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
+ // }
333
357
 
334
- context.adapterName = adapterName !== '' ? adapterName : 'unknown';
358
+ // context.adapterName = adapterName !== '' ? adapterName : 'unknown';
359
+
360
+ const adapterName = context.adapterName;
335
361
 
336
362
  if (adapterName.match(/[A-Z]/)) {
337
363
  context.errors.push('[E0005] Adapter name must be lowercase');
@@ -798,6 +824,7 @@ async function checkPackageJson(context) {
798
824
 
799
825
  const requiredVersion = dependenciesPackageJson[dependency].required;
800
826
  const recommendedVersion = dependenciesPackageJson[dependency].recommended;
827
+ const actualVersion = dependenciesPackageJson[dependency].actual;
801
828
  const alternatives = dependenciesPackageJson[dependency].alternatives || [];
802
829
  const optional = !!dependenciesPackageJson[dependency].optional;
803
830
  const suggested = !!dependenciesPackageJson[dependency].suggested;
@@ -811,11 +838,15 @@ async function checkPackageJson(context) {
811
838
  // if dependency exists, version requirements must be met
812
839
  if (!compareVersions.compare(dependencyVersion, requiredVersion, '>=')) {
813
840
  context.errors.push(
814
- `[E0033] ${dependency} ${dependencyVersion} specified. ${requiredVersion} is required as minimum, ${recommendedVersion} (or newer) is current. Please update dependencies at package.json`,
841
+ `[E0033] ${dependency} ${dependencyVersion} specified. ${requiredVersion} is required as minimum, ${actualVersion} (or newer) is current. Please update dependencies at package.json`,
815
842
  );
816
843
  } else if (!compareVersions.compare(dependencyVersion, recommendedVersion, '>=')) {
817
844
  context.warnings.push(
818
- `[W0034] ${dependency} ${dependencyVersion} specified. ${recommendedVersion} (or newer) is current. Please update dependencies at package.json`,
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.`,
819
850
  );
820
851
  } else {
821
852
  context.checks.push(`dependency ${dependency} ${dependencyVersion} is ok`);
@@ -854,6 +885,7 @@ async function checkPackageJson(context) {
854
885
 
855
886
  const requiredVersion = devDependenciesPackageJson[dependency].required;
856
887
  const recommendedVersion = devDependenciesPackageJson[dependency].recommended;
888
+ const actualVersion = devDependenciesPackageJson[dependency].actual;
857
889
  const alternatives = devDependenciesPackageJson[dependency].alternatives || [];
858
890
  const optional = !!devDependenciesPackageJson[dependency].optional;
859
891
  const suggested = !!devDependenciesPackageJson[dependency].suggested;
@@ -867,17 +899,21 @@ async function checkPackageJson(context) {
867
899
  // if dependency exists, version requirements must be met
868
900
  if (!compareVersions.compare(dependencyVersion, requiredVersion, '>=')) {
869
901
  context.errors.push(
870
- `[E0036] ${dependency} ${dependencyVersion} specified. ${requiredVersion} is required as minimum, ${recommendedVersion} (or newer) is current. Please update devDependencies at package.json`,
902
+ `[E0036] ${dependency} ${dependencyVersion} specified. ${requiredVersion} is required as minimum, ${actualVersion} (or newer) is current. Please update devDependencies at package.json`,
871
903
  );
872
904
  } else if (!compareVersions.compare(dependencyVersion, recommendedVersion, '>=')) {
873
905
  context.warnings.push(
874
- `[W0037] ${dependency} ${dependencyVersion} specified. ${recommendedVersion} (or newer) is current. Please update devDependencies at package.json`,
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.`,
875
911
  );
876
912
  } else {
877
913
  context.checks.push(`devDependency ${dependency} ${dependencyVersion} is ok`);
878
914
  }
879
915
  } else {
880
- // if dependency does not existscheck if alternate exists
916
+ // if dependency does not exist - check if alternate exists
881
917
  let found = '';
882
918
  for (const alternative of alternatives) {
883
919
  if (context.packageJson.devDependencies[`${alternative}`]) {
@@ -893,13 +929,58 @@ async function checkPackageJson(context) {
893
929
  }
894
930
  } else {
895
931
  context.errors.push(
896
- `[E0035] No devDependency declared for ${dependency}. Please add "${dependency}":"${recommendedVersion}" to devDependencies at package.json`,
932
+ `[E0035] No devDependency declared for ${dependency}. Please add "${dependency}":"${actualVersion}" to devDependencies at package.json`,
897
933
  );
898
934
  }
899
935
  }
900
936
  }
901
937
  context.checks.push('required devDependencies have been checked.');
902
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
+
903
984
  const enforcedDependencies = [
904
985
  '@iobroker/adapter-core',
905
986
  '@alcalzone/release-script',
@@ -1110,3 +1191,5 @@ exports.validateReleaseFormat = validateReleaseFormat;
1110
1191
  // [0060] ${dependency} listed as dependency and as devDependency.
1111
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.
1112
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.
@@ -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 {
@@ -1294,3 +1308,5 @@ exports.checkIOPackageJson = checkIOPackageJson;
1294
1308
  // [1105] Schema validation: ${errorMsg}
1295
1309
  // [1107] Could not download io-package.json schema for validation
1296
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
@@ -21,6 +21,32 @@ axios.defaults.headers = {
21
21
 
22
22
  // const common = require('./common.js');
23
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
+
24
50
  async function checkNpm(context) {
25
51
  console.log('\n[E2000 - E2999] checkNpm');
26
52
  let body;
@@ -125,6 +151,7 @@ async function checkNpm(context) {
125
151
  }
126
152
 
127
153
  exports.checkNpm = checkNpm;
154
+ exports.getNpm = getNpm;
128
155
 
129
156
  // List of error and warnings used at this module
130
157
  // ----------------------------------------------
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 &&
@@ -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
- // [550 - ] see M500_jsonConfig.js
838
+ // [5500 - ] see M5500_jsonConfig.js
@@ -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 = /\b(\d\d\d\d)\b/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');
@@ -60,7 +77,9 @@ async function checkReadme(context) {
60
77
  // console.log(`${latest} - ${timeStr} - ${npmYear}`);
61
78
  }
62
79
  } catch (e) {
63
- context.warnings.push('[W6006] Could not retrieve timestamp of LATEST revision at npm.');
80
+ if (context.npmExists) {
81
+ context.warnings.push('[W6010] Could not retrieve timestamp of LATEST revision at npm.');
82
+ }
64
83
  common.error(`executing "npm view" - ${e}`);
65
84
  }
66
85
 
@@ -72,17 +91,7 @@ async function checkReadme(context) {
72
91
  const text = data.substring(pos);
73
92
  const year = new Date().getFullYear();
74
93
  const commitYear = context.lastCommitYear || 0;
75
- let readmeYear = 0;
76
- let m = text.match(/\d\d\d\d\s*-\s*(\d\d\d\d)/);
77
- if (m) {
78
- readmeYear = Number(m[1]);
79
- }
80
- m = text.match(/(\d\d\d\d)/); /* both variants could be present */
81
- if (m) {
82
- if (Number(m[1]) > readmeYear) {
83
- readmeYear = Number(m[1]);
84
- }
85
- }
94
+ const readmeYear = getMaxYearFromText(text);
86
95
 
87
96
  common.info(
88
97
  `years detected: README ${readmeYear} / Current ${year} / Last commit ${commitYear} / NPM ${npmYear}`,
@@ -114,6 +123,25 @@ async function checkReadme(context) {
114
123
  } else {
115
124
  context.checks.push('Valid copyright year found in README.md');
116
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
+ }
117
145
  }
118
146
 
119
147
  // languages = languagedetect.detect(data, 3);
@@ -134,6 +162,7 @@ exports.checkReadme = checkReadme;
134
162
  // [6004] No "## License" found in README.md
135
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
136
164
  // [6005] No actual year found in copyright. Please add "Copyright (c) ${year} ${getAuthor(context.packageJson.author)}" at the end of README.md
137
- // [6006] Could not retrieve timestamp of LATEST revision at npm.
165
+ // [6010] Could not retrieve timestamp of LATEST revision at npm.
138
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
139
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.
@@ -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 = /\b(\d\d\d\d)\b/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
- let licenseYear = 0;
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');
@@ -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((file, i) => {
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/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.1",
2
+ "version": "5.0.0-alpha.3",
3
3
  "name": "@iobroker/repochecker",
4
4
  "dependencies": {
5
5
  "ajv": "^8.17.1",
6
- "axios": "^1.11.0",
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.1.0",
14
+ "@iobroker/eslint-config": "^2.2.0",
15
15
  "@tsconfig/node20": "^20.1.6",
16
- "@types/node": "^24.3.0",
17
- "@types/semver": "^7.7.0"
16
+ "@types/node": "^24.6.1",
17
+ "@types/semver": "^7.7.1"
18
18
  },
19
19
  "publishConfig": {
20
20
  "access": "public"