@iobroker/repochecker 3.1.3 → 3.2.0

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.
@@ -8,6 +8,11 @@
8
8
  */
9
9
  const axios = require('axios');
10
10
 
11
+ const issuesToWatch = [
12
+ 'IMPORTANT: Update of dependency @iobroker/adapter-core is required as soon as possible',
13
+ 'Compatibility check and testing for node.js 22',
14
+ ];
15
+
11
16
  // disable axios caching
12
17
  axios.defaults.headers = {
13
18
  'Cache-Control': 'no-cache',
@@ -17,24 +22,11 @@ axios.defaults.headers = {
17
22
 
18
23
  const common = require('./common.js');
19
24
 
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
- // }
25
+ async function getAllIssues(context) {
26
+ //console.log('\ngetAllIssues');
27
+ const response = await axios(`${context.githubUrlApi}/issues`, {});
28
+ return response.data;
29
+ }
38
30
 
39
31
  async function getCommitInfos(context) {
40
32
  console.log('\ngetCommitInfos');
@@ -49,7 +41,7 @@ async function getCommitInfos(context) {
49
41
  } catch (e) {
50
42
  console.log(`[INTERNAL] error downloading commit info from ${url} - ${e}`);
51
43
  throw e;
52
- };
44
+ }
53
45
 
54
46
  const lastCommit = response.data;
55
47
  //common.debug(`Last commit:\n${JSON.stringify(lastCommit)}`);
@@ -57,13 +49,13 @@ async function getCommitInfos(context) {
57
49
  const lastCommitDate = new Date(lastCommit.commit.author.date);
58
50
  context.lastCommitYear = lastCommitDate.getUTCFullYear().toString();
59
51
 
60
- common.debug (`lastCommitSha : ${context.lastCommitSha}`);
61
- common.debug (`lastCommitYear: ${context.lastCommitYear}`);
52
+ common.debug(`lastCommitSha : ${context.lastCommitSha}`);
53
+ common.debug(`lastCommitYear: ${context.lastCommitYear}`);
62
54
 
63
55
  return context;
64
56
  }
65
57
 
66
- function checkGithubRepo(context) {
58
+ async function checkGithubRepo(context) {
67
59
  console.log('\ncheckGithubRepo [E8xx]');
68
60
 
69
61
  if (!context.githubApiData.description) {
@@ -82,6 +74,14 @@ function checkGithubRepo(context) {
82
74
  context.errors.push(`[E803] Archived repositories are not allowed.`);
83
75
  }
84
76
 
77
+ const issues = await getAllIssues(context);
78
+ for (const issue of issues){
79
+ if (issue.pull_request) continue;
80
+ if (issuesToWatch.includes(issue.title)) {
81
+ context.errors.push(`[E804] Please process issue [#${issue.number}] "${issue.title}."`);
82
+ }
83
+ }
84
+
85
85
  // max E803 - limited to 849
86
86
 
87
87
  return context;
@@ -8,9 +8,9 @@
8
8
  NOTE: requires filesList to be loaded
9
9
  */
10
10
 
11
- /*
12
- TODO:
13
- - something is wrong with undefined 'check' variable
11
+ /*
12
+ TODO:
13
+ - something is wrong with undefined 'check' variable
14
14
  - conversion of github to regex is wrong with multiple stars
15
15
  */
16
16
 
@@ -34,7 +34,7 @@ async function checkGitIgnore(context) {
34
34
  console.log('\ncheckGitIgnore [E9xx]');
35
35
 
36
36
  if (!context.filesList) {
37
- throw('FATAL:context.fileslist is undefined');
37
+ throw ('FATAL:context.fileslist is undefined');
38
38
  }
39
39
 
40
40
  if (!context.filesList.includes('.gitignore')) {
@@ -57,7 +57,7 @@ async function checkGitIgnore(context) {
57
57
  }
58
58
  });
59
59
 
60
- /* TODO: something is wrong with undefined 'check' variable
60
+ /* TODO: something is wrong with undefined 'check' variable
61
61
  if (!rules.includes('node_modules') && !rules.includes('/node_modules') && !rules.includes('/node_modules/*') && !rules.includes('node_modules/*')) {
62
62
  !check && context.errors.push(`[E902] node_modules not found in .npmignore`);
63
63
  }
@@ -129,7 +129,7 @@ async function checkNpmIgnore(context) {
129
129
 
130
130
  // package.json files section is NOT used
131
131
  if (!context.filesList.includes('.npmignore')) {
132
- context.warnings.push(`[E952] .npmignore not found`);
132
+ context.errors.push(`[E952] neither files section at package.json nor file .npmignore not found. npm package will contain unwanted files.`);
133
133
  } else {
134
134
  context.warnings.push(`[W953] .npmignore found - consider using package.json object "files" instead.`);
135
135
 
package/lib/common.js CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  */
6
6
  const axios = require('axios');
7
+ const fs = require('node:fs/promises');
8
+ const compareVersions = require('compare-versions');
7
9
 
8
10
  // disable axios caching
9
11
  axios.defaults.headers = {
@@ -13,41 +15,55 @@ axios.defaults.headers = {
13
15
  };
14
16
 
15
17
  let gDebug = false;
16
- function setDebug(flag){
18
+ function setDebug(flag) {
17
19
  gDebug = flag;
20
+ debug('debug messages have been enabled');
18
21
  }
19
22
 
20
23
  function debug(msg) {
21
- console.log(`[DEBUG] ${msg}`);
24
+ gDebug && console.log(`[DEBUG] ${msg}`);
22
25
  }
23
26
 
24
- function checkLanguages(langObj, languages) {
25
- return languages.filter(lang => !langObj[lang]);
27
+ let gLocal = false;
28
+ function setLocal(flag) {
29
+ gLocal = flag;
30
+ console.log(`[INFO] running in LOCAL mode`);
26
31
  }
27
32
 
28
- async function downloadFile(githubUrl, path, binary, noError) {
33
+ function isLocal() {
34
+ return gLocal;
35
+ }
29
36
 
30
- console.log(`Download ${githubUrl}${path || ''}`);
37
+ function checkLanguages(langObj, languages) {
38
+ return languages.filter((lang) => !langObj[lang]);
39
+ }
31
40
 
32
- const options = {};
33
- if (binary) {
34
- options.responseType = 'arraybuffer';
41
+ async function downloadFile(githubUrl, path, binary, noError) {
42
+ if (!isLocal()) {
43
+ console.log(`Download ${githubUrl}${path || ''}`);
44
+ const options = {};
45
+ if (binary) {
46
+ options.responseType = 'arraybuffer';
47
+ }
48
+ try {
49
+ const response = await axios(githubUrl + (path || ''), options);
50
+ debug(`download succeded`);
51
+ return response.data;
52
+ } catch (e) {
53
+ (!noError || gDebug) && console.error(`Cannot download ${githubUrl}${path || ''} ${e}`);
54
+ throw e;
55
+ }
56
+ } else {
57
+ console.log(`Download local ${path || ''}`);
58
+ // remove first / from path
59
+ path = path.replace(/^\/+/, '');
60
+ const file = await fs.readFile(path, binary ? null : 'utf8');
61
+ return file;
35
62
  }
36
-
37
- try {
38
- const response = await axios(githubUrl + (path || ''), options);
39
- debug(`download succeded`);
40
- return(response.data);
41
- } catch (e) {
42
- (!noError || gDebug) && console.error(`Cannot download ${githubUrl}${path || ''} ${e}`);
43
- throw e;
44
- }
45
-
46
63
  }
47
-
48
64
  function getDependencyArray(deps) {
49
65
  return deps
50
- .map(dep => typeof dep === 'object' ? Object.keys(dep) : [dep])
66
+ .map((dep) => (typeof dep === 'object' ? Object.keys(dep) : [dep]))
51
67
  .reduce((acc, dep) => acc.concat(dep), []);
52
68
  }
53
69
 
@@ -76,13 +92,13 @@ function getDependencies(deps) {
76
92
  const ret = {};
77
93
  console.log(`deps: ${JSON.stringify(deps)}, type ${typeof deps}`);
78
94
  if (deps instanceof Array) {
79
- for (const dep of deps ) {
95
+ for (const dep of deps) {
80
96
  if (typeof dep === 'object') {
81
- for (const key in dep ) {
97
+ for (const key in dep) {
82
98
  ret[key] = dep[key];
83
99
  }
84
100
  } else {
85
- ret[ dep ] = '>=0';
101
+ ret[dep] = '>=0';
86
102
  }
87
103
  }
88
104
  }
@@ -100,12 +116,13 @@ function maxVersion(v1, v2) {
100
116
  return v2;
101
117
  }
102
118
 
103
- exports.setDebug=setDebug;
104
- exports.debug=debug;
105
-
106
- exports.checkLanguages=checkLanguages;
107
- exports.downloadFile=downloadFile;
108
- exports.getDependencyArray=getDependencyArray;
109
- exports.getDependencies=getDependencies;
110
- exports.maxVersion=maxVersion;
119
+ exports.setDebug = setDebug;
120
+ exports.debug = debug;
121
+ exports.setLocal = setLocal;
122
+ exports.isLocal = isLocal;
111
123
 
124
+ exports.checkLanguages = checkLanguages;
125
+ exports.downloadFile = downloadFile;
126
+ exports.getDependencyArray = getDependencyArray;
127
+ exports.getDependencies = getDependencies;
128
+ exports.maxVersion = maxVersion;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.1.3",
2
+ "version": "3.2.0",
3
3
  "name": "@iobroker/repochecker",
4
4
  "dependencies": {
5
5
  "axios": "^1.7.7",