@iobroker/repochecker 3.2.3 → 3.3.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.
package/index.js CHANGED
@@ -34,8 +34,8 @@ const M900_GitNpmIgnore = require('./lib/M900_GitNpmIgnore.js');
34
34
  // disable axios caching
35
35
  axios.defaults.headers = {
36
36
  'Cache-Control': 'no-cache',
37
- 'Pragma': 'no-cache',
38
- 'Expires': '0',
37
+ Pragma: 'no-cache',
38
+ Expires: '0',
39
39
  };
40
40
 
41
41
  // Error ranges
@@ -74,7 +74,7 @@ function getGithubApiData(context) {
74
74
  console.log('\ngetGithubApiData');
75
75
  axios
76
76
  .get(context.githubUrlApi, { cache: false })
77
- .then((response) => {
77
+ .then(response => {
78
78
  context.githubApiData = response.data;
79
79
  // console.log(`API Data: ${JSON.stringify(context.githubApiData)}`);
80
80
 
@@ -90,7 +90,7 @@ function getGithubApiData(context) {
90
90
 
91
91
  resolve(context);
92
92
  })
93
- .catch((e) => {
93
+ .catch(e => {
94
94
  context.errors.push(`[E000] FATAL: cannot access repository ${context.githubUrlApi}`);
95
95
  reject(e);
96
96
  }); // E0xx
@@ -112,85 +112,84 @@ function check(request, ctx, callback) {
112
112
  // console.log('PROCESS: ' + JSON.stringify(request));
113
113
  if (!request.queryStringParameters.url) {
114
114
  return callback(null, makeResponse(500, { error: 'No github URL provided' }));
115
- } else {
116
- const context = { checks: [], errors: [], warnings: [] };
117
- let githubUrl = request.queryStringParameters.url;
118
- const githubBranch = request.queryStringParameters.branch;
115
+ }
116
+ const context = { checks: [], errors: [], warnings: [] };
117
+ let githubUrl = request.queryStringParameters.url;
118
+ const githubBranch = request.queryStringParameters.branch;
119
119
 
120
- githubUrl = githubUrl
121
- .replace('http://', 'https://')
122
- .replace('https://www.github.com', 'https://github.com')
123
- .replace('https://raw.githubusercontent.com/', 'https://github.com/');
120
+ githubUrl = githubUrl
121
+ .replace('http://', 'https://')
122
+ .replace('https://www.github.com', 'https://github.com')
123
+ .replace('https://raw.githubusercontent.com/', 'https://github.com/');
124
124
 
125
- if (githubUrl.match(/\/$/)) {
126
- githubUrl = githubUrl.substring(0, githubUrl.length - 1);
127
- }
125
+ if (githubUrl.match(/\/$/)) {
126
+ githubUrl = githubUrl.substring(0, githubUrl.length - 1);
127
+ }
128
128
 
129
- context.version = version;
130
- config.initConfig(context);
129
+ context.version = version;
130
+ config.initConfig(context);
131
+ context.checks.push(`Starting checker ioBroker.repochecker ${version}`);
131
132
 
132
- context.githubUrlOriginal = githubUrl;
133
- context.githubUrlApi = githubUrl.replace('https://github.com/', 'https://api.github.com/repos/');
134
- context.branch = githubBranch || null;
133
+ context.githubUrlOriginal = githubUrl;
134
+ context.githubUrlApi = githubUrl.replace('https://github.com/', 'https://api.github.com/repos/');
135
+ context.branch = githubBranch || null;
135
136
 
136
- getGithubApiData(context)
137
- .then((context) => M800_Github.getCommitInfos(context))
138
- .then((context) => M000_PackageJson.getPackageJson(context))
139
- .then((context) => M100_IOPackageJson.getIOPackageJson(context))
140
- .then((context) => M000_PackageJson.checkPackageJson(context))
141
- .then((context) => M100_IOPackageJson.checkIOPackageJson(context))
142
- .then((context) => M250_Npm.checkNpm(context))
143
- .then((context) => M400_Repository.checkRepository(context))
144
- .then((context) => M500_Code.checkCode(context))
145
- .then((context) => M300_Testing.checkTests(context))
146
- .then((context) => M800_Github.checkGithubRepo(context))
147
- .then((context) => M600_Readme.checkReadme(context))
148
- .then((context) => M700_License.checkLicenseFile(context))
149
- .then((context) => M900_GitNpmIgnore.checkNpmIgnore(context))
150
- .then((context) => M900_GitNpmIgnore.checkGitIgnore(context))
151
- .then((context) => {
152
- return callback(
153
- null,
154
- makeResponse(200, {
155
- result: 'OK',
156
- checks: context.checks,
157
- errors: context.errors,
158
- warnings: context.warnings,
159
- version,
160
- hasTravis: context.hasTravis,
161
- lastCommitSha: context.lastCommitSha,
162
- }),
163
- );
164
- })
165
- .catch((err) => {
166
- console.error(`GLOBAL ERROR: ${err.toString()}, ${JSON.stringify(err)}`);
167
- context.errors.push(`[E999] GLOBAL ERROR: ${err.toString()}, ${JSON.stringify(err)}`);
137
+ getGithubApiData(context)
138
+ .then(context => M800_Github.getCommitInfos(context))
139
+ .then(context => M000_PackageJson.getPackageJson(context))
140
+ .then(context => M100_IOPackageJson.getIOPackageJson(context))
141
+ .then(context => M000_PackageJson.checkPackageJson(context))
142
+ .then(context => M100_IOPackageJson.checkIOPackageJson(context))
143
+ .then(context => M250_Npm.checkNpm(context))
144
+ .then(context => M400_Repository.checkRepository(context))
145
+ .then(context => M500_Code.checkCode(context))
146
+ .then(context => M300_Testing.checkTests(context))
147
+ .then(context => M800_Github.checkGithubRepo(context))
148
+ .then(context => M600_Readme.checkReadme(context))
149
+ .then(context => M700_License.checkLicenseFile(context))
150
+ .then(context => M900_GitNpmIgnore.checkNpmIgnore(context))
151
+ .then(context => M900_GitNpmIgnore.checkGitIgnore(context))
152
+ .then(context => {
153
+ return callback(
154
+ null,
155
+ makeResponse(200, {
156
+ result: 'OK',
157
+ checks: context.checks,
158
+ errors: context.errors,
159
+ warnings: context.warnings,
160
+ version,
161
+ hasTravis: context.hasTravis,
162
+ lastCommitSha: context.lastCommitSha,
163
+ }),
164
+ );
165
+ })
166
+ .catch(err => {
167
+ console.error(`GLOBAL ERROR: ${err.toString()}, ${JSON.stringify(err)}`);
168
+ context.errors.push(`[E999] GLOBAL ERROR: ${err.toString()}, ${JSON.stringify(err)}`);
168
169
 
169
- return callback(
170
- null,
171
- makeResponse(200, {
172
- result: 'Errors found',
173
- checks: context.checks,
174
- errors: context.errors,
175
- issues,
176
- warnings: context.warnings,
177
- version,
178
- hasTravis: context.hasTravis,
179
- lastCommitSha: context.lastCommitSha,
180
- error: `${err.request ? err.request.path : ''} ${err.message}`,
181
- }),
182
- );
183
- });
184
- }
170
+ return callback(
171
+ null,
172
+ makeResponse(200, {
173
+ result: 'Errors found',
174
+ checks: context.checks,
175
+ errors: context.errors,
176
+ issues,
177
+ warnings: context.warnings,
178
+ version,
179
+ hasTravis: context.hasTravis,
180
+ lastCommitSha: context.lastCommitSha,
181
+ error: `${err.request ? err.request.path : ''} ${err.message}`,
182
+ }),
183
+ );
184
+ });
185
185
  }
186
186
 
187
187
  function getText(text, lang) {
188
188
  if (typeof text === 'object') {
189
189
  if (text[lang]) {
190
190
  return text[lang];
191
- } else {
192
- return text.en;
193
191
  }
192
+ return text.en;
194
193
  }
195
194
  return text;
196
195
  }
@@ -247,10 +246,17 @@ if (typeof module !== 'undefined' && module.parent) {
247
246
  const context = JSON.parse(data.body);
248
247
  console.log(context.result);
249
248
 
250
- console.log('\n\n########## SUMMARY ##########');
249
+ console.log('\n\n########## SUMMARY ##########\n');
250
+ if (context.checks.length) {
251
+ context.checks.forEach(msg => {
252
+ console.log(msg);
253
+ });
254
+ }
255
+
256
+ console.log('\n\n########## SUMMARY of ISSUES ##########');
251
257
  if (context.errors.length) {
252
258
  console.log('\n\nErrors:');
253
- context.errors.sort().forEach((err) => {
259
+ context.errors.sort().forEach(err => {
254
260
  const issue = err.substring(1, 5);
255
261
  console.error(err);
256
262
  if (issues[issue]) {
@@ -273,7 +279,7 @@ if (typeof module !== 'undefined' && module.parent) {
273
279
  }
274
280
  if (context.warnings.length) {
275
281
  console.log('\nWarnings:');
276
- context.warnings.sort().forEach((err) => {
282
+ context.warnings.sort().forEach(err => {
277
283
  const issue = err.substring(1, 5);
278
284
  console.warn(err);
279
285
  if (issues[issue]) {