@iobroker/repochecker 2.1.7 → 2.1.10

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.
Files changed (3) hide show
  1. package/README.md +5 -2
  2. package/index.js +40 -35
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -20,6 +20,9 @@ Branch (`master/main/dev`) is optional.
20
20
  -->
21
21
 
22
22
  ## Changelog
23
+ ### 2.1.10 (2023-09-04)
24
+ * (bluefox) Added check of iobroker.js-controller in dependencies
25
+
23
26
  ### 2.1.7 (2023-08-14)
24
27
  * (mcm57) Update index.js - fix typo in error message (packet.json)
25
28
  * (mcm57) Update index.js - renumber E504/1 to 519 - fixes #112
@@ -37,7 +40,7 @@ Branch (`master/main/dev`) is optional.
37
40
  * (bluefox) Fixed some errors
38
41
 
39
42
  ### 2.1.0 (2022-05-26)
40
- * (bluefox) Added support of jsonConfig.json5 and jsonCustom.json5
43
+ * (bluefox) Added support for jsonConfig.json5 and jsonCustom.json5
41
44
 
42
45
  ### 2.0.5 (2022-05-22)
43
46
  * (bluefox) Made it possible to run with npx
@@ -45,7 +48,7 @@ Branch (`master/main/dev`) is optional.
45
48
  ## License
46
49
  The MIT License (MIT)
47
50
 
48
- Copyright (c) 2014-2022 Bluefox <dogafox@gmail.com>
51
+ Copyright (c) 2014-2022 Denis Haev <dogafox@gmail.com>
49
52
 
50
53
  Permission is hereby granted, free of charge, to any person obtaining a copy
51
54
  of this software and associated documentation files (the "Software"), to deal
package/index.js CHANGED
@@ -22,13 +22,13 @@ const JSON5 = require('json5');
22
22
  const compareVersions = require('compare-versions');
23
23
 
24
24
  const version = require('./package.json').version;
25
- const recommendedJsControllerVersion = '3.3.22';
25
+ const recommendedJsControllerVersion = '5.0.11';
26
26
 
27
27
  const memStore = {};
28
28
 
29
29
  /* Writable memory stream */
30
30
  function WMStrm(key, options) {
31
- // allow use without new operator
31
+ // allow use without a new operator
32
32
  if (!(this instanceof WMStrm)) {
33
33
  return new WMStrm(key, options);
34
34
  }
@@ -51,7 +51,7 @@ WMStrm.prototype._write = function (chunk, enc, cb) {
51
51
  };
52
52
 
53
53
  function downloadFile(githubUrl, path, binary, noError) {
54
- console.log('Download ' + githubUrl + (path || ''));
54
+ console.log(`Download ${githubUrl}${path || ''}`);
55
55
  const options = {};
56
56
  if (binary) {
57
57
  options.responseType = 'arraybuffer';
@@ -116,7 +116,7 @@ function checkPackageJson(context) {
116
116
  try {
117
117
  context.packageJson = JSON.parse(context.packageJson);
118
118
  } catch (e) {
119
- context.errors.push('[E001] Cannot parse package.json: ' + e);
119
+ context.errors.push(`[E001] Cannot parse package.json: ${e}`);
120
120
  return context;
121
121
  }
122
122
  }
@@ -136,7 +136,7 @@ function checkPackageJson(context) {
136
136
  const m = context.githubUrlOriginal.match(/\/ioBroker\.(.*)$/);
137
137
  let adapterName = '';
138
138
  if (!m || !m[1]) {
139
- context.errors.push('[E004] No adapter name found in URL: ' + context.githubUrlOriginal);
139
+ context.errors.push(`[E004] No adapter name found in URL: ${context.githubUrlOriginal}`);
140
140
  } else {
141
141
  context.checks.push('Adapter name found in the URL');
142
142
  adapterName = m[1].replace(/\/master$/, '').replace(/\/main$/, '');
@@ -235,7 +235,7 @@ function checkPackageJson(context) {
235
235
  // https://docs.npmjs.com/cli/v7/configuring-npm/package-json#repository
236
236
  if (context.packageJson.repository && typeof context.packageJson.repository === 'object') {
237
237
  if (context.packageJson.repository.type !== 'git') {
238
- context.errors.push('[E018] Invalid repository type in package.json: ' + context.packageJson.repository.type + '. It should be git');
238
+ context.errors.push(`[E018] Invalid repository type in package.json: ${context.packageJson.repository.type}. It should be git`);
239
239
  } else {
240
240
  context.checks.push('Repository type is valid in package.json: git');
241
241
  }
@@ -268,7 +268,12 @@ function checkPackageJson(context) {
268
268
  context.checks.push('npm is not in dependencies');
269
269
  }
270
270
 
271
- // max number is E024
271
+ if ((context.packageJson.dependencies && context.packageJson.dependencies['iobroker.js-controller']) || (context.packageJson.optionalDependencies && context.packageJson.optionalDependencies['iobroker.js-controller'])) {
272
+ context.errors.push('[E025] Do not include "iobroker.js-controller" as dependency!');
273
+ } else {
274
+ context.checks.push('iobroker.js-controller is not in dependencies');
275
+ }
276
+ // max number is E025
272
277
 
273
278
  return context;
274
279
  });
@@ -717,7 +722,7 @@ function checkIOPackageJson(context) {
717
722
  try {
718
723
  context.ioPackageJson = JSON.parse(context.ioPackageJson);
719
724
  } catch (e) {
720
- context.errors.push('[E100] Cannot parse io-package.json: ' + e);
725
+ context.errors.push(`[E100] Cannot parse io-package.json: ${e}`);
721
726
  return resolve(context);
722
727
  }
723
728
  }
@@ -749,20 +754,20 @@ function checkIOPackageJson(context) {
749
754
  context.checks.push('"common.titleLang" found in io-package.json');
750
755
 
751
756
  if (typeof context.ioPackageJson.common.titleLang !== 'object') {
752
- context.errors.push('[E105] "common.titleLang" must be an object. Now: ' + JSON.stringify(context.ioPackageJson.common.titleLang));
757
+ context.errors.push(`[E105] "common.titleLang" must be an object. Now: ${JSON.stringify(context.ioPackageJson.common.titleLang)}`);
753
758
  } else if (!checkLanguages(context.ioPackageJson.common.titleLang)) {
754
759
  context.warnings.push(`[W105] "common.titleLang" should be translated into all supported languages (${allowedLanguages.join(', ')})`);
755
760
  } else {
756
761
  Object.keys(context.ioPackageJson.common.titleLang).forEach(lang => {
757
762
  const text = context.ioPackageJson.common.titleLang[lang];
758
763
  if (text.match(/iobroker/i)) {
759
- context.errors.push('[W105] "common.titleLang" should not have ioBroker in the name. It is clear, for what this adapter was created. Now: ' + JSON.stringify(context.ioPackageJson.common.titleLang));
764
+ context.errors.push(`[W105] "common.titleLang" should not have ioBroker in the name. It is clear, for what this adapter was created. Now: ${JSON.stringify(context.ioPackageJson.common.titleLang)}`);
760
765
  } else {
761
766
  context.checks.push('"common.titleLang" has no ioBroker in it in io-package.json');
762
767
  }
763
768
 
764
769
  if (text.match(/\sadapter|adapter\s/i)) {
765
- context.errors.push('[E106] "common.titleLang" should not contain word "adapter" in the name. It is clear, that this is adapter. Now: ' + JSON.stringify(context.ioPackageJson.common.titleLang));
770
+ context.errors.push(`[E106] "common.titleLang" should not contain word "adapter" in the name. It is clear, that this is adapter. Now: ${JSON.stringify(context.ioPackageJson.common.titleLang)}`);
766
771
  } else {
767
772
  context.checks.push('"common.titleLang" has no "adapter" in it in io-package.json');
768
773
  }
@@ -788,7 +793,7 @@ function checkIOPackageJson(context) {
788
793
  context.checks.push('"common.desc" found in io-package.json');
789
794
 
790
795
  if (typeof context.ioPackageJson.common.desc !== 'object') {
791
- context.errors.push('[E109] "common.desc" in io-package.json should be an object for many languages. Found only ' + context.ioPackageJson.common.desc);
796
+ context.errors.push(`[E109] "common.desc" in io-package.json should be an object for many languages. Found only "${context.ioPackageJson.common.desc}"`);
792
797
  } else if (!checkLanguages(context.ioPackageJson.common.desc)) {
793
798
  context.warnings.push(`[W109] "common.desc" should be translated into all supported languages (${allowedLanguages.join(', ')})`);
794
799
  } else {
@@ -878,7 +883,7 @@ function checkIOPackageJson(context) {
878
883
  context.ioPackageJson.common.license !== context.packageJson.license) {
879
884
  context.errors.push('[E117] Licenses in package.json and in io-package.json are different');
880
885
  } else {
881
- context.checks.push('"common.license" is equal in pacjage.json and in io-package.json');
886
+ context.checks.push('"common.license" is equal in package.json and in io-package.json');
882
887
  }
883
888
  }
884
889
 
@@ -983,7 +988,7 @@ function checkIOPackageJson(context) {
983
988
 
984
989
  instanceObjects.forEach(instanceObject => {
985
990
  if (instanceObject.type !== undefined && !allowedObjectTypes.includes(instanceObject.type)) {
986
- context.errors.push('[E147] instanceObject type has an invalid type: ' + instanceObject.type);
991
+ context.errors.push(`[E147] instanceObject type has an invalid type: ${instanceObject.type}`);
987
992
  }
988
993
 
989
994
  if (instanceObject.common) {
@@ -993,7 +998,7 @@ function checkIOPackageJson(context) {
993
998
  }
994
999
 
995
1000
  if (instanceObject.type === 'state' && !allowedStateTypes.includes(instanceObject.common.type)) {
996
- context.errors.push('[E149] instanceObject common.type has an invalid value: ' + instanceObject.common.type);
1001
+ context.errors.push(`[E149] instanceObject common.type has an invalid value: ${instanceObject.common.type}`);
997
1002
  }
998
1003
  }
999
1004
  }
@@ -1203,13 +1208,13 @@ function checkNpm(context) {
1203
1208
  // E3xx
1204
1209
  function checkTests(context) {
1205
1210
  console.log('checkTests [E3xx]');
1206
- // if found some file in \.github\workflows with test inside => it is OK too
1211
+ // if found some file in `\.github\workflows` with the test inside => it is OK too
1207
1212
  if (context && context.filesList.find(name => name.startsWith('.github/workflows/') && name.endsWith('.yml') && name.toLowerCase().includes('test'))) {
1208
1213
  context.checks.push('Tests found on github actions');
1209
1214
  return Promise.resolve(context);
1210
1215
  }
1211
1216
 
1212
- const travisURL = context.githubUrlOriginal.replace('github.com', 'api.travis-ci.org') + '.png';
1217
+ const travisURL = `${context.githubUrlOriginal.replace('github.com', 'api.travis-ci.org')}.png`;
1213
1218
 
1214
1219
  return axios(travisURL)
1215
1220
  .then(response => {
@@ -1261,14 +1266,14 @@ function checkRepo(context) {
1261
1266
  } else {
1262
1267
  context.latestRepo = body;
1263
1268
  if (!context.latestRepo[context.adapterName]) {
1264
- context.warnings.push('[W400] Cannot find "' + context.adapterName + '" in latest repository');
1269
+ context.warnings.push(`[W400] Cannot find "${context.adapterName}" in latest repository`);
1265
1270
  } else {
1266
1271
  context.checks.push('Adapter found in latest repository');
1267
1272
 
1268
1273
  if (context.latestRepo[context.adapterName].type !== context.ioPackageJson.common.type) {
1269
- context.errors.push('[E402] Types of adapter in latest repository and in io-package.json are different "' + context.latestRepo[context.adapterName].type + '" !== "' + context.ioPackageJson.common.type + '"');
1274
+ context.errors.push(`[E402] Types of adapter in latest repository and in io-package.json are different "${context.latestRepo[context.adapterName].type}" !== "${context.ioPackageJson.common.type}"`);
1270
1275
  } else {
1271
- context.checks.push('Types of adapter in latest repository and in io-package.json are equal: "' + context.latestRepo[context.adapterName].type + '"');
1276
+ context.checks.push(`Types of adapter in latest repository and in io-package.json are equal: "${context.latestRepo[context.adapterName].type}"`);
1272
1277
  }
1273
1278
 
1274
1279
  if (context.latestRepo[context.adapterName].version) {
@@ -1285,7 +1290,7 @@ function checkRepo(context) {
1285
1290
  context.checks.push('Icon found in latest repository');
1286
1291
 
1287
1292
  if (!context.latestRepo[context.adapterName].icon.startsWith(url)) {
1288
- context.errors.push('[E405] Icon must be in the following path: ' + url);
1293
+ context.errors.push(`[E405] Icon (latest) must be in the following path: ${url}`);
1289
1294
  } else {
1290
1295
  context.checks.push('Icon found in latest repository');
1291
1296
  }
@@ -1295,7 +1300,7 @@ function checkRepo(context) {
1295
1300
  } else {
1296
1301
  context.checks.push('Meta URL(latest) found in latest repository');
1297
1302
 
1298
- if (context.latestRepo[context.adapterName].meta !== url + 'io-package.json') {
1303
+ if (context.latestRepo[context.adapterName].meta !== `${url}io-package.json`) {
1299
1304
  context.errors.push(`[E407] Meta URL (latest) must be equal to ${url}io-package.json`);
1300
1305
  } else {
1301
1306
  context.checks.push('Meta URL (latest) is OK in latest repository');
@@ -1313,9 +1318,9 @@ function checkRepo(context) {
1313
1318
  context.stableRepo = body;
1314
1319
  if (context.stableRepo[context.adapterName]) {
1315
1320
  if (context.stableRepo[context.adapterName].type !== context.ioPackageJson.common.type) {
1316
- context.errors.push('[E422] Types of adapter in stable repository and in io-package.json are different "' + context.stableRepo[context.adapterName].type + '" !== "' + context.ioPackageJson.common.type + '"');
1321
+ context.errors.push(`[E422] Types of adapter in stable repository and in io-package.json are different "${context.stableRepo[context.adapterName].type}" !== "${context.ioPackageJson.common.type}"`);
1317
1322
  } else {
1318
- context.checks.push('Types of adapter in stable repository and in io-package.json are equal: "' + context.stableRepo[context.adapterName].type + '"');
1323
+ context.checks.push(`Types of adapter in stable repository and in io-package.json are equal: "${context.stableRepo[context.adapterName].type}"`);
1319
1324
  }
1320
1325
 
1321
1326
  if (!context.latestRepo[context.adapterName]) {
@@ -1338,7 +1343,7 @@ function checkRepo(context) {
1338
1343
  context.checks.push('Icon found in stable repository');
1339
1344
 
1340
1345
  if (!context.stableRepo[context.adapterName].icon.startsWith(url)) {
1341
- context.errors.push('[E426] Icon (stable) must be in the following path: ' + url);
1346
+ context.errors.push(`[E426] Icon (stable) must be in the following path: ${url}`);
1342
1347
  } else {
1343
1348
  context.checks.push('Icon (stable) found in latest repository');
1344
1349
  }
@@ -1349,7 +1354,7 @@ function checkRepo(context) {
1349
1354
  } else {
1350
1355
  context.checks.push('Meta URL (stable) found in latest repository');
1351
1356
 
1352
- if (context.stableRepo[context.adapterName].meta !== url + 'io-package.json') {
1357
+ if (context.stableRepo[context.adapterName].meta !== `${url}io-package.json`) {
1353
1358
  context.errors.push(`[E428] Meta URL (stable) must be equal to ${url}io-package.json`);
1354
1359
  } else {
1355
1360
  context.checks.push('Meta URL (stable) is OK in latest repository');
@@ -1386,7 +1391,7 @@ function extractWords(words) {
1386
1391
  lines[0] = lines[0].replace('systemDictionary = ', '');
1387
1392
  lines[lines.length - 1] = lines[lines.length - 1].trim().replace(/};$/, '}');
1388
1393
  words = lines.join('\n');
1389
- const resultFunc = new Function('return ' + words + ';');
1394
+ const resultFunc = new Function(`return ${words};`);
1390
1395
 
1391
1396
  return resultFunc();
1392
1397
  } catch (e) {
@@ -1453,11 +1458,11 @@ function checkCode(context) {
1453
1458
  .on('entry', entry => {
1454
1459
  // console.log('Check ' + entry.path);
1455
1460
  if (!found && entry.type === 'Directory' && entry.path.match(/\/node_modules\/$/)) {
1456
- console.log('Found ' + entry.path);
1461
+ console.log(`Found ${entry.path}`);
1457
1462
  found = true;
1458
1463
  context.errors.push('[E500] node_modules found in repo. Please delete it');
1459
1464
  }
1460
- // Get list of all files and .npmignore + .gitignore
1465
+ // Get a list of all files and `.npmignore` + `.gitignore`
1461
1466
 
1462
1467
  const name = entry.path.replace(/^[^/]+\//, '');
1463
1468
  context.filesList.push(name);
@@ -1466,8 +1471,8 @@ function checkCode(context) {
1466
1471
  promises.push(new Promise(resolve => {
1467
1472
  const wstream = new WMStrm(name);
1468
1473
  wstream.on('finish', () => {
1469
- context['/' + name] = memStore[name].toString();
1470
- resolve(context['/' + name]);
1474
+ context[`/${name}`] = memStore[name].toString();
1475
+ resolve(context[`/${name}`]);
1471
1476
  });
1472
1477
  entry.pipe(wstream);
1473
1478
  }));
@@ -1570,7 +1575,7 @@ function checkCode(context) {
1570
1575
  context.errors.push('[E515] JavaScript-Rules support is declared, but no location in property url defined');
1571
1576
  }
1572
1577
  if (!context.filesList.includes('admin/' + context.ioPackageJson.common.javascriptRules.url)) {
1573
- context.errors.push('[E516] "' + context.ioPackageJson.common.javascriptRules.url + '" not found, but JavaScript-Rules support is declared');
1578
+ context.errors.push(`[E516] "${context.ioPackageJson.common.javascriptRules.url}" not found, but JavaScript-Rules support is declared`);
1574
1579
  }
1575
1580
  }
1576
1581
 
@@ -1594,7 +1599,7 @@ function checkCode(context) {
1594
1599
  if (!context['/' + context.packageJson.main]) {
1595
1600
  context.errors.push(`[E519] "${context.packageJson.main}" found in package.json, but not found as file`);
1596
1601
  } else {
1597
- if (context['/' + context.packageJson.main].includes('setInterval(') && !context['/' + context.packageJson.main].includes('clearInterval(')) {
1602
+ if (context['/' + context.packageJson.main].includes('setInterval(') && !context[`/${context.packageJson.main}`].includes('clearInterval(')) {
1598
1603
  if (context.ioPackageJson.compact) {
1599
1604
  // if compact mode supported, it is critical
1600
1605
  context.errors.push(`[E504] setInterval found in "${context.packageJson.main}", but no clearInterval detected`);
@@ -1807,9 +1812,9 @@ function checkNpmIgnore(context) {
1807
1812
  }
1808
1813
  });
1809
1814
 
1810
- // There's no need to put node_modules in .npmignore. npm will never publish node_modules in the package, except if one of the modules is explicitly mentioned in bundledDependencies.
1815
+ // There's no need to put node_modules in `.npmignore`. npm will never publish node_modules in the package, except if one of the modules is explicitly mentioned in bundledDependencies.
1811
1816
  /*if (!rules.includes('node_modules') && !rules.includes('/node_modules') && !rules.includes('/node_modules/*') && !rules.includes('node_modules/*')) {
1812
- !check && context.errors.push(`[E804] node_modules not found in .npmignore`);
1817
+ !check && context.errors.push(`[E804] node_modules not found in `.npmignore``);
1813
1818
  }*/
1814
1819
  if (!tooComplexToCheck) {
1815
1820
  if (!rules.includes('iob_npm.done') && !rules.includes('/iob_npm.done')) {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
- "version": "2.1.7",
2
+ "version": "2.1.10",
3
3
  "name": "@iobroker/repochecker",
4
4
  "dependencies": {
5
- "axios": "^1.4.0",
5
+ "axios": "^1.5.0",
6
6
  "compare-versions": "^6.1.0",
7
7
  "image-size": "^1.0.2",
8
8
  "unzipper": "^0.10.14",
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "devDependencies": {
15
15
  "@alcalzone/release-script": "^3.6.0",
16
- "eslint": "^8.47.0"
16
+ "eslint": "^8.48.0"
17
17
  },
18
18
  "files": [
19
19
  "index.js"