@iobroker/repochecker 2.1.4 → 2.1.6

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 +6 -0
  2. package/index.js +43 -24
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -20,6 +20,12 @@ Branch (`master/main/dev`) is optional.
20
20
  -->
21
21
 
22
22
  ## Changelog
23
+ ### 2.1.6 (2022-12-08)
24
+ * (bluefox) added better error logging
25
+
26
+ ### 2.1.5 (2022-12-07)
27
+ * (bluefox) added check of `.releaseconfig.json` file
28
+
23
29
  ### 2.1.4 (2022-08-19)
24
30
  * (bluefox) Added check for adapter name: it may not start with '_'
25
31
 
package/index.js CHANGED
@@ -235,24 +235,24 @@ 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: ' + 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
- context.checks.push('Repository type is valid: git');
240
+ context.checks.push('Repository type is valid in package.json: git');
241
241
  }
242
242
 
243
243
  if (!allowedRepoUrls.includes(context.packageJson.repository.url)) {
244
- context.errors.push(`[E019] Invalid repository URL: ${context.packageJson.repository.url}. Expected: ${context.githubApiData.ssh_url} or ${context.githubApiData.clone_url}`);
244
+ context.errors.push(`[E019] Invalid repository URL in package.json: ${context.packageJson.repository.url}. Expected: ${context.githubApiData.ssh_url} or ${context.githubApiData.clone_url}`);
245
245
  } else {
246
246
  context.checks.push('Repository URL is valid in package.json');
247
247
  }
248
248
  } else if (context.packageJson.repository && typeof context.packageJson.repository === 'string') {
249
249
  if (!allowedRepoUrls.includes(context.packageJson.repository)) {
250
- context.errors.push(`[E019] Invalid repository URL: ${context.packageJson.repository}. Expected: ${context.githubApiData.ssh_url} or ${context.githubApiData.clone_url}`);
250
+ context.errors.push(`[E019] Invalid repository URL in package.json: ${context.packageJson.repository}. Expected: ${context.githubApiData.ssh_url} or ${context.githubApiData.clone_url}`);
251
251
  } else {
252
252
  context.checks.push('Repository URL is valid in package.json');
253
253
  }
254
254
  } else {
255
- context.errors.push('[E019] Invalid repository URL');
255
+ context.errors.push('[E019] Invalid repository URL in package.json');
256
256
  }
257
257
  }
258
258
 
@@ -284,6 +284,7 @@ const allowedLanguages = [
284
284
  'it',
285
285
  'es',
286
286
  'pl',
287
+ 'uk',
287
288
  'zh-cn'
288
289
  ];
289
290
 
@@ -851,7 +852,7 @@ function checkIOPackageJson(context) {
851
852
  }
852
853
 
853
854
  if (!(context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'json')) {
854
- context.warnings.push('[W156] Adapter should support admin 5 UI (jsonConfig)');
855
+ context.warnings.push('[W156] Adapter should support admin 5 UI (jsonConfig) if you do not use a React based UI');
855
856
  }
856
857
  } else {
857
858
  context.checks.push('adapter has no admin config');
@@ -1065,11 +1066,11 @@ function checkIOPackageJson(context) {
1065
1066
  }
1066
1067
  } else if (context.packageJson.dependencies['@iobroker/adapter-core'].includes('2.4') || context.packageJson.dependencies['@iobroker/adapter-core'].includes('2.5') || context.packageJson.dependencies['@iobroker/adapter-core'].includes('2.6')) {
1067
1068
  if (!context.ioPackageJson.common.dependencies) {
1068
- context.errors.push(`[E154] common.dependencies must contain {"js-controller": ">=2.0.0"} or later - recommended: {"js-controller": ">=${recommendedJsControllerVersion}"}`);
1069
+ context.errors.push(`[E154] common.dependencies must contain [{"js-controller": ">=2.0.0"}] or later - recommended: [{"js-controller": ">=${recommendedJsControllerVersion}"}]`);
1069
1070
  } else {
1070
1071
  if (currentJsControllerVersion) {
1071
1072
  if (!compareVersions.compare(currentJsControllerVersion, '2.0.0', '>=')) {
1072
- context.errors.push(`[E154] common.dependencies must contain {"js-controller": ">=2.0.0"} or later - recommended: {"js-controller": ">=${recommendedJsControllerVersion}"}`);
1073
+ context.errors.push(`[E154] common.dependencies must contain [{"js-controller": ">=2.0.0"}] or later - recommended: [{"js-controller": ">=${recommendedJsControllerVersion}"}]`);
1073
1074
  } else {
1074
1075
  context.checks.push('adapter-core >=2.4 dependency matches js-controller dependency');
1075
1076
  }
@@ -1149,7 +1150,7 @@ function checkIOPackageJson(context) {
1149
1150
  // E2xx
1150
1151
  function checkNpm(context) {
1151
1152
  console.log('checkNpm [E2xx]');
1152
- return axios('https://api.npms.io/v2/package/iobroker.' + context.adapterName)
1153
+ return axios(`https://registry.npmjs.org/iobroker.${context.adapterName}`)
1153
1154
  .catch(() => ({body: null}))
1154
1155
  .then(async response => {
1155
1156
  let body = response.data;
@@ -1176,23 +1177,19 @@ function checkNpm(context) {
1176
1177
  }
1177
1178
  } else {
1178
1179
  context.checks.push('Adapter found on npm');
1179
- if (!body.collected ||
1180
- !body.collected.metadata ||
1181
- !body.collected.metadata.maintainers ||
1182
- !body.collected.metadata.maintainers.length ||
1183
- !body.collected.metadata.maintainers.find(user => user.username === 'bluefox' || user.username === 'iobluefox')) {
1180
+ if (!body.maintainers ||
1181
+ !body.maintainers.length ||
1182
+ !body.maintainers.find(user => user.name === 'bluefox' || user.name === 'iobluefox')) {
1184
1183
  context.errors.push(`[E201] Bluefox was not found in the collaborators on NPM!. Please execute in adapter directory: "npm owner add bluefox iobroker.${context.adapterName}"`);
1185
1184
  } else {
1186
1185
  context.checks.push('Bluefox found in collaborators on NPM');
1187
1186
  }
1188
1187
 
1189
- if (!body.collected ||
1190
- !body.collected.metadata ||
1191
- !body.collected.metadata.version ||
1192
- context.packageJson.version !== body.collected.metadata.version
1188
+ if (!body['dist-tags'] ||
1189
+ context.packageJson.version !== body['dist-tags'].latest
1193
1190
  ) {
1194
1191
  context.warnings.push(`[W202] Version of package.json (${context.packageJson.version}) doesn't match latest version on NPM (${
1195
- (body && body.collected && body.collected.metadata && body.collected.metadata.version) || JSON.stringify(body)})`);
1192
+ (body['dist-tags'] && body['dist-tags'].latest) || JSON.stringify(body)})`);
1196
1193
  } else {
1197
1194
  context.checks.push('Version of package.json matches latest version on NPM');
1198
1195
  }
@@ -1404,7 +1401,8 @@ function checkCode(context) {
1404
1401
  '.gitignore',
1405
1402
  'iob_npm.done',
1406
1403
  '.travis.yml',
1407
- 'gulpfile.js'
1404
+ 'gulpfile.js',
1405
+ '.releaseconfig.json',
1408
1406
  ];
1409
1407
 
1410
1408
  if (context.packageJson.main) {
@@ -1422,6 +1420,8 @@ function checkCode(context) {
1422
1420
  readFiles.push('admin/jsonConfig.json5');
1423
1421
  allowedLanguages.forEach(lang =>
1424
1422
  readFiles.push(`admin/i18n/${lang}/translations.json`));
1423
+ allowedLanguages.forEach(lang =>
1424
+ readFiles.push(`admin/i18n/${lang}.json`));
1425
1425
  }
1426
1426
 
1427
1427
  if (context.ioPackageJson.common.supportCustoms || context.ioPackageJson.common.jsonCustom || (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.custom === 'json')) {
@@ -1533,8 +1533,14 @@ function checkCode(context) {
1533
1533
  } catch (e) {
1534
1534
  context.errors.push(`[E509] Cannot parse "admin/i18n/${lang}/translations.json": ${e}`);
1535
1535
  }
1536
+ } else if (context[`/admin/i18n/${lang}.json`]) {
1537
+ try {
1538
+ JSON.parse(context[`/admin/i18n/${lang}.json`]);
1539
+ } catch (e) {
1540
+ context.errors.push(`[E509] Cannot parse "admin/i18n/${lang}.json": ${e}`);
1541
+ }
1536
1542
  } else {
1537
- context.errors.push(`[E510] "/admin/i18n/${lang}/translations.json" not found, but admin support is declared`);
1543
+ context.errors.push(`[E510] "/admin/i18n/${lang}/translations.json" or "admin/i18n/${lang}.json" not found, but admin support is declared`);
1538
1544
  }
1539
1545
  });
1540
1546
  }
@@ -1559,6 +1565,15 @@ function checkCode(context) {
1559
1565
  context.errors.push('[E514] "admin/blockly.js" not found, but blockly support is declared');
1560
1566
  }
1561
1567
 
1568
+ if (context.ioPackageJson.common.javascriptRules) {
1569
+ if (!context.ioPackageJson.common.javascriptRules.url) {
1570
+ context.errors.push('[E515] JavaScript-Rules support is declared, but no location in property url defined');
1571
+ }
1572
+ if (!context['/' + context.ioPackageJson.common.javascriptRules.url]) {
1573
+ context.errors.push('[E516] "' + context.ioPackageJson.common.javascriptRules.url + '" not found, but JavaScript-Rules support is declared');
1574
+ }
1575
+ }
1576
+
1562
1577
  if (context['/iob_npm.done']) {
1563
1578
  context.errors.push('[E503] "iob_npm.done" found in repo! Remove that file');
1564
1579
  }
@@ -1571,6 +1586,10 @@ function checkCode(context) {
1571
1586
  context.warnings.push('[W513] "gulpfile.js" found in repo! Think about migrating to @iobroker/adapter-dev package');
1572
1587
  }
1573
1588
 
1589
+ if (context.packageJson.devDependencies && context.packageJson.devDependencies['@alcalzone/release-script'] && !context['/.releaseconfig.json']) {
1590
+ context.errors.push('[E518] "@alcalzone/release-script" is used, but ".releaseconfig.json" not found');
1591
+ }
1592
+
1574
1593
  if (context.packageJson.main && context.packageJson.main.endsWith('.js')) {
1575
1594
  if (!context['/' + context.packageJson.main]) {
1576
1595
  context.errors.push(`[E504] "${context.packageJson.main}" found in package.json, but not found as file`);
@@ -1593,7 +1612,7 @@ function checkCode(context) {
1593
1612
  }
1594
1613
  }
1595
1614
  }
1596
- // max E515
1615
+ // max E518
1597
1616
  resolve(context);
1598
1617
  })
1599
1618
  .catch(e => reject(e));
@@ -1925,7 +1944,7 @@ function check(request, ctx, callback) {
1925
1944
  }));
1926
1945
  })
1927
1946
  .catch(err => {
1928
- console.error('GLOBAL ERROR' + err);
1947
+ console.error(`GLOBAL ERROR: ${err.toString()}, ${JSON.stringify(err)}`);
1929
1948
 
1930
1949
  return callback(null, makeResponse(200, {
1931
1950
  result: 'Errors found',
@@ -1943,7 +1962,7 @@ function check(request, ctx, callback) {
1943
1962
  if (typeof module !== 'undefined' && module.parent) {
1944
1963
  exports.handler = check;
1945
1964
  } else {
1946
- let repoUrl = 'https://github.com/Dirk-Peter-md/ioBroker.sprinklecontrol';
1965
+ let repoUrl = 'https://github.com/ioBroker/ioBroker.ekey';
1947
1966
  let repoBranch = null;
1948
1967
 
1949
1968
  // Get url from parameters if possible
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
- "version": "2.1.4",
2
+ "version": "2.1.6",
3
3
  "name": "@iobroker/repochecker",
4
4
  "dependencies": {
5
- "axios": "^0.27.2",
6
- "compare-versions": "^4.1.3",
5
+ "axios": "^1.2.1",
6
+ "compare-versions": "^5.0.1",
7
7
  "image-size": "^1.0.2",
8
8
  "unzipper": "^0.10.11",
9
9
  "json5": "^2.2.1"
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "devDependencies": {
15
15
  "@alcalzone/release-script": "^3.5.9",
16
- "eslint": "^8.22.0"
16
+ "eslint": "^8.29.0"
17
17
  },
18
18
  "files": [
19
19
  "index.js"