@iobroker/repochecker 3.0.0-alpha.3 → 3.0.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,7 +20,14 @@ Branch (`master/main/dev`) is optional.
20
20
  -->
21
21
 
22
22
  ## Changelog
23
- ### 3.0.0-alpha.3 (2024-09-10)
23
+ ### 3.0.1 (2024-09-11)
24
+ * (mcm1957) Handling of missing LICENSE file corrected. [#282]
25
+ * (mcm1957) [W126] Missing mandatory translation is error now. [#293]
26
+ * (mcm1957) Record repochcker version used for tests.
27
+ * (mcm1957) Record github commit-sha of last commit used for tests.
28
+
29
+ ### 3.0.0 (2024-09-10)
30
+ * (mcm1957) Error and warning numbering has been reviewed and duplicates removed.
24
31
  * (mcm1957) index.js has been split into seperated modules.
25
32
 
26
33
  ### 2.10.0 (2024-08-19)
package/index.js CHANGED
@@ -128,6 +128,7 @@ function check(request, ctx, callback) {
128
128
  githubUrl = githubUrl.substring(0, githubUrl.length - 1);
129
129
  }
130
130
 
131
+ context.version = version;
131
132
  config.initConfig(context);
132
133
 
133
134
  context.githubUrlOriginal = githubUrl;
@@ -156,7 +157,8 @@ function check(request, ctx, callback) {
156
157
  errors: context.errors,
157
158
  warnings: context.warnings,
158
159
  version,
159
- hasTravis: context.hasTravis
160
+ hasTravis: context.hasTravis,
161
+ lastCommitSha: context.lastCommitSha,
160
162
  }));
161
163
  })
162
164
  .catch(err => {
@@ -171,6 +173,7 @@ function check(request, ctx, callback) {
171
173
  warnings: context.warnings,
172
174
  version,
173
175
  hasTravis: context.hasTravis,
176
+ lastCommitSha: context.lastCommitSha,
174
177
  error: `${err.request ? err.request.path : ''} ${err.message}`,
175
178
  }));
176
179
  });
@@ -265,6 +268,7 @@ if (typeof module !== 'undefined' && module.parent) {
265
268
  } else {
266
269
  console.log('\n\nNO warnings encountered.');
267
270
  }
271
+ console.log(`\ncreated by repochecker ${context.version} based on commit ${context.lastCommitSha}`);
268
272
  });
269
273
  }
270
274
 
@@ -163,7 +163,7 @@ async function checkIOPackageJson(context) {
163
163
  } else {
164
164
  let missingLang = common.checkLanguages(context.ioPackageJson.common.titleLang, context.cfg.requiredLanguages);
165
165
  if (missingLang.length) {
166
- context.warnings.push(`[W126] Missing mandatory translation into ${missingLang.join()} of "common.titleLang" in io-package.json.`);
166
+ context.errors.push(`[E126] Missing mandatory translation into ${missingLang.join()} of "common.titleLang" in io-package.json.`);
167
167
  }
168
168
 
169
169
  missingLang = common.checkLanguages(context.ioPackageJson.common.titleLang, context.cfg.allowedLanguages);
@@ -50,7 +50,7 @@ async function checkReadme(context) {
50
50
  const latest = npmJson['dist-tags'].latest;
51
51
  const timeStr = npmJson.time[latest];
52
52
  npmYear = new Date(timeStr).getFullYear();
53
- console.log(`[DEBUG] ${latest} - ${timeStr} - ${npmYear}`);
53
+ // console.log(`${latest} - ${timeStr} - ${npmYear}`);
54
54
  }
55
55
  } catch (e) {
56
56
  context.warnings.push('[W606] Could not retrieve timestamp of LATEST revision at npm.');
@@ -23,10 +23,17 @@ async function checkLicenseFile(context) {
23
23
  // https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/LICENSE
24
24
  console.log('\ncheckLicenseFile [E7xx]');
25
25
 
26
- const data = await common.downloadFile(context.githubUrl, '/LICENSE');
27
- if (!data) {
28
- context.errors.push('[E700] NO LICENSE file found, please add it.');
29
- } else {
26
+ let data;
27
+ try {
28
+ data = await common.downloadFile(context.githubUrl, '/LICENSE');
29
+ } catch (e) {
30
+ if (e.status = 404) {
31
+ context.errors.push('[E700] File LICENSE not found. Please add.');
32
+ } else{
33
+ context.errors.push('[E702] Cannot read LICENSE file. Please check.');
34
+ }
35
+ }
36
+ if (data) {
30
37
  context.checks.push('LICENSE file found');
31
38
 
32
39
  let npmYear = 0;
@@ -85,6 +92,7 @@ exports.checkLicenseFile = checkLicenseFile;
85
92
  // List of error and warnings used at this module
86
93
  // ----------------------------------------------
87
94
 
88
- // [E700] NO LICENSE file found, please add it.
89
- // [E701] No actual year found in LICENSE. Please add "Copyright (c) ${m[1]}-${year} ${getAuthor(context.packageJson.author)}" at the start of LICENSE
90
- // [E701] No actual year found in LICENSE. Please add "Copyright (c) ${year} ${getAuthor(context.packageJson.author)}" at the start of LICENSE
95
+ // [700] File LICENSE not found. Please add.');
96
+ // [701] No actual year found in LICENSE. Please add "Copyright (c) ${m[1]}-${year} ${getAuthor(context.packageJson.author)}" at the start of LICENSE
97
+ // [701] No actual year found in LICENSE. Please add "Copyright (c) ${year} ${getAuthor(context.packageJson.author)}" at the start of LICENSE
98
+ // [702] Cannot read LICENSE file. Please check.');
@@ -6,24 +6,59 @@
6
6
  Numbering : 800 - 899
7
7
 
8
8
  */
9
+ const axios = require('axios');
10
+
11
+ // disable axios caching
12
+ axios.defaults.headers = {
13
+ 'Cache-Control': 'no-cache',
14
+ 'Pragma': 'no-cache',
15
+ 'Expires': '0',
16
+ };
9
17
 
10
18
  const common = require('./common.js');
11
19
 
20
+ // async function getCommitInfos(context) {
21
+ // console.log('\ngetCommitInfos');
22
+ // context.lastCommitYear = 0;
23
+ // try{
24
+ // const data = await common.downloadFile(context.githubUrlOriginal, `/commits/${context.branch}`)
25
+ // const m = data.match(/Commits on [\w\s\d]+, (\d\d\d\d)/);
26
+ // if (m) {
27
+ // context.lastCommitYear = Number(m[1]);
28
+ // common.debug (`lastCommitYear: ${context.lastCommitYear}`);
29
+ // } else {
30
+ // common.debug (`lastCommitYear: not found within data returned`);
31
+ // }
32
+ // } catch (e) {
33
+ // console.log( '[INTERNAL] error retrieving commit info - ${e}');
34
+ // }
35
+
36
+ // return context;
37
+ // }
38
+
12
39
  async function getCommitInfos(context) {
13
40
  console.log('\ngetCommitInfos');
41
+ context.lastCommitSha = '';
14
42
  context.lastCommitYear = 0;
15
- try{
16
- const data = await common.downloadFile(context.githubUrlOriginal, `/commits/${context.branch}`)
17
- const m = data.match(/Commits on [\w\s\d]+, (\d\d\d\d)/);
18
- if (m) {
19
- context.lastCommitYear = Number(m[1]);
20
- common.debug (`lastCommitYear: ${context.lastCommitYear}`);
21
- } else {
22
- common.debug (`lastCommitYear: not found within data returned`);
23
- }
43
+
44
+ let response = {};
45
+ const url = `${context.githubUrlApi}/commits/${context.branch}`;
46
+ try {
47
+ common.debug(`reading github commits from ${url}`);
48
+ response = await axios(url);
24
49
  } catch (e) {
25
- console.log( '[INTERNAL] error retrieving commit info - ${e}');
26
- }
50
+ console.log(`[INTERNAL] error downloading commit info from ${url} - ${e}`);
51
+ throw e;
52
+ };
53
+
54
+ const lastCommit = response.data;
55
+ //common.debug(`Last commit:\n${JSON.stringify(lastCommit)}`);
56
+ context.lastCommitSha = lastCommit.sha;
57
+ const lastCommitDate = new Date(lastCommit.commit.author.date);
58
+ context.lastCommitYear = lastCommitDate.getUTCFullYear().toString();
59
+
60
+ common.debug (`lastCommitSha : ${context.lastCommitSha}`);
61
+ common.debug (`lastCommitYear: ${context.lastCommitYear}`);
27
62
 
28
63
  return context;
29
64
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.0.0-alpha.3",
2
+ "version": "3.0.1",
3
3
  "name": "@iobroker/repochecker",
4
4
  "dependencies": {
5
5
  "axios": "^1.7.7",