@iobroker/repochecker 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,6 +20,14 @@ Branch (`master/main/dev`) is optional.
20
20
  -->
21
21
 
22
22
  ## Changelog
23
+ ### 2.2.1 (2024-03-26)
24
+ * (mcm1957) Added check that own adapter is not listed at common.restartAdapters
25
+ * (mcm1957) Added check of version strings at common.news
26
+ * (mcm1957) Added check for recommended node version (node 18 for now)
27
+ * (mcm1957) Disallow common.mode == subscribe
28
+ * (mcm1957) Deprecate common.wakeup
29
+ * (mcm1957) Added check for adapter-core version (>= 3.0.6)
30
+
23
31
  ### 2.2.0 (2024-03-24)
24
32
  * (klein0r) Added check for licenseInformation
25
33
  * (klein0r) Added check for deprecated license
package/doc/issues.json CHANGED
@@ -122,6 +122,9 @@
122
122
  "E025": {
123
123
  "title": "Do not include `iobroker.js-controller` as dependency!"
124
124
  },
125
+ "E029": {
126
+ "title": "Node.js ${requiredNodeVersion} is required as minimum, node.js ${recommendedNodeVersion} is recommended. Please adapt `{'engines' : { 'node' >= '${match.groups.vers}' } }` at package.json."
127
+ },
125
128
  "E100": {
126
129
  "title": "Cannot parse io-package.json"
127
130
  },
@@ -293,6 +296,12 @@
293
296
  "E172": {
294
297
  "title": "`common.automaticUpgrade` will be defined by the user. Remove the attribute from io-package.json"
295
298
  },
299
+ "E175": {
300
+ "title": "Release `${version}` at `common.news` in io-package.json is malformed."
301
+ },
302
+ "E176": {
303
+ "title": "Own adapter is not allowed to be listed at `common.restartAdapters` in io-pacakge.json"
304
+ },
296
305
  "E200": {
297
306
  "title": "Not found on npm. Please publish"
298
307
  },
@@ -443,6 +452,15 @@
443
452
  "E903": {
444
453
  "title": "iob_npm.done not found in .gitignore"
445
454
  },
455
+ "W026": {
456
+ "title": "`{'engines' : { 'node' >= '${recommendedNodeVersion}' } }` is required at package.json"
457
+ },
458
+ "W027": {
459
+ "title": "{'engines' : { 'node' : '${nodeVal}' } }` is not parseable."
460
+ },
461
+ "W028": {
462
+ "title": "Minimum node.js version ${recommendedNodeVersion} recommended. Please adapt `{'engines' : { 'node' >= '${match.groups.vers}' } }` at package.json."
463
+ },
446
464
  "W105": {
447
465
  "title": "`common.titleLang` should be translated into all supported languages"
448
466
  },
@@ -476,6 +494,12 @@
476
494
  "W172": {
477
495
  "title": "`common.localLink` in io-package.json is deprecated. Please define object `common.localLinks`: { `_default`: `...` }"
478
496
  },
497
+ "W173": {
498
+ "title": "`@iobroker/adapter-core` should be release ${recommendedAdapterCoreVersion} or newer - please update"
499
+ },
500
+ "W174": {
501
+ "title": "`common.wakeup` is deprectaed. Please remove from io-package.json"
502
+ },
479
503
  "W302": {
480
504
  "title": "Use github actions instead of travis-ci"
481
505
  },
package/index.js CHANGED
@@ -23,7 +23,12 @@ const compareVersions = require('compare-versions');
23
23
  const issues = require('./doc/issues');
24
24
 
25
25
  const version = require('./package.json').version;
26
+
27
+ // adapt recommended version here
28
+ const recommendedAdapterCoreVersion = '3.0.6';
26
29
  const recommendedJsControllerVersion = '5.0.11';
30
+ const recommendedNodeVersion = '18';
31
+ const requiredNodeVersion = '16';
27
32
 
28
33
  const memStore = {};
29
34
 
@@ -80,7 +85,7 @@ function checkLanguages(langObj) {
80
85
 
81
86
  function getGithubApiData(context) {
82
87
  return new Promise((resolve, reject) => {
83
- axios.get(context.githubUrlApi)
88
+ axios.get(context.githubUrlApi, { cache: false })
84
89
  .then(response => {
85
90
  context.githubApiData = response.data;
86
91
  // console.log(`API Data: ${JSON.stringify(context.githubApiData)}`);
@@ -103,6 +108,7 @@ function getGithubApiData(context) {
103
108
  // E0xx
104
109
  function checkPackageJson(context) {
105
110
  return new Promise((resolve, reject) => {
111
+ console.log('\ncheckPackageJson [E0xx]');
106
112
  if (context.packageJson) {
107
113
  return resolve(context.packageJson);
108
114
  } else {
@@ -277,7 +283,10 @@ function checkPackageJson(context) {
277
283
  } else {
278
284
  context.checks.push('iobroker.js-controller is not in dependencies');
279
285
  }
280
- // max number is E025
286
+
287
+ // SPECIAL NOTE: E026-E029 are used at checkIoPackage.json
288
+
289
+ // max number is E029
281
290
 
282
291
  return context;
283
292
  });
@@ -300,7 +309,6 @@ const allowedLanguages = [
300
309
  const allowedModes = {
301
310
  'none': 'this adapter will not be started',
302
311
  'daemon': 'always running process (will be restarted if process exits)',
303
- 'subscribe': 'is started when state system.adapter…alive changes to true. Is killed when .alive changes to false and sets .alive to false if process exits (will not be restarted when process exits)',
304
312
  'schedule': 'is started by schedule found in system.adapter…common.schedule - reacts on changes of .schedule by rescheduling with new state',
305
313
  'once': 'his adapter will be started every time the system.adapter.. object changed. It will not be restarted after termination.',
306
314
  'extension': ''
@@ -711,7 +719,7 @@ const licenses = [
711
719
  function checkIOPackageJson(context) {
712
720
  context = context || {};
713
721
  return new Promise((resolve, reject) => {
714
- console.log('checkIOPackageJson [E1xx]');
722
+ console.log('\ncheckIOPackageJson [E1xx]');
715
723
  if (context.ioPackageJson) {
716
724
  return resolve(context.ioPackageJson);
717
725
  } else {
@@ -749,7 +757,7 @@ function checkIOPackageJson(context) {
749
757
  }
750
758
 
751
759
  if (context.ioPackageJson.common.title) {
752
- context.warnings.push('[W171] "common.title" is deprecated in io-package.json');
760
+ context.warnings.push('[W171] "common.title" is deprecated in io-package.json. Please remove from io-package.json.');
753
761
  }
754
762
 
755
763
  if (!context.ioPackageJson.common.titleLang) {
@@ -877,7 +885,7 @@ function checkIOPackageJson(context) {
877
885
 
878
886
  if (!context.ioPackageJson.common.licenseInformation) {
879
887
  if (!context.ioPackageJson.common.license) {
880
- context.errors.push('[E115] No licenseInformation found in io-package.json');
888
+ context.errors.push('[E115] "common.licenseInformation" not found in io-package.json');
881
889
  }
882
890
  } else {
883
891
  context.checks.push('"common.licenseInformation" found in io-package.json');
@@ -918,7 +926,7 @@ function checkIOPackageJson(context) {
918
926
  context.checks.push('"common.mode" found in io-package.json');
919
927
 
920
928
  if (!allowedModes[context.ioPackageJson.common.mode]) {
921
- context.errors.push('[E166] Unknown type found in io-package.json');
929
+ context.errors.push(`[E166] "common.mode" ${context.ioPackageJson.common.mode} is unknown in io-package.json.`);
922
930
  } else {
923
931
  context.checks.push('"common.mode" has known mode in io-package.json');
924
932
 
@@ -977,6 +985,12 @@ function checkIOPackageJson(context) {
977
985
  context.errors.push('[E130] Too many "common.news" found in io-package.json. Must be less than 20. Please remove old news.');
978
986
  }
979
987
 
988
+ Object.keys(context.ioPackageJson.common.news).forEach(version => {
989
+ if (!compareVersions.validateStrict(version)) {
990
+ context.errors.push(`[E175] Release "${version}" at "common.news" in io-package.json is malformed.`);
991
+ }
992
+ });
993
+
980
994
  if (!context.ioPackageJson.common.news[context.ioPackageJson.common.version]) {
981
995
  context.errors.push(`[E145] No "common.news" found for actual version ${context.ioPackageJson.common.version}`);
982
996
  }
@@ -1109,6 +1123,16 @@ function checkIOPackageJson(context) {
1109
1123
  }
1110
1124
  }
1111
1125
  }
1126
+
1127
+ /*
1128
+ - adapter-core 3.0.0+ requires node 16+ (*** TODO ***)
1129
+ - adapter-core 3.0.6 is recommended as minimum
1130
+ */
1131
+ if (!compareVersions.compare(context.packageJson.dependencies['@iobroker/adapter-core'], `${recommendedJsControllerVersion}`, '>=')) {
1132
+ context.warnings.push(`[W173] "@iobroker/adapter-core" should be release ${recommendedAdapterCoreVersion} or newer - please update`);
1133
+ } else {
1134
+ context.checks.push(`adapter-core ${context.packageJson.dependencies['@iobroker/adapter-core']} matches recommendation`);
1135
+ }
1112
1136
  }
1113
1137
 
1114
1138
  if (context.ioPackageJson.common.protectedNative) {
@@ -1135,16 +1159,85 @@ function checkIOPackageJson(context) {
1135
1159
  }
1136
1160
  }
1137
1161
 
1138
- if (!context.ioPackageJson.common.tier) {
1139
- context.warnings.push(`[W115] common.tier is required in io-package.json`);
1140
- } else if (![1, 2, 3].includes(context.ioPackageJson.common.tier)) {
1141
- context.errors.push(`[E155] Invalid common.tier value: ${context.ioPackageJson.common.tier}. Only 1, 2 or 3 are allowed!`);
1162
+ if (!context.ioPackageJson.common.onlyWWW) {
1163
+ if (!context.ioPackageJson.common.tier) {
1164
+ context.warnings.push(`[W115] common.tier is required in io-package.json. Please check https://https://github.com/ioBroker/ioBroker.docs/blob/master/docs/en/dev/objectsschema.md#adapter.`);
1165
+ } else if (![1, 2, 3].includes(context.ioPackageJson.common.tier)) {
1166
+ context.errors.push(`[E155] Invalid common.tier value: ${context.ioPackageJson.common.tier}. Only 1, 2 or 3 are allowed!`);
1167
+ } else {
1168
+ context.checks.push('"common.tier" is valid in io-package.json');
1169
+ }
1142
1170
  } else {
1143
- context.checks.push('"common.tier" is valid in io-package.json');
1171
+ context.checks.push('"common.tier" check skipped for wwwOnly adapter.');
1144
1172
  }
1145
1173
 
1146
1174
  if (context.ioPackageJson.common.automaticUpgrade) {
1147
- context.errors.push(`[E172] common.automaticUpgrade will be defined by the user. Remove the attribute from io-package.json`);
1175
+ context.errors.push(`[E172] "common.automaticUpgrade" will be defined by the user. Please remove from io-package.json`);
1176
+ } else {
1177
+ context.checks.push('"common.automaticUpgrade" does not exist in io-package.json');
1178
+ }
1179
+
1180
+ if (context.ioPackageJson.common.wakeup) {
1181
+ context.warnings.push(`[W174] "common.wakeup" is deprectaed. Please remove from io-package.json`);
1182
+ } else {
1183
+ context.checks.push('"common.wakeup" does not exist in io-package.json');
1184
+ }
1185
+
1186
+ /*
1187
+ * The following check is logical related to package.json. It is placed here as the check must be performed only
1188
+ * if wwwOnly attribute is not set at io-package.json. Please note that these errors use error number form package.json range.
1189
+ *
1190
+ */
1191
+
1192
+ if (!context.ioPackageJson.common.onlyWWW) {
1193
+ if (!context.packageJson.engines) {
1194
+ context.warnings.push(`[W026] "{'engines' : { 'node' >= '${recommendedNodeVersion}' } }" is required at package.json`);
1195
+ } else {
1196
+ if (!context.packageJson.engines.node) {
1197
+ context.warnings.push(`[W026] "{'engines' : { 'node' >= '${recommendedNodeVersion}' } }" is required at package.json`);
1198
+ } else {
1199
+ context.checks.push('engines attribute containing node requirements exist.');
1200
+ // 'engines': { 'node': '>= 18' }
1201
+ // 'engines': { 'node': '>= 18.1.2' }
1202
+ // 'engines': { 'node': '>= 18.1.2 < 19' }
1203
+ const nodeVal = context.packageJson.engines.node;
1204
+ let match = nodeVal.match(/^^(?<cmp>[<>=~]+)?\s*(?<vers>\d+(\.\d+(\.\d+)?)?(\-\w+\.\d+)?)/m);
1205
+ if ( ! match ) {
1206
+ context.warnings.push(`[W027] {'engines' : { 'node' : '${nodeVal}' } }" is not parseable.`);
1207
+ } else {
1208
+ //console.log( `${JSON.stringify(match.groups)}`);
1209
+ if ( match.groups.cmp !== '>' && match.groups.cmp !== '>=' ) {
1210
+ context.warnings.push(`[W026] "{'engines' : { 'node' >= '${recommendedNodeVersion}' } }" is required at package.json`);
1211
+ } else {
1212
+ //console.log( `${match.groups.vers} - ${recommendedNodeVersion}`);
1213
+ if ( ! compareVersions.compare( match.groups.vers, requiredNodeVersion, '>=')) {
1214
+ context.errors.push(`[E029] Node.js ${requiredNodeVersion} is required as minimum, node.js ${recommendedNodeVersion} is recommended. Please adapt "{'engines' : { 'node' >= '${match.groups.vers}' } }" at package.json.`);
1215
+ } else if ( ! compareVersions.compare( match.groups.vers, recommendedNodeVersion, '>=')) {
1216
+ context.warnings.push(`[W028] Minimum node.js version ${recommendedNodeVersion} recommended. Please adapt "{'engines' : { 'node' >= '${match.groups.vers}' } }" at package.json.`);
1217
+ } else {
1218
+ context.checks.push('Correct node.js version requested by "engines" attribute at package.json.');
1219
+ }
1220
+ }
1221
+ }
1222
+ }
1223
+ }
1224
+ } else {
1225
+ context.checks.push('"engines" check skipped for wwwOnly adapter.');
1226
+ }
1227
+ /* end of foreign check */
1228
+
1229
+
1230
+ if (context.ioPackageJson.common.restartAdapters) {
1231
+ const restartAdaptersArray = context.ioPackageJson.common.restartAdapters;
1232
+
1233
+ // own adapter is not allowed in restart array
1234
+ if (restartAdaptersArray.includes(context.ioPackageJson.common.name)) {
1235
+ context.errors.push(`[E176] Own adapter is not allowed to be listed at "common.restartAdapters" in io-pacakge.json`);
1236
+ } else {
1237
+ context.checks.push('Own adapter not listed at "common.restartAdapters".');
1238
+ }
1239
+ } else {
1240
+ context.checks.push('"restartAdapters" check skipped as object not present.');
1148
1241
  }
1149
1242
 
1150
1243
  if (context.ioPackageJson.common.extIcon) {
@@ -1179,7 +1272,7 @@ function checkIOPackageJson(context) {
1179
1272
  }
1180
1273
  // do not put any code behind this line
1181
1274
 
1182
- // max number is E172
1275
+ // max number is E176
1183
1276
  }
1184
1277
  });
1185
1278
  });
@@ -1187,7 +1280,7 @@ function checkIOPackageJson(context) {
1187
1280
 
1188
1281
  // E2xx
1189
1282
  function checkNpm(context) {
1190
- console.log('checkNpm [E2xx]');
1283
+ console.log('\ncheckNpm [E2xx]');
1191
1284
  return axios(`https://registry.npmjs.org/iobroker.${context.adapterName}`)
1192
1285
  .catch(() => ({body: null}))
1193
1286
  .then(async response => {
@@ -1240,7 +1333,7 @@ function checkNpm(context) {
1240
1333
 
1241
1334
  // E3xx
1242
1335
  function checkTests(context) {
1243
- console.log('checkTests [E3xx]');
1336
+ console.log('\ncheckTests [E3xx]');
1244
1337
  // if found some file in `\.github\workflows` with the test inside => it is OK too
1245
1338
  if (context && context.filesList.find(name => name.startsWith('.github/workflows/') && name.endsWith('.yml') && name.toLowerCase().includes('test'))) {
1246
1339
  context.checks.push('Tests found on github actions');
@@ -1288,7 +1381,7 @@ function checkTests(context) {
1288
1381
 
1289
1382
  // E4xx
1290
1383
  function checkRepo(context) {
1291
- console.log('checkRepo [E4xx]');
1384
+ console.log('\ncheckRepo [E4xx]');
1292
1385
  if (context.ioPackageJson && context.ioPackageJson.common && context.ioPackageJson.common.type) {
1293
1386
  // download latest repo
1294
1387
  return axios('https://raw.githubusercontent.com/ioBroker/ioBroker.repositories/master/sources-dist.json')
@@ -1480,7 +1573,7 @@ function checkCode(context) {
1480
1573
 
1481
1574
  // https://github.com/userName/ioBroker.adaptername/archive/${context.branch}.zip
1482
1575
  return new Promise((resolve, reject) => {
1483
- console.log('checkCode [E5xx]');
1576
+ console.log('\ncheckCode [E5xx]');
1484
1577
  return downloadFile(context.githubUrlOriginal, `/archive/${context.branch}.zip`, true)
1485
1578
  .then(data => {
1486
1579
  console.log(`${context.branch}.zip ${data.length} bytes`);
@@ -1686,7 +1779,7 @@ function checkCommits(context) {
1686
1779
  // E8xx
1687
1780
  function checkGithubRepo(context) {
1688
1781
  return new Promise((resolve) => {
1689
- console.log('checkGithubRepo [E8xx]');
1782
+ console.log('\ncheckGithubRepo [E8xx]');
1690
1783
 
1691
1784
  if (!context.githubApiData.description) {
1692
1785
  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.`);
@@ -1713,7 +1806,7 @@ function checkGithubRepo(context) {
1713
1806
  function checkReadme(context) {
1714
1807
  // https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/README.md
1715
1808
  return new Promise((resolve, reject) => {
1716
- console.log('checkReadme [E6xx]');
1809
+ console.log('\ncheckReadme [E6xx]');
1717
1810
  downloadFile(context.githubUrl, '/README.md')
1718
1811
  .then(data => {
1719
1812
  if (!data) {
@@ -1764,7 +1857,7 @@ function checkReadme(context) {
1764
1857
  function checkLicenseFile(context) {
1765
1858
  // https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/LICENSE
1766
1859
  return new Promise((resolve, reject) => {
1767
- console.log('checkLicenseFile [E7xx]');
1860
+ console.log('\ncheckLicenseFile [E7xx]');
1768
1861
  downloadFile(context.githubUrl, '/LICENSE')
1769
1862
  .then(data => {
1770
1863
  if (!data) {
@@ -1827,7 +1920,7 @@ function checkNpmIgnore(context) {
1827
1920
  ];
1828
1921
 
1829
1922
  // https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/.npmignore
1830
- console.log('checkNpmIgnore [E8xx]');
1923
+ console.log('\checkNpmIgnore [E8xx]');
1831
1924
  if (context.packageJson.files && context.packageJson.files.length) {
1832
1925
  return Promise.resolve(context);
1833
1926
  }
@@ -1889,7 +1982,7 @@ function checkGitIgnore(context) {
1889
1982
  ];
1890
1983
 
1891
1984
  // https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/.gitignore
1892
- console.log('checkGitIgnore [E9xx]');
1985
+ console.log('\ncheckGitIgnore [E9xx]');
1893
1986
  if (!context.filesList.includes('.gitignore')) {
1894
1987
  context.warnings.push(`[W901] .gitignore not found`);
1895
1988
  } else {
@@ -2044,7 +2137,7 @@ if (typeof module !== 'undefined' && module.parent) {
2044
2137
  console.log('\n\n########## SUMMARY ##########');
2045
2138
  if (context.errors.length) {
2046
2139
  console.log('\n\nErrors:');
2047
- context.errors.forEach(err => {
2140
+ context.errors.sort().forEach(err => {
2048
2141
  const issue = err.substring(1, 5);
2049
2142
  console.error(err);
2050
2143
  if (issues[issue]) {
@@ -2068,11 +2161,10 @@ if (typeof module !== 'undefined' && module.parent) {
2068
2161
  }
2069
2162
  if (context.warnings.length) {
2070
2163
  console.log('\nWarnings:');
2071
- context.warnings.forEach(err => {
2164
+ context.warnings.sort().forEach(err => {
2072
2165
  const issue = err.substring(1, 5);
2166
+ console.warn(err);
2073
2167
  if (issues[issue]) {
2074
- console.warn(err);
2075
-
2076
2168
  //if (issues[issue].title) {
2077
2169
  // console.warn(getText(issues[issue].title, 'en'));
2078
2170
  //}
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.2.0",
2
+ "version": "2.2.1",
3
3
  "name": "@iobroker/repochecker",
4
4
  "dependencies": {
5
5
  "axios": "^1.6.8",