@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.
- package/README.md +175 -106
- package/index.js +135 -109
- package/lib/M000_PackageJson.js +62 -29
- package/lib/M100_IOPackageJson.js +72 -68
- package/lib/M250_Npm.js +4 -6
- package/lib/M300_Testing.js +1 -1
- package/lib/M400_Repository.js +14 -12
- package/lib/M500_Code.js +269 -153
- package/lib/M500__JsonConfig.js +603 -0
- package/lib/M700_License.js +5 -5
- package/lib/M800_Github.js +22 -22
- package/lib/M900_GitNpmIgnore.js +6 -6
- package/lib/common.js +49 -32
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -31,7 +31,6 @@ const M700_License = require('./lib/M700_License.js');
|
|
|
31
31
|
const M800_Github = require('./lib/M800_Github.js');
|
|
32
32
|
const M900_GitNpmIgnore = require('./lib/M900_GitNpmIgnore.js');
|
|
33
33
|
|
|
34
|
-
|
|
35
34
|
// disable axios caching
|
|
36
35
|
axios.defaults.headers = {
|
|
37
36
|
'Cache-Control': 'no-cache',
|
|
@@ -39,7 +38,6 @@ axios.defaults.headers = {
|
|
|
39
38
|
'Expires': '0',
|
|
40
39
|
};
|
|
41
40
|
|
|
42
|
-
|
|
43
41
|
// Error ranges
|
|
44
42
|
// E0xx
|
|
45
43
|
// check package.json
|
|
@@ -71,12 +69,12 @@ axios.defaults.headers = {
|
|
|
71
69
|
// E9xx
|
|
72
70
|
// check .gitignore file
|
|
73
71
|
|
|
74
|
-
|
|
75
72
|
function getGithubApiData(context) {
|
|
76
73
|
return new Promise((resolve, reject) => {
|
|
77
74
|
console.log('\ngetGithubApiData');
|
|
78
|
-
axios
|
|
79
|
-
.
|
|
75
|
+
axios
|
|
76
|
+
.get(context.githubUrlApi, { cache: false })
|
|
77
|
+
.then((response) => {
|
|
80
78
|
context.githubApiData = response.data;
|
|
81
79
|
// console.log(`API Data: ${JSON.stringify(context.githubApiData)}`);
|
|
82
80
|
|
|
@@ -92,10 +90,10 @@ function getGithubApiData(context) {
|
|
|
92
90
|
|
|
93
91
|
resolve(context);
|
|
94
92
|
})
|
|
95
|
-
.catch(e => {
|
|
93
|
+
.catch((e) => {
|
|
96
94
|
context.errors.push(`[E000] FATAL: cannot access repository ${context.githubUrlApi}`);
|
|
97
95
|
reject(e);
|
|
98
|
-
})
|
|
96
|
+
}); // E0xx
|
|
99
97
|
});
|
|
100
98
|
}
|
|
101
99
|
|
|
@@ -104,18 +102,18 @@ function makeResponse(code, data) {
|
|
|
104
102
|
statusCode: code || 200,
|
|
105
103
|
headers: {
|
|
106
104
|
'Access-Control-Allow-Origin': '*', // Required for CORS support to work
|
|
107
|
-
'Access-Control-Allow-Credentials': true // Required for cookies, authorization headers with HTTPS
|
|
105
|
+
'Access-Control-Allow-Credentials': true, // Required for cookies, authorization headers with HTTPS
|
|
108
106
|
},
|
|
109
|
-
body: typeof data === 'string' ? data : JSON.stringify(data)
|
|
107
|
+
body: typeof data === 'string' ? data : JSON.stringify(data),
|
|
110
108
|
};
|
|
111
109
|
}
|
|
112
110
|
|
|
113
111
|
function check(request, ctx, callback) {
|
|
114
|
-
// console.log('PROCESS: ' + JSON.stringify(request));
|
|
112
|
+
// console.log('PROCESS: ' + JSON.stringify(request));
|
|
115
113
|
if (!request.queryStringParameters.url) {
|
|
116
|
-
return callback(null, makeResponse(500, {error: 'No github URL provided'}));
|
|
114
|
+
return callback(null, makeResponse(500, { error: 'No github URL provided' }));
|
|
117
115
|
} else {
|
|
118
|
-
const context = {checks: [], errors: [], warnings: []};
|
|
116
|
+
const context = { checks: [], errors: [], warnings: [] };
|
|
119
117
|
let githubUrl = request.queryStringParameters.url;
|
|
120
118
|
const githubBranch = request.queryStringParameters.branch;
|
|
121
119
|
|
|
@@ -136,46 +134,52 @@ function check(request, ctx, callback) {
|
|
|
136
134
|
context.branch = githubBranch || null;
|
|
137
135
|
|
|
138
136
|
getGithubApiData(context)
|
|
139
|
-
.then(context => M800_Github.getCommitInfos(context))
|
|
140
|
-
.then(context => M000_PackageJson.getPackageJson(context))
|
|
141
|
-
.then(context => M100_IOPackageJson.getIOPackageJson(context))
|
|
142
|
-
.then(context => M000_PackageJson.checkPackageJson(context))
|
|
143
|
-
.then(context => M100_IOPackageJson.checkIOPackageJson(context))
|
|
144
|
-
.then(context => M250_Npm.checkNpm(context))
|
|
145
|
-
.then(context => M400_Repository.checkRepository(context))
|
|
146
|
-
.then(context => M500_Code.checkCode(context))
|
|
147
|
-
.then(context => M300_Testing.checkTests(context))
|
|
148
|
-
.then(context => M800_Github.checkGithubRepo(context))
|
|
149
|
-
.then(context => M600_Readme.checkReadme(context))
|
|
150
|
-
.then(context => M700_License.checkLicenseFile(context))
|
|
151
|
-
.then(context => M900_GitNpmIgnore.checkNpmIgnore(context))
|
|
152
|
-
.then(context => M900_GitNpmIgnore.checkGitIgnore(context))
|
|
153
|
-
.then(context => {
|
|
154
|
-
return callback(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
+
);
|
|
163
164
|
})
|
|
164
|
-
.catch(err => {
|
|
165
|
+
.catch((err) => {
|
|
165
166
|
console.error(`GLOBAL ERROR: ${err.toString()}, ${JSON.stringify(err)}`);
|
|
166
167
|
context.errors.push(`[E999] GLOBAL ERROR: ${err.toString()}, ${JSON.stringify(err)}`);
|
|
167
168
|
|
|
168
|
-
return callback(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
+
);
|
|
179
183
|
});
|
|
180
184
|
}
|
|
181
185
|
}
|
|
@@ -191,17 +195,38 @@ function getText(text, lang) {
|
|
|
191
195
|
return text;
|
|
192
196
|
}
|
|
193
197
|
|
|
194
|
-
common.setDebug(true); /* DEBUG*/
|
|
195
|
-
|
|
196
198
|
if (typeof module !== 'undefined' && module.parent) {
|
|
197
199
|
exports.handler = check;
|
|
198
200
|
} else {
|
|
199
|
-
let repoUrl =
|
|
201
|
+
let repoUrl = null;
|
|
200
202
|
let repoBranch = null;
|
|
201
203
|
|
|
204
|
+
// check options
|
|
205
|
+
if (process.argv.includes('-d')) {
|
|
206
|
+
process.argv.splice(process.argv.indexOf('-d'), 1);
|
|
207
|
+
common.setDebug(true);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (process.argv.includes('--debug')) {
|
|
211
|
+
process.argv.splice(process.argv.indexOf('--debug'), 1);
|
|
212
|
+
common.setDebug(true);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (process.argv.includes('--local')) {
|
|
216
|
+
process.argv.splice(process.argv.indexOf('--local'), 1);
|
|
217
|
+
common.setLocal(true);
|
|
218
|
+
}
|
|
219
|
+
|
|
202
220
|
// Get url from parameters if possible
|
|
203
221
|
if (process.argv.length > 2) {
|
|
204
222
|
repoUrl = process.argv[2];
|
|
223
|
+
|
|
224
|
+
if (!repoUrl.toLowerCase().includes('github.com')) {
|
|
225
|
+
repoUrl = `https://github.com/${repoUrl}`;
|
|
226
|
+
}
|
|
227
|
+
} else {
|
|
228
|
+
console.log('ERROR: No repository specified');
|
|
229
|
+
process.exit(1);
|
|
205
230
|
}
|
|
206
231
|
|
|
207
232
|
// Get branch from parameters if possible
|
|
@@ -210,65 +235,66 @@ if (typeof module !== 'undefined' && module.parent) {
|
|
|
210
235
|
}
|
|
211
236
|
|
|
212
237
|
console.log(`Checking repository ${repoUrl} (branch ${repoBranch})`);
|
|
213
|
-
check(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
console.log('\n\nErrors:');
|
|
225
|
-
context.errors.sort().forEach(err => {
|
|
226
|
-
const issue = err.substring(1, 5);
|
|
227
|
-
console.error(err);
|
|
228
|
-
if (issues[issue]) {
|
|
229
|
-
//if (issues[issue].title) {
|
|
230
|
-
// console.error(getText(issues[issue].title, 'en'));
|
|
231
|
-
//}
|
|
232
|
-
if (issues[issue].explanation) {
|
|
233
|
-
console.error(getText(issues[issue].explanation, 'en'));
|
|
234
|
-
}
|
|
235
|
-
if (issues[issue].resolving) {
|
|
236
|
-
console.error(getText(issues[issue].resolving, 'en'));
|
|
237
|
-
}
|
|
238
|
-
if (issues[issue].notes) {
|
|
239
|
-
console.error(getText(issues[issue].notes, 'en'));
|
|
240
|
-
}
|
|
241
|
-
}
|
|
238
|
+
check(
|
|
239
|
+
{
|
|
240
|
+
queryStringParameters: {
|
|
241
|
+
url: repoUrl,
|
|
242
|
+
branch: repoBranch,
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
null,
|
|
246
|
+
(err, data) => {
|
|
247
|
+
const context = JSON.parse(data.body);
|
|
248
|
+
console.log(context.result);
|
|
242
249
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
250
|
+
console.log('\n\n########## SUMMARY ##########');
|
|
251
|
+
if (context.errors.length) {
|
|
252
|
+
console.log('\n\nErrors:');
|
|
253
|
+
context.errors.sort().forEach((err) => {
|
|
254
|
+
const issue = err.substring(1, 5);
|
|
255
|
+
console.error(err);
|
|
256
|
+
if (issues[issue]) {
|
|
257
|
+
//if (issues[issue].title) {
|
|
258
|
+
// console.error(getText(issues[issue].title, 'en'));
|
|
259
|
+
//}
|
|
260
|
+
if (issues[issue].explanation) {
|
|
261
|
+
console.error(getText(issues[issue].explanation, 'en'));
|
|
262
|
+
}
|
|
263
|
+
if (issues[issue].resolving) {
|
|
264
|
+
console.error(getText(issues[issue].resolving, 'en'));
|
|
265
|
+
}
|
|
266
|
+
if (issues[issue].notes) {
|
|
267
|
+
console.error(getText(issues[issue].notes, 'en'));
|
|
268
|
+
}
|
|
261
269
|
}
|
|
262
|
-
|
|
263
|
-
|
|
270
|
+
});
|
|
271
|
+
} else {
|
|
272
|
+
console.log('\n\nNO errors encountered.');
|
|
273
|
+
}
|
|
274
|
+
if (context.warnings.length) {
|
|
275
|
+
console.log('\nWarnings:');
|
|
276
|
+
context.warnings.sort().forEach((err) => {
|
|
277
|
+
const issue = err.substring(1, 5);
|
|
278
|
+
console.warn(err);
|
|
279
|
+
if (issues[issue]) {
|
|
280
|
+
//if (issues[issue].title) {
|
|
281
|
+
// console.warn(getText(issues[issue].title, 'en'));
|
|
282
|
+
//}
|
|
283
|
+
if (issues[issue].explanation) {
|
|
284
|
+
console.warn(getText(issues[issue].explanation, 'en'));
|
|
285
|
+
}
|
|
286
|
+
if (issues[issue].resolving) {
|
|
287
|
+
console.warn(getText(issues[issue].resolving, 'en'));
|
|
288
|
+
}
|
|
289
|
+
if (issues[issue].notes) {
|
|
290
|
+
console.warn(getText(issues[issue].notes, 'en'));
|
|
291
|
+
}
|
|
264
292
|
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
console.log(
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
});
|
|
293
|
+
});
|
|
294
|
+
} else {
|
|
295
|
+
console.log('\n\nNO warnings encountered.');
|
|
296
|
+
}
|
|
297
|
+
console.log(`\ncreated by repochecker ${context.version} based on commit ${context.lastCommitSha}`);
|
|
298
|
+
},
|
|
299
|
+
);
|
|
273
300
|
}
|
|
274
|
-
|
package/lib/M000_PackageJson.js
CHANGED
|
@@ -11,15 +11,16 @@ const compareVersions = require('compare-versions');
|
|
|
11
11
|
|
|
12
12
|
const common = require('./common.js');
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
const
|
|
14
|
+
// Note: node version specify rules for engines clase and do NOT reflect the recommended node version for users
|
|
15
|
+
const recommendedNodeVersion = '18'; // This is the minimum node version that should be required at engines clause
|
|
16
|
+
const requiredNodeVersion = '18'; // This is the minimum node version that must be required at engines clause
|
|
16
17
|
|
|
17
18
|
/* TODO: configuration should be moved to context */
|
|
18
19
|
|
|
19
20
|
const dependenciesPackageJson = {
|
|
20
21
|
'@iobroker/adapter-core': {
|
|
21
22
|
required: '3.1.4',
|
|
22
|
-
recommended: '3.
|
|
23
|
+
recommended: '3.2.2',
|
|
23
24
|
},
|
|
24
25
|
};
|
|
25
26
|
|
|
@@ -33,11 +34,15 @@ const devDependenciesPackageJson = {
|
|
|
33
34
|
|
|
34
35
|
const blacklistedDependenciesPackageJson = {
|
|
35
36
|
'npm': {
|
|
36
|
-
msg: "'npm'must not be listed as dependency at package.json. Please remove.",
|
|
37
|
+
msg: "'npm'must not be listed as dependency at package.json. Please remove and create new release.",
|
|
37
38
|
err: true
|
|
38
39
|
},
|
|
39
40
|
'iobroker.js-controller': {
|
|
40
|
-
msg: "'iobroker.js-controller' must not be listed as dependency at package.json.
|
|
41
|
+
msg: "'iobroker.js-controller' must not be listed as dependency at package.json.Please remove and create new release.",
|
|
42
|
+
err: true
|
|
43
|
+
},
|
|
44
|
+
'@iobroker/adapter-dev': {
|
|
45
|
+
msg: "'@iobroker/adapter-dev' must not be listed as dependency at package.json. Please remove and create new release.",
|
|
41
46
|
err: true
|
|
42
47
|
},
|
|
43
48
|
'@iobroker/dev-server': {
|
|
@@ -48,6 +53,34 @@ const blacklistedDependenciesPackageJson = {
|
|
|
48
53
|
msg: "'@iobroker/plugin-sentry' must not be listed as dependency at package.json as it will crash js-controller 7 systems. Please remove and create new release.",
|
|
49
54
|
err: true
|
|
50
55
|
},
|
|
56
|
+
'@iobroker/repochecker': {
|
|
57
|
+
msg: "'@iobroker/repochecker' must not be listed as dependency at package.json. Please remove and create new release.",
|
|
58
|
+
err: true
|
|
59
|
+
},
|
|
60
|
+
'@alcalzone/release-script': {
|
|
61
|
+
msg: "'@alcalzone/release-script' must not be listed as dependency at package.json. Please remove and create new release.",
|
|
62
|
+
err: true
|
|
63
|
+
},
|
|
64
|
+
'@alcalzone/release-script-plugin-iobroker': {
|
|
65
|
+
msg: "'@alcalzone/release-script-plugin-iobroker' must not be listed as dependency at package.json. Please remove and create new release.",
|
|
66
|
+
err: true
|
|
67
|
+
},
|
|
68
|
+
'@alcalzone/release-script-plugin-license': {
|
|
69
|
+
msg: "'@alcalzone/release-script-plugin-license' must not be listed as dependency at package.json. Please remove and create new release.",
|
|
70
|
+
err: true
|
|
71
|
+
},
|
|
72
|
+
'@alcalzone/release-script-plugin-package': {
|
|
73
|
+
msg: "'@alcalzone/release-script-plugin-package' must not be listed as dependency at package.json. Please remove and create new release.",
|
|
74
|
+
err: true
|
|
75
|
+
},
|
|
76
|
+
'@alcalzone/release-script-plugin-manual-review': {
|
|
77
|
+
msg: "'@alcalzone/release-script-plugin-manual-review' must not be listed as dependency at package.json. Please remove and create new release.",
|
|
78
|
+
err: true
|
|
79
|
+
},
|
|
80
|
+
'@alcalzone/release-script-plugin-version': {
|
|
81
|
+
msg: "'@alcalzone/release-script-plugin-version' must not be listed as dependency at package.json. Please remove and create new release.",
|
|
82
|
+
err: true
|
|
83
|
+
},
|
|
51
84
|
};
|
|
52
85
|
|
|
53
86
|
const blacklistedDevDependenciesPackageJson = {
|
|
@@ -136,7 +169,7 @@ async function checkPackageJson(context) {
|
|
|
136
169
|
}
|
|
137
170
|
|
|
138
171
|
if (context.packageJson.name !== `iobroker.${adapterName.toLowerCase()}`) {
|
|
139
|
-
context.errors.push(`[E020] Name of adapter in package.json must be lowercase and be equal to "iobroker.${adapterName.toLowerCase()}". Now is "${packageJson.name}"`);
|
|
172
|
+
context.errors.push(`[E020] Name of adapter in package.json must be lowercase and be equal to "iobroker.${adapterName.toLowerCase()}". Now is "${context.packageJson.name}"`);
|
|
140
173
|
} else {
|
|
141
174
|
context.checks.push(`Name of adapter in package.json must be lowercase and be equal to "iobroker.${adapterName.toLowerCase()}".`);
|
|
142
175
|
}
|
|
@@ -238,7 +271,7 @@ async function checkPackageJson(context) {
|
|
|
238
271
|
if (context.packageJson.dependencies) {
|
|
239
272
|
for (const blacklist in blacklistedDependenciesPackageJson) {
|
|
240
273
|
if (context.packageJson.dependencies[blacklist]) {
|
|
241
|
-
if (blacklistedDependenciesPackageJson[blacklist].err){
|
|
274
|
+
if (blacklistedDependenciesPackageJson[blacklist].err) {
|
|
242
275
|
context.errors.push(`[E050] ${blacklistedDependenciesPackageJson[blacklist].msg}`);
|
|
243
276
|
} else {
|
|
244
277
|
context.warnings.push(`[W051] ${blacklistedDependenciesPackageJson[blacklist].msg}`);
|
|
@@ -250,7 +283,7 @@ async function checkPackageJson(context) {
|
|
|
250
283
|
if (context.packageJson.devDependencies) {
|
|
251
284
|
for (const blacklist in blacklistedDevDependenciesPackageJson) {
|
|
252
285
|
if (context.packageJson.devDependencies[blacklist]) {
|
|
253
|
-
if (blacklistedDevDependenciesPackageJson[blacklist].err){
|
|
286
|
+
if (blacklistedDevDependenciesPackageJson[blacklist].err) {
|
|
254
287
|
context.errors.push(`[E052] ${blacklistedDevDependenciesPackageJson[blacklist].msg}`);
|
|
255
288
|
} else {
|
|
256
289
|
context.warnings.push(`[W053] ${blacklistedDevDependenciesPackageJson[blacklist].msg}`);
|
|
@@ -295,16 +328,16 @@ async function checkPackageJson(context) {
|
|
|
295
328
|
// 'engines': { 'node': '>= 18.1.2 < 19' }
|
|
296
329
|
const nodeVal = context.packageJson.engines.node;
|
|
297
330
|
const match = nodeVal.match(/^(?<cmp>[<>=~]+)?\s*(?<vers>\d+(\.\d+(\.\d+)?)?(-\w+\.\d+)?)/m);
|
|
298
|
-
if (
|
|
331
|
+
if (!match) {
|
|
299
332
|
context.warnings.push(`[W027] Engines clause at at package.json ({'engines' : { 'node' : '${nodeVal}' } }") is not parseable.`);
|
|
300
333
|
} else {
|
|
301
|
-
common.debug(
|
|
302
|
-
if (
|
|
334
|
+
common.debug(`node check: ${JSON.stringify(match.groups)}`);
|
|
335
|
+
if (match.groups.cmp !== '>' && match.groups.cmp !== '>=') {
|
|
303
336
|
context.warnings.push(`[W028] Minimum node.js version ${recommendedNodeVersion} recommended. Please adapt "{'engines' : { 'node' >= '${match.groups.vers}' } }" at package.json.`);
|
|
304
337
|
} else {
|
|
305
|
-
if (
|
|
338
|
+
if (!compareVersions.compare(match.groups.vers, requiredNodeVersion, '>=')) {
|
|
306
339
|
context.errors.push(`[E029] Node.js ${requiredNodeVersion} is required as minimum, node.js ${recommendedNodeVersion} is recommended. Please adapt "{'engines' : { 'node' >= '${match.groups.vers}' } }" at package.json.`);
|
|
307
|
-
} else if (
|
|
340
|
+
} else if (!compareVersions.compare(match.groups.vers, recommendedNodeVersion, '>=')) {
|
|
308
341
|
context.warnings.push(`[W028] Minimum node.js version ${recommendedNodeVersion} recommended. Please adapt "{'engines' : { 'node' >= '${match.groups.vers}' } }" at package.json.`);
|
|
309
342
|
} else {
|
|
310
343
|
context.checks.push(`Correct node.js version ${match.groups.vers} requested by "engines" attribute at package.json.`);
|
|
@@ -322,12 +355,12 @@ async function checkPackageJson(context) {
|
|
|
322
355
|
const requiredVersion = dependenciesPackageJson[dependency].required;
|
|
323
356
|
const recommendedVersion = dependenciesPackageJson[dependency].recommended;
|
|
324
357
|
let dependencyVersion = context.packageJson.dependencies[`${dependency}`] || '';
|
|
325
|
-
dependencyVersion = dependencyVersion.replace(/[\^~]/,''
|
|
358
|
+
dependencyVersion = dependencyVersion.replace(/[\^~]/, '');
|
|
326
359
|
if (!dependencyVersion) {
|
|
327
360
|
context.errors.push(`[E032] No dependency declared for ${dependency}. Please add "${dependency}":"${recommendedVersion}" to dependencies at package.json`);
|
|
328
|
-
} else if (!
|
|
361
|
+
} else if (!compareVersions.compare(dependencyVersion, requiredVersion, '>=')) {
|
|
329
362
|
context.errors.push(`[E033] ${dependency} ${dependencyVersion} specified. ${requiredVersion} is required as minimum, ${recommendedVersion} is recommended. Please update dependencies at package.json`);
|
|
330
|
-
} else if (!
|
|
363
|
+
} else if (!compareVersions.compare(dependencyVersion, recommendedVersion, '>=')) {
|
|
331
364
|
context.warnings.push(`[W034] ${dependency} ${dependencyVersion} specified. ${recommendedVersion} is recommended. Please consider updating dependencies at package.json`);
|
|
332
365
|
} else {
|
|
333
366
|
context.checks.push('dependency ${dependency} ${dependencyVersion} is ok');
|
|
@@ -343,12 +376,12 @@ async function checkPackageJson(context) {
|
|
|
343
376
|
const requiredVersion = devDependenciesPackageJson[dependency].required;
|
|
344
377
|
const recommendedVersion = devDependenciesPackageJson[dependency].recommended;
|
|
345
378
|
let dependencyVersion = context.packageJson.devDependencies[`${dependency}`] || '';
|
|
346
|
-
dependencyVersion = dependencyVersion.replace(/[\^~]/,''
|
|
379
|
+
dependencyVersion = dependencyVersion.replace(/[\^~]/, '');
|
|
347
380
|
if (!dependencyVersion) {
|
|
348
381
|
context.errors.push(`[E035] No devDependency declared for ${dependency}. Please add "${dependency}":"${recommendedVersion}" to devDependencies at package.json`);
|
|
349
|
-
} else if (!
|
|
382
|
+
} else if (!compareVersions.compare(dependencyVersion, requiredVersion, '>=')) {
|
|
350
383
|
context.errors.push(`[E036] ${dependency} ${dependencyVersion} specified. ${requiredVersion} is required as minimum, ${recommendedVersion} is recommended. Please update devDependencies at package.json`);
|
|
351
|
-
} else if (!
|
|
384
|
+
} else if (!compareVersions.compare(dependencyVersion, recommendedVersion, '>=')) {
|
|
352
385
|
context.warnings.push(`[W037] ${dependency} ${dependencyVersion} specified. ${recommendedVersion} is recommended. Please consider updating devDependencies at package.json`);
|
|
353
386
|
} else {
|
|
354
387
|
context.checks.push('devDependency ${dependency} ${dependencyVersion} is ok');
|
|
@@ -367,8 +400,8 @@ async function checkPackageJson(context) {
|
|
|
367
400
|
];
|
|
368
401
|
for (const dependency in context.packageJson.dependencies) {
|
|
369
402
|
if (!context.packageJson.dependencies[dependency].startsWith('^') &&
|
|
370
|
-
|
|
371
|
-
|
|
403
|
+
!context.packageJson.dependencies[dependency].startsWith('~') &&
|
|
404
|
+
!context.packageJson.dependencies[dependency].startsWith('>')
|
|
372
405
|
) {
|
|
373
406
|
if (context.packageJson.dependencies[dependency].toLowerCase().includes('github.com')) {
|
|
374
407
|
context.warnings.push(`[W043] dependency should not require a github version. Please change "${dependency}:${context.packageJson.dependencies[dependency]}"`);
|
|
@@ -382,8 +415,8 @@ async function checkPackageJson(context) {
|
|
|
382
415
|
|
|
383
416
|
for (const dependency in context.packageJson.devDependencies) {
|
|
384
417
|
if (!context.packageJson.devDependencies[dependency].startsWith('^') &&
|
|
385
|
-
|
|
386
|
-
|
|
418
|
+
!context.packageJson.devDependencies[dependency].startsWith('~') &&
|
|
419
|
+
!context.packageJson.devDependencies[dependency].startsWith('>')
|
|
387
420
|
) {
|
|
388
421
|
if (context.packageJson.devDependencies[dependency].toLowerCase().includes('github.com')) {
|
|
389
422
|
context.warnings.push(`[W045] devDependency should not require github versions. Please change "${dependency}:${context.packageJson.devDependencies[dependency]}"`);
|
|
@@ -404,7 +437,7 @@ async function checkPackageJson(context) {
|
|
|
404
437
|
//console.log(` check ${log}`);
|
|
405
438
|
tmp = tmp[element];
|
|
406
439
|
if (!tmp) {
|
|
407
|
-
|
|
440
|
+
//console.log(` ${log} does not exist`);
|
|
408
441
|
break;
|
|
409
442
|
}
|
|
410
443
|
}
|
|
@@ -415,9 +448,9 @@ async function checkPackageJson(context) {
|
|
|
415
448
|
context.warnings.push(`[W038] ${blacklistPackageJson[blacklist].msg}`);
|
|
416
449
|
}
|
|
417
450
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
451
|
+
// else {
|
|
452
|
+
// console.log(`blacklist ${blacklist} no match`);
|
|
453
|
+
// }
|
|
421
454
|
}
|
|
422
455
|
context.checks.push('"blacklist (package)" checked.');
|
|
423
456
|
|
|
@@ -429,10 +462,10 @@ async function checkPackageJson(context) {
|
|
|
429
462
|
const recommendedKeywords = ['ioBroker'];
|
|
430
463
|
common.debug(`package.keywords: "${context.packageJson.keywords.join(', ')}"`);
|
|
431
464
|
common.debug(`filtered: "${context.packageJson.keywords.filter(keyword => !ignoredKeywords.includes(keyword.toLowerCase()))}"`);
|
|
432
|
-
if (context.packageJson.keywords.filter(keyword => !ignoredKeywords.includes(keyword.toLowerCase())).length === 0
|
|
465
|
+
if (context.packageJson.keywords.filter(keyword => !ignoredKeywords.includes(keyword.toLowerCase())).length === 0) {
|
|
433
466
|
context.errors.push(`[E049] "keywords" within package.json must contain some keywords besides "${context.packageJson.keywords.join(', ')}" related to adapter`);
|
|
434
467
|
}
|
|
435
|
-
if (!
|
|
468
|
+
if (!recommendedKeywords.filter(keyword => context.packageJson.keywords.includes(keyword)).length > 0) {
|
|
436
469
|
context.warnings.push(`[W040] "keywords" within package.json should contain "${recommendedKeywords.join(', ')}"`);
|
|
437
470
|
}
|
|
438
471
|
if (forbiddenKeywords.filter(keyword => context.packageJson.keywords.map(k => k.toLowerCase()).includes(keyword)).length > 0) {
|