@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/LICENSE +21 -21
- package/README.md +240 -181
- package/index.js +79 -73
- package/lib/M000_PackageJson.js +172 -78
- package/lib/M100_IOPackageJson.js +646 -457
- package/lib/M250_Npm.js +34 -25
- package/lib/M300_Testing.js +7 -1
- package/lib/M400_Repository.js +130 -45
- package/lib/M500_Code.js +21 -18
- package/lib/M500__JsonConfig.js +197 -190
- package/lib/M600_Readme.js +25 -8
- package/lib/M700_License.js +21 -7
- package/lib/M800_Github.js +21 -7
- package/lib/M900_GitNpmIgnore.js +34 -31
- package/lib/common.js +4 -4
- package/lib/config.js +34 -47
- package/package.json +8 -6
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
|
-
|
|
38
|
-
|
|
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(
|
|
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(
|
|
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
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
}
|
|
116
|
+
const context = { checks: [], errors: [], warnings: [] };
|
|
117
|
+
let githubUrl = request.queryStringParameters.url;
|
|
118
|
+
const githubBranch = request.queryStringParameters.branch;
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
if (githubUrl.match(/\/$/)) {
|
|
126
|
+
githubUrl = githubUrl.substring(0, githubUrl.length - 1);
|
|
127
|
+
}
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
context.version = version;
|
|
130
|
+
config.initConfig(context);
|
|
131
|
+
context.checks.push(`Starting checker ioBroker.repochecker ${version}`);
|
|
131
132
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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(
|
|
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(
|
|
282
|
+
context.warnings.sort().forEach(err => {
|
|
277
283
|
const issue = err.substring(1, 5);
|
|
278
284
|
console.warn(err);
|
|
279
285
|
if (issues[issue]) {
|