@iobroker/repochecker 2.2.3 → 2.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/README.md +9 -1
- package/doc/issues.json +36 -3
- package/index.js +436 -213
- package/package.json +1 -1
- package/doc/readme.js +0 -151
package/README.md
CHANGED
|
@@ -24,10 +24,18 @@ Branch (`master/main/dev`) is optional.
|
|
|
24
24
|
<!--
|
|
25
25
|
* (mcm1957) Added deprecate warnings for "main', 'materialize", "materializeTab" and "noConfig"
|
|
26
26
|
-->
|
|
27
|
+
### 2.3.0 (2024-05-07)
|
|
28
|
+
* (mcm1957) Elements marked as deprectaed added to blacklist.
|
|
29
|
+
* (mcm1957) Blacklist added to block elements at package.json and io-package.json.
|
|
30
|
+
* (mcm1957) Error [E000] will be raised now if repository cannot be accessed at all [#194].
|
|
31
|
+
* (mcm1957) Reading of package.json and io-package.json has been moved to head of tests.
|
|
32
|
+
* (mcm1957) Check minimum and recommended node version at package.json (#160)
|
|
33
|
+
* (mcm1957) Raise an error if version at package.json is lower than latest release at npmjs [#192]
|
|
34
|
+
|
|
27
35
|
### 2.2.3 (2024-03-29)
|
|
28
36
|
* (mcm1957) Checking of license has been improved
|
|
29
37
|
|
|
30
|
-
### 2.2.2 (2024-03-29)
|
|
38
|
+
### 2.2.2 (2024-03-29)
|
|
31
39
|
* (mcm1957) Checking of adapter-core has been fixed
|
|
32
40
|
* (mcm1957) Load all potential interesting files, fixes [#149]
|
|
33
41
|
|
package/doc/issues.json
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
+
"E000": {
|
|
3
|
+
"title": "FATAL: cannot access repository ${context.githubUrlApi}"
|
|
4
|
+
},
|
|
2
5
|
"E001": {
|
|
3
6
|
"_comment": "all texts can be string or object with language translations",
|
|
4
7
|
"title": {
|
|
@@ -122,9 +125,30 @@
|
|
|
122
125
|
"E025": {
|
|
123
126
|
"title": "Do not include `iobroker.js-controller` as dependency!"
|
|
124
127
|
},
|
|
128
|
+
"E026": {
|
|
129
|
+
"title": "`{'engines': {'node'>='${requiredNodeVersion}'}}` is required at package.json, `{'engines':{'node'>='${recommendedNodeVersion}'}}` is recommened"
|
|
130
|
+
},
|
|
125
131
|
"E029": {
|
|
126
132
|
"title": "Node.js ${requiredNodeVersion} is required as minimum, node.js ${recommendedNodeVersion} is recommended. Please adapt `{'engines' : { 'node' >= '${match.groups.vers}' } }` at package.json."
|
|
127
133
|
},
|
|
134
|
+
"E031": {
|
|
135
|
+
"title": "No devDependencies declared at package.json. Plase correct package.json"
|
|
136
|
+
},
|
|
137
|
+
"E032": {
|
|
138
|
+
"title": "No dependency declared for ${dependency}. Please add `${dependency}`:`${recommendedVersion}` to dependencies at package.json"
|
|
139
|
+
},
|
|
140
|
+
"E033": {
|
|
141
|
+
"title": "${dependency} ${dependencyVersion} specified. ${requiredVersion} is required as minimum, ${recommendedVersion} is recommended. Please update dependencies at package.json"
|
|
142
|
+
},
|
|
143
|
+
"E034": {
|
|
144
|
+
"title": "No devDependency declared for ${dependency}. Please add `${dependency}`:`${recommendedVersion}` to devDependencies at package.json"
|
|
145
|
+
},
|
|
146
|
+
"E035": {
|
|
147
|
+
"title": "${dependency} ${dependencyVersion} specified. ${requiredVersion} is required as minimum, ${recommendedVersion} is recommended. Please update devDependencies at package.json"
|
|
148
|
+
},
|
|
149
|
+
"E036": {
|
|
150
|
+
"title": "${blacklistPackageJson[blacklist].msg}"
|
|
151
|
+
},
|
|
128
152
|
"E100": {
|
|
129
153
|
"title": "Cannot parse io-package.json"
|
|
130
154
|
},
|
|
@@ -308,6 +332,9 @@
|
|
|
308
332
|
"E183": {
|
|
309
333
|
"title": "`common.licenseInformation.license` is missing"
|
|
310
334
|
},
|
|
335
|
+
"E184": {
|
|
336
|
+
"title": "${blacklistIOPackageJson[blacklist].msg}"
|
|
337
|
+
},
|
|
311
338
|
"E200": {
|
|
312
339
|
"title": "Not found on npm. Please publish"
|
|
313
340
|
},
|
|
@@ -458,15 +485,18 @@
|
|
|
458
485
|
"E903": {
|
|
459
486
|
"title": "iob_npm.done not found in .gitignore"
|
|
460
487
|
},
|
|
461
|
-
"W026": {
|
|
462
|
-
"title": "`{'engines' : { 'node' >= '${recommendedNodeVersion}' } }` is required at package.json"
|
|
463
|
-
},
|
|
464
488
|
"W027": {
|
|
465
489
|
"title": "{'engines' : { 'node' : '${nodeVal}' } }` is not parseable."
|
|
466
490
|
},
|
|
467
491
|
"W028": {
|
|
468
492
|
"title": "Minimum node.js version ${recommendedNodeVersion} recommended. Please adapt `{'engines' : { 'node' >= '${match.groups.vers}' } }` at package.json."
|
|
469
493
|
},
|
|
494
|
+
"W030": {
|
|
495
|
+
"title": "No dependencies declared at package.json. Is this really correct?"
|
|
496
|
+
},
|
|
497
|
+
"W036": {
|
|
498
|
+
"title": "${blacklistPackageJson[blacklist].msg}"
|
|
499
|
+
},
|
|
470
500
|
"W105": {
|
|
471
501
|
"title": "`common.titleLang` should be translated into all supported languages"
|
|
472
502
|
},
|
|
@@ -521,6 +551,9 @@
|
|
|
521
551
|
"W181": {
|
|
522
552
|
"title": "`common.license` in io-package.json is deprecated. Please define object `common.licenseInformation`"
|
|
523
553
|
},
|
|
554
|
+
"W184": {
|
|
555
|
+
"title": "${blacklistIOPackageJson[blacklist].msg}"
|
|
556
|
+
},
|
|
524
557
|
"W302": {
|
|
525
558
|
"title": "Use github actions instead of travis-ci"
|
|
526
559
|
},
|
package/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
|
|
5
4
|
___ _ _ _____ _ _
|
|
@@ -30,6 +29,63 @@ const recommendedJsControllerVersion = '5.0.11';
|
|
|
30
29
|
const recommendedNodeVersion = '18';
|
|
31
30
|
const requiredNodeVersion = '16';
|
|
32
31
|
|
|
32
|
+
const dependencies = {
|
|
33
|
+
"@iobroker/adapter-core": {
|
|
34
|
+
"required":"3.1.4",
|
|
35
|
+
"recommended":"3.1.4"
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const devDependencies = {
|
|
40
|
+
"@iobroker/testing": {
|
|
41
|
+
"required":"4.1.3",
|
|
42
|
+
"recommended":"4.1.3"
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const blacklistPackageJson = {
|
|
47
|
+
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const blacklistIOPackageJson = {
|
|
51
|
+
"installedFrom": {
|
|
52
|
+
"msg": "\"installedFrom\" is invalid at io-package.json. Please remove.",
|
|
53
|
+
"err": true
|
|
54
|
+
},
|
|
55
|
+
"common.installedFrom": {
|
|
56
|
+
"msg": "\"common.installedFrom\" is invalid. Please remove from io-package.json.",
|
|
57
|
+
"err": true
|
|
58
|
+
},
|
|
59
|
+
"common.title": {
|
|
60
|
+
"msg": "\"common.title\" is deprecated an replaces by \"common.titleLang\". Please remove from io-package.json.",
|
|
61
|
+
"err": false
|
|
62
|
+
},
|
|
63
|
+
"common.main": {
|
|
64
|
+
"msg": "\"common.main\" is deprecated and ignored. Please remove from io-package.json. Use \"main\" at package.json instead.",
|
|
65
|
+
"err": false
|
|
66
|
+
},
|
|
67
|
+
"common.materialize": {
|
|
68
|
+
"msg": "\"common.materialize\" is deprecated for admin >= 5 at io-package.json. Please use property \"adminUI\".",
|
|
69
|
+
"err": false
|
|
70
|
+
},
|
|
71
|
+
"common.materializeTab": {
|
|
72
|
+
"msg": "\"common.materializeTab\" is deprecated for admin >= 5 at io-package.json. Please use property \"adminUI\".",
|
|
73
|
+
"err": false
|
|
74
|
+
},
|
|
75
|
+
"common.noConfig": {
|
|
76
|
+
"msg": "\"common.noConfig\" is deprecated for admin >= 5 at io-package.json. Please use property \"adminUI.config\":\"none\".",
|
|
77
|
+
"err": false
|
|
78
|
+
},
|
|
79
|
+
"common.subscribe": {
|
|
80
|
+
"msg": "\"common.subscribe\" will be removed with js-controller >= 6. Please remove from io-package.json and adapt code if required.",
|
|
81
|
+
"err": true
|
|
82
|
+
},
|
|
83
|
+
"common.wapeup": {
|
|
84
|
+
"msg": "\"common.wakeup\" is deprecated and ignored. Please remove from io-package.json.",
|
|
85
|
+
"err": true
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
33
89
|
const memStore = {};
|
|
34
90
|
|
|
35
91
|
/* Writable memory stream */
|
|
@@ -85,6 +141,7 @@ function checkLanguages(langObj) {
|
|
|
85
141
|
|
|
86
142
|
function getGithubApiData(context) {
|
|
87
143
|
return new Promise((resolve, reject) => {
|
|
144
|
+
console.log('\ngetGithubApiData');
|
|
88
145
|
axios.get(context.githubUrlApi, { cache: false })
|
|
89
146
|
.then(response => {
|
|
90
147
|
context.githubApiData = response.data;
|
|
@@ -96,14 +153,93 @@ function getGithubApiData(context) {
|
|
|
96
153
|
}
|
|
97
154
|
|
|
98
155
|
context.githubUrl = `${context.githubUrlOriginal.replace('https://github.com', 'https://raw.githubusercontent.com')}/${context.branch}`;
|
|
99
|
-
console.log(`Original URL: ${context.githubUrlOriginal}
|
|
156
|
+
console.log(`Original URL: ${context.githubUrlOriginal}`);
|
|
157
|
+
console.log(`raw: ${context.githubUrl}`);
|
|
158
|
+
console.log(`api: ${context.githubUrlApi}`);
|
|
100
159
|
|
|
101
160
|
resolve(context);
|
|
102
161
|
})
|
|
103
|
-
.catch(e =>
|
|
162
|
+
.catch(e => {
|
|
163
|
+
context.errors.push(`[E000] FATAL: cannot access repository ${context.githubUrlApi}`);
|
|
164
|
+
reject(e.toJSON())
|
|
165
|
+
});// E0xx
|
|
104
166
|
});
|
|
105
167
|
}
|
|
106
168
|
|
|
169
|
+
// Error ranges
|
|
170
|
+
// E0xx
|
|
171
|
+
// check package.json
|
|
172
|
+
//
|
|
173
|
+
// E1xx
|
|
174
|
+
// check io-package.json
|
|
175
|
+
//
|
|
176
|
+
// E2xx
|
|
177
|
+
// check npm and npmjs.org
|
|
178
|
+
//
|
|
179
|
+
// E3xx
|
|
180
|
+
// check testing
|
|
181
|
+
//
|
|
182
|
+
// E4xx
|
|
183
|
+
// check repositories
|
|
184
|
+
//
|
|
185
|
+
// E5xx
|
|
186
|
+
// check code
|
|
187
|
+
//
|
|
188
|
+
// E6xx
|
|
189
|
+
// check README file
|
|
190
|
+
//
|
|
191
|
+
// E7xx
|
|
192
|
+
// check license file
|
|
193
|
+
//
|
|
194
|
+
// E8xx
|
|
195
|
+
// check github repository
|
|
196
|
+
//
|
|
197
|
+
// E9xx
|
|
198
|
+
// check .gitignore file
|
|
199
|
+
|
|
200
|
+
// ---------------------------- let's begin ----------------------------
|
|
201
|
+
|
|
202
|
+
function getPackageJson(context) {
|
|
203
|
+
return new Promise((resolve, reject) => {
|
|
204
|
+
console.log('\ngetPackageJson');
|
|
205
|
+
|
|
206
|
+
downloadFile(context.githubUrl, '/package.json')
|
|
207
|
+
.then(packageJson => {
|
|
208
|
+
context.packageJson = packageJson;
|
|
209
|
+
if (typeof context.packageJson === 'string') {
|
|
210
|
+
try {
|
|
211
|
+
context.packageJson = JSON.parse(context.packageJson);
|
|
212
|
+
} catch (e) {
|
|
213
|
+
context.errors.push(`[E001] Cannot parse package.json: ${e}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
resolve( context );
|
|
217
|
+
})
|
|
218
|
+
.catch(e => reject(e));
|
|
219
|
+
})
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
function getIOPackageJson(context) {
|
|
223
|
+
return new Promise((resolve, reject) => {
|
|
224
|
+
console.log('\ngetIOPackageJson');
|
|
225
|
+
|
|
226
|
+
downloadFile(context.githubUrl, '/io-package.json')
|
|
227
|
+
.then(ioPackageJson => {
|
|
228
|
+
context.ioPackageJson = ioPackageJson;
|
|
229
|
+
if (typeof context.ioPackageJson === 'string') {
|
|
230
|
+
try {
|
|
231
|
+
context.ioPackageJson = JSON.parse(context.ioPackageJson);
|
|
232
|
+
} catch (e) {
|
|
233
|
+
context.errors.push(`[E100] Cannot parse ioPackage.json: ${e}`);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
resolve( context );
|
|
237
|
+
})
|
|
238
|
+
.catch(e => reject(e));
|
|
239
|
+
})
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
|
|
107
243
|
// check package.json
|
|
108
244
|
// E0xx
|
|
109
245
|
function checkPackageJson(context) {
|
|
@@ -112,184 +248,282 @@ function checkPackageJson(context) {
|
|
|
112
248
|
if (context.packageJson) {
|
|
113
249
|
return resolve(context.packageJson);
|
|
114
250
|
} else {
|
|
115
|
-
|
|
116
|
-
.then(packageJson => resolve(packageJson))
|
|
117
|
-
.catch(e => reject(e));
|
|
251
|
+
throw('package.json not loaded');
|
|
118
252
|
}
|
|
119
253
|
})
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
254
|
+
.then(packageJson => {
|
|
255
|
+
context.packageJson = packageJson;
|
|
256
|
+
if (typeof context.packageJson === 'string') {
|
|
257
|
+
try {
|
|
258
|
+
context.packageJson = JSON.parse(context.packageJson);
|
|
259
|
+
} catch (e) {
|
|
260
|
+
context.errors.push(`[E001] Cannot parse package.json: ${e}`);
|
|
261
|
+
return context;
|
|
129
262
|
}
|
|
263
|
+
}
|
|
130
264
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
265
|
+
if (!context.githubUrlOriginal.match(/\/iobroker\./i)) {
|
|
266
|
+
context.errors.push('[E002] No "ioBroker." found in the name of repository');
|
|
267
|
+
} else {
|
|
268
|
+
context.checks.push('"ioBroker" was found in the name of repository');
|
|
269
|
+
}
|
|
136
270
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
271
|
+
if (context.githubUrlOriginal.includes('/iobroker.')) {
|
|
272
|
+
context.errors.push('[E003] Repository must have name ioBroker.adaptername, but now io"b"roker is in lowercase');
|
|
273
|
+
} else {
|
|
274
|
+
context.checks.push('Repository has name ioBroker.adaptername (not iobroker.adaptername)');
|
|
275
|
+
}
|
|
142
276
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
277
|
+
const m = context.githubUrlOriginal.match(/\/ioBroker\.(.*)$/);
|
|
278
|
+
let adapterName = '';
|
|
279
|
+
if (!m || !m[1]) {
|
|
280
|
+
context.errors.push(`[E004] No adapter name found in URL: ${context.githubUrlOriginal}`);
|
|
281
|
+
} else {
|
|
282
|
+
context.checks.push('Adapter name found in the URL');
|
|
283
|
+
adapterName = m[1].replace(/\/master$/, '').replace(/\/main$/, '');
|
|
284
|
+
}
|
|
151
285
|
|
|
152
|
-
|
|
286
|
+
context.adapterName = adapterName;
|
|
153
287
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
288
|
+
if (adapterName.match(/[A-Z]/)) {
|
|
289
|
+
context.errors.push('[E005] Adapter name must be lowercase');
|
|
290
|
+
} else {
|
|
291
|
+
context.checks.push('Adapter name is lowercase');
|
|
292
|
+
}
|
|
159
293
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
294
|
+
if (adapterName.match(/[^-_a-z\d]/)) {
|
|
295
|
+
context.errors.push(`[E006] Invalid characters found in adapter name "${adapterName}". Only lowercase chars, digits, "-" and "_" are allowed`);
|
|
296
|
+
} else {
|
|
297
|
+
context.checks.push(`No invalid characters found in "${adapterName}"`);
|
|
298
|
+
}
|
|
165
299
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
300
|
+
if (adapterName.startsWith('_')) {
|
|
301
|
+
context.errors.push(`[E024] Adapter name "${adapterName}" may not start with '_'`);
|
|
302
|
+
} else {
|
|
303
|
+
context.checks.push(`Adapter name "${adapterName}" does not start with '_'`);
|
|
304
|
+
}
|
|
171
305
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
306
|
+
const n = context.githubUrlOriginal.match(/\/([^/]+)\/iobroker\./i);
|
|
307
|
+
if (!n || !n[1]) {
|
|
308
|
+
context.errors.push('[E007] Cannot find author repo in the URL');
|
|
309
|
+
} else {
|
|
310
|
+
context.authorName = n[1];
|
|
311
|
+
}
|
|
178
312
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
313
|
+
if (context.packageJson.name !== `iobroker.${adapterName.toLowerCase()}`) {
|
|
314
|
+
context.errors.push(`[E020] Name of adapter in package.json must be lowercase and be equal to "iobroker.${adapterName.toLowerCase()}". Now is "${packageJson.name}"`);
|
|
315
|
+
} else {
|
|
316
|
+
context.checks.push(`Name of adapter in package.json must be lowercase and be equal to "iobroker.${adapterName.toLowerCase()}".`);
|
|
317
|
+
}
|
|
184
318
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
319
|
+
if (!context.packageJson.version) {
|
|
320
|
+
context.errors.push('[E009] No version found in the package.json');
|
|
321
|
+
} else {
|
|
322
|
+
context.checks.push('Version found in package.json');
|
|
323
|
+
}
|
|
190
324
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
325
|
+
if (!context.packageJson.description) {
|
|
326
|
+
context.errors.push('[E010] No description found in the package.json');
|
|
327
|
+
} else {
|
|
328
|
+
context.checks.push('Description found in package.json');
|
|
329
|
+
}
|
|
196
330
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
331
|
+
if (context.packageJson.licenses) {
|
|
332
|
+
context.errors.push('[E021] "licenses" in package.json are deprecated. Please remove and use "license": "NAME" field.');
|
|
333
|
+
} else {
|
|
334
|
+
context.checks.push('No "licenses" found in package.json');
|
|
335
|
+
}
|
|
202
336
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
337
|
+
if (!context.packageJson.author) {
|
|
338
|
+
context.errors.push('[E013] No author found in the package.json');
|
|
339
|
+
} else {
|
|
340
|
+
context.checks.push('Author found in package.json');
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (context.packageJson._args) {
|
|
344
|
+
context.errors.push('[E014] NPM information found in package.json. Please remove all attributes starting with "_"');
|
|
345
|
+
} else {
|
|
346
|
+
context.checks.push('No npm generated attributes found in package.json');
|
|
347
|
+
}
|
|
208
348
|
|
|
209
|
-
|
|
210
|
-
|
|
349
|
+
if (!context.packageJson.license) {
|
|
350
|
+
context.errors.push('[E015] No license found in package.json');
|
|
351
|
+
} else {
|
|
352
|
+
context.checks.push('"license" found in package.json');
|
|
353
|
+
|
|
354
|
+
// check if license valid
|
|
355
|
+
if (!licenses.includes(context.packageJson.license)) {
|
|
356
|
+
context.errors.push('[E016] ${context.packageJson.license} found in package.json is no valid SPDX license. Please use one of listed here: https://spdx.org/licenses/');
|
|
211
357
|
} else {
|
|
212
|
-
context.checks.push('
|
|
358
|
+
context.checks.push('"license" is valid in package.json');
|
|
213
359
|
}
|
|
360
|
+
}
|
|
214
361
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
362
|
+
if (!context.packageJson.repository) {
|
|
363
|
+
context.errors.push('[E017] No repository found in the package.json');
|
|
364
|
+
} else {
|
|
365
|
+
context.checks.push('Repository found in package.json');
|
|
366
|
+
|
|
367
|
+
const allowedRepoUrls = [
|
|
368
|
+
context.githubApiData.html_url, // https://github.com/klein0r/ioBroker.luftdaten
|
|
369
|
+
`git+${context.githubApiData.html_url}`, // git+https://github.com/klein0r/ioBroker.luftdaten
|
|
370
|
+
context.githubApiData.git_url, // git://github.com/klein0r/ioBroker.luftdaten.git
|
|
371
|
+
context.githubApiData.ssh_url, // git@github.com:klein0r/ioBroker.luftdaten.git
|
|
372
|
+
context.githubApiData.clone_url, // https://github.com/klein0r/ioBroker.luftdaten.git
|
|
373
|
+
`git+${context.githubApiData.clone_url}` // git+https://github.com/klein0r/ioBroker.luftdaten.git
|
|
374
|
+
];
|
|
375
|
+
|
|
376
|
+
// https://docs.npmjs.com/cli/v7/configuring-npm/package-json#repository
|
|
377
|
+
if (context.packageJson.repository && typeof context.packageJson.repository === 'object') {
|
|
378
|
+
if (context.packageJson.repository.type !== 'git') {
|
|
379
|
+
context.errors.push(`[E018] Invalid repository type in package.json: ${context.packageJson.repository.type}. It should be git`);
|
|
380
|
+
} else {
|
|
381
|
+
context.checks.push('Repository type is valid in package.json: git');
|
|
382
|
+
}
|
|
219
383
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
384
|
+
if (!allowedRepoUrls.includes(context.packageJson.repository.url)) {
|
|
385
|
+
context.errors.push(`[E019] Invalid repository URL in package.json: ${context.packageJson.repository.url}. Expected: ${context.githubApiData.ssh_url} or ${context.githubApiData.clone_url}`);
|
|
386
|
+
} else {
|
|
387
|
+
context.checks.push('Repository URL is valid in package.json');
|
|
388
|
+
}
|
|
389
|
+
} else if (context.packageJson.repository && typeof context.packageJson.repository === 'string') {
|
|
390
|
+
if (!allowedRepoUrls.includes(context.packageJson.repository)) {
|
|
391
|
+
context.errors.push(`[E019] Invalid repository URL in package.json: ${context.packageJson.repository}. Expected: ${context.githubApiData.ssh_url} or ${context.githubApiData.clone_url}`);
|
|
223
392
|
} else {
|
|
224
|
-
context.checks.push('
|
|
393
|
+
context.checks.push('Repository URL is valid in package.json');
|
|
225
394
|
}
|
|
395
|
+
} else {
|
|
396
|
+
context.errors.push('[E019] Invalid repository URL in package.json');
|
|
226
397
|
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
if (reservedAdapterNames.includes(adapterName)) {
|
|
401
|
+
context.errors.push('[E022] Adapter name is reserved. Please rename adapter.');
|
|
402
|
+
} else {
|
|
403
|
+
context.checks.push('Adapter name is not reserved');
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
if (!context.packageJson.dependencies) {
|
|
407
|
+
context.errors.push('[W030] No dependencies declared at package.json. Is this really correct?');
|
|
408
|
+
}
|
|
409
|
+
if (!context.packageJson.devDependencies) {
|
|
410
|
+
context.errors.push('[E031] No devDependencies declared at package.json. Plase correct package.json');
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if ((context.packageJson.dependencies && context.packageJson.dependencies.npm) || (context.packageJson.optionalDependencies && context.packageJson.optionalDependencies.npm)) {
|
|
414
|
+
context.errors.push('[E023] Do not include "npm" as dependency!');
|
|
415
|
+
} else {
|
|
416
|
+
context.checks.push('npm is not in dependencies');
|
|
417
|
+
}
|
|
227
418
|
|
|
228
|
-
|
|
229
|
-
|
|
419
|
+
if ((context.packageJson.dependencies && context.packageJson.dependencies['iobroker.js-controller']) ||
|
|
420
|
+
(context.packageJson.devDependencies && context.packageJson.devDependencies['iobroker.js-controller']) ||
|
|
421
|
+
(context.packageJson.optionalDependencies && context.packageJson.optionalDependencies['iobroker.js-controller'])
|
|
422
|
+
) {
|
|
423
|
+
context.errors.push('[E025] Do not include "iobroker.js-controller" as dependency!');
|
|
424
|
+
} else {
|
|
425
|
+
context.checks.push('iobroker.js-controller is not in dependencies');
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
if (!context.ioPackageJson.common.onlyWWW) {
|
|
429
|
+
if (!context.packageJson.engines) {
|
|
430
|
+
context.errors.push(`[E026] "{'engines': {'node'>='${requiredNodeVersion}'}}" is required at package.json, "{'engines':{'node'>='${recommendedNodeVersion}'}}" is recommened`);
|
|
230
431
|
} else {
|
|
231
|
-
context.
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
context.
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
// https://docs.npmjs.com/cli/v7/configuring-npm/package-json#repository
|
|
243
|
-
if (context.packageJson.repository && typeof context.packageJson.repository === 'object') {
|
|
244
|
-
if (context.packageJson.repository.type !== 'git') {
|
|
245
|
-
context.errors.push(`[E018] Invalid repository type in package.json: ${context.packageJson.repository.type}. It should be git`);
|
|
432
|
+
if (!context.packageJson.engines.node) {
|
|
433
|
+
context.errors.push(`[E026] "{'engines': {'node'>='${requiredNodeVersion}'}}" is required at package.json, "{'engines':{'node'>='${recommendedNodeVersion}'}}" is recommened`);
|
|
434
|
+
} else {
|
|
435
|
+
context.checks.push('engines attribute containing node requirements exist.');
|
|
436
|
+
// 'engines': { 'node': '>= 18' }
|
|
437
|
+
// 'engines': { 'node': '>= 18.1.2' }
|
|
438
|
+
// 'engines': { 'node': '>= 18.1.2 < 19' }
|
|
439
|
+
const nodeVal = context.packageJson.engines.node;
|
|
440
|
+
let match = nodeVal.match(/^^(?<cmp>[<>=~]+)?\s*(?<vers>\d+(\.\d+(\.\d+)?)?(\-\w+\.\d+)?)/m);
|
|
441
|
+
if ( ! match ) {
|
|
442
|
+
context.warnings.push(`[W027] {'engines' : { 'node' : '${nodeVal}' } }" is not parseable.`);
|
|
246
443
|
} else {
|
|
247
|
-
|
|
444
|
+
//console.log( `${JSON.stringify(match.groups)}`);
|
|
445
|
+
if ( match.groups.cmp !== '>' && match.groups.cmp !== '>=' ) {
|
|
446
|
+
context.warnings.push(`[W028] Minimum node.js version ${recommendedNodeVersion} recommended. Please adapt "{'engines' : { 'node' >= '${match.groups.vers}' } }" at package.json.`);
|
|
447
|
+
} else {
|
|
448
|
+
//console.log( `${match.groups.vers} - ${recommendedNodeVersion}`);
|
|
449
|
+
if ( ! compareVersions.compare( match.groups.vers, requiredNodeVersion, '>=')) {
|
|
450
|
+
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.`);
|
|
451
|
+
} else if ( ! compareVersions.compare( match.groups.vers, recommendedNodeVersion, '>=')) {
|
|
452
|
+
context.warnings.push(`[W028] Minimum node.js version ${recommendedNodeVersion} recommended. Please adapt "{'engines' : { 'node' >= '${match.groups.vers}' } }" at package.json.`);
|
|
453
|
+
} else {
|
|
454
|
+
context.checks.push(`Correct node.js version ${match.groups.vers} requested by "engines" attribute at package.json.`);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
248
457
|
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
} else {
|
|
461
|
+
context.checks.push('"engines" check skipped for wwwOnly adapter.');
|
|
462
|
+
}
|
|
249
463
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
464
|
+
if (!context.ioPackageJson.common.onlyWWW) {
|
|
465
|
+
for (const dependency in dependencies) {
|
|
466
|
+
const requiredVersion = dependencies[dependency].required;
|
|
467
|
+
const recommendedVersion = dependencies[dependency].recommended;
|
|
468
|
+
let dependencyVersion = context.packageJson.dependencies[`${dependency}`] || '';
|
|
469
|
+
dependencyVersion = dependencyVersion.replace(/[\^\~]/,'' );
|
|
470
|
+
if (!dependencyVersion) {
|
|
471
|
+
context.errors.push(`[E032] No dependency declared for ${dependency}. Please add "${dependency}":"${recommendedVersion}" to dependencies at package.json`);
|
|
472
|
+
} else if (! compareVersions.compare( dependencyVersion, requiredVersion, '>=' )) {
|
|
473
|
+
context.errors.push(`[E033] ${dependency} ${dependencyVersion} specified. ${requiredVersion} is required as minimum, ${recommendedVersion} is recommended. Please update dependencies at package.json`);
|
|
261
474
|
} else {
|
|
262
|
-
context.
|
|
475
|
+
context.checks.push('dependency ${dependency} ${dependencyVersion} is ok');
|
|
263
476
|
}
|
|
264
477
|
}
|
|
478
|
+
context.checks.push('"dependencies" checked.');
|
|
479
|
+
} else {
|
|
480
|
+
context.checks.push('"dependencies" check skipped for wwwOnly adapter.');
|
|
481
|
+
}
|
|
265
482
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
483
|
+
for (const dependency in devDependencies) {
|
|
484
|
+
const requiredVersion = devDependencies[dependency].required;
|
|
485
|
+
const recommendedVersion = devDependencies[dependency].recommended;
|
|
486
|
+
let dependencyVersion = context.packageJson.devDependencies[`${dependency}`] || '';
|
|
487
|
+
dependencyVersion = dependencyVersion.replace(/[\^\~]/,'' );
|
|
488
|
+
if (!dependencyVersion) {
|
|
489
|
+
context.errors.push(`[E034] No devDependency declared for ${dependency}. Please add "${dependency}":"${recommendedVersion}" to devDependencies at package.json`);
|
|
490
|
+
} else if (! compareVersions.compare( dependencyVersion, requiredVersion, '>=' )) {
|
|
491
|
+
context.errors.push(`[E035] ${dependency} ${dependencyVersion} specified. ${requiredVersion} is required as minimum, ${recommendedVersion} is recommended. Please update devDependencies at package.json`);
|
|
274
492
|
} else {
|
|
275
|
-
context.checks.push('
|
|
493
|
+
context.checks.push('devDependency ${dependency} ${dependencyVersion} is ok');
|
|
276
494
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
495
|
+
}
|
|
496
|
+
context.checks.push('"devDependencies" checked.');
|
|
497
|
+
|
|
498
|
+
for (const blacklist in blacklistPackageJson) {
|
|
499
|
+
//console.log(`checking blacklist ${blacklist}`);
|
|
500
|
+
let tmp = context.packageJson;
|
|
501
|
+
let log = '';
|
|
502
|
+
for (const element of blacklist.split('.')){
|
|
503
|
+
log = log + '.' + element;
|
|
504
|
+
//console.log(` check ${log}`);
|
|
505
|
+
tmp = tmp[element];
|
|
506
|
+
if ( !tmp ){
|
|
507
|
+
//console.log(` ${log} does not exist`);
|
|
508
|
+
break
|
|
509
|
+
}
|
|
285
510
|
}
|
|
511
|
+
if (tmp) {
|
|
512
|
+
if (blacklistPackageJson[blacklist].err) {
|
|
513
|
+
context.errors.push(`[E036] ${blacklistPackageJson[blacklist].msg}`);
|
|
514
|
+
} else {
|
|
515
|
+
context.warnings.push(`[W036] ${blacklistPackageJson[blacklist].msg}`);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
//else {
|
|
519
|
+
// console.log(`blacklist ${blacklist} no match`);
|
|
520
|
+
//}
|
|
521
|
+
}
|
|
522
|
+
context.checks.push('"blacklist (package)" checked.');
|
|
523
|
+
// max number is E036
|
|
286
524
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
// max number is E029
|
|
290
|
-
|
|
291
|
-
return context;
|
|
292
|
-
});
|
|
525
|
+
return context;
|
|
526
|
+
});
|
|
293
527
|
}
|
|
294
528
|
|
|
295
529
|
const allowedLanguages = [
|
|
@@ -723,11 +957,10 @@ function checkIOPackageJson(context) {
|
|
|
723
957
|
if (context.ioPackageJson) {
|
|
724
958
|
return resolve(context.ioPackageJson);
|
|
725
959
|
} else {
|
|
726
|
-
|
|
727
|
-
.then(packageJson => resolve(packageJson))
|
|
728
|
-
.catch(e => reject(e));
|
|
960
|
+
throw('io-package.json not loaded');
|
|
729
961
|
}
|
|
730
|
-
})
|
|
962
|
+
})
|
|
963
|
+
.then(ioPackageJson => {
|
|
731
964
|
return new Promise(resolve => {
|
|
732
965
|
context.ioPackageJson = ioPackageJson;
|
|
733
966
|
if (typeof context.ioPackageJson === 'string') {
|
|
@@ -1035,9 +1268,9 @@ function checkIOPackageJson(context) {
|
|
|
1035
1268
|
}
|
|
1036
1269
|
}
|
|
1037
1270
|
|
|
1038
|
-
if (context.ioPackageJson.common.installedFrom) {
|
|
1039
|
-
|
|
1040
|
-
}
|
|
1271
|
+
//if (context.ioPackageJson.common.installedFrom) {
|
|
1272
|
+
// context.errors.push('[E144] common.installedFrom field found in io-package.json. Must be removed.');
|
|
1273
|
+
//}
|
|
1041
1274
|
|
|
1042
1275
|
if (context.ioPackageJson.instanceObjects) {
|
|
1043
1276
|
const instanceObjects = context.ioPackageJson.instanceObjects;
|
|
@@ -1068,15 +1301,15 @@ function checkIOPackageJson(context) {
|
|
|
1068
1301
|
}
|
|
1069
1302
|
|
|
1070
1303
|
if (!context.ioPackageJson.common.connectionType) {
|
|
1071
|
-
!context.ioPackageJson.common.onlyWWW && context.errors.push('[E150] No common.connectionType found in io-package.json');
|
|
1304
|
+
!context.ioPackageJson.common.onlyWWW && context.errors.push('[E150] No "common.connectionType" found in io-package.json');
|
|
1072
1305
|
} else if (!['local', 'cloud', 'none'].includes(context.ioPackageJson.common.connectionType)) {
|
|
1073
|
-
context.errors.push(`[E151] common.connectionType type has an invalid value "${context.ioPackageJson.common.connectionType}"`);
|
|
1306
|
+
context.errors.push(`[E151] "common.connectionType" type has an invalid value "${context.ioPackageJson.common.connectionType}"`);
|
|
1074
1307
|
}
|
|
1075
1308
|
|
|
1076
1309
|
if (!context.ioPackageJson.common.dataSource) {
|
|
1077
|
-
!context.ioPackageJson.common.onlyWWW && context.errors.push('[E152] No common.dataSource found in io-package.json');
|
|
1310
|
+
!context.ioPackageJson.common.onlyWWW && context.errors.push('[E152] No "common.dataSource" found in io-package.json');
|
|
1078
1311
|
} else if (!['poll', 'push', 'assumption', 'none'].includes(context.ioPackageJson.common.dataSource)) {
|
|
1079
|
-
context.errors.push(`[
|
|
1312
|
+
context.errors.push(`[E153] "common.dataSource" type has an invalid value "${context.ioPackageJson.common.dataSource}"`);
|
|
1080
1313
|
}
|
|
1081
1314
|
|
|
1082
1315
|
let currentJsControllerVersion = undefined;
|
|
@@ -1184,9 +1417,9 @@ function checkIOPackageJson(context) {
|
|
|
1184
1417
|
|
|
1185
1418
|
if (!context.ioPackageJson.common.onlyWWW) {
|
|
1186
1419
|
if (!context.ioPackageJson.common.tier) {
|
|
1187
|
-
context.warnings.push(`[W115] common.tier is required in io-package.json. Please check https://github.com/ioBroker/ioBroker.docs/blob/master/docs/en/dev/objectsschema.md#adapter.`);
|
|
1420
|
+
context.warnings.push(`[W115] \"common.tier\" is required in io-package.json. Please check https://github.com/ioBroker/ioBroker.docs/blob/master/docs/en/dev/objectsschema.md#adapter.`);
|
|
1188
1421
|
} else if (![1, 2, 3].includes(context.ioPackageJson.common.tier)) {
|
|
1189
|
-
context.errors.push(`[E155] Invalid common.tier value: ${context.ioPackageJson.common.tier}. Only 1, 2 or 3 are allowed!`);
|
|
1422
|
+
context.errors.push(`[E155] Invalid \"common.tier\" value: ${context.ioPackageJson.common.tier} at io-package.json. Only 1, 2 or 3 are allowed!`);
|
|
1190
1423
|
} else {
|
|
1191
1424
|
context.checks.push('"common.tier" is valid in io-package.json');
|
|
1192
1425
|
}
|
|
@@ -1200,55 +1433,11 @@ function checkIOPackageJson(context) {
|
|
|
1200
1433
|
context.checks.push('"common.automaticUpgrade" does not exist in io-package.json');
|
|
1201
1434
|
}
|
|
1202
1435
|
|
|
1203
|
-
if (context.ioPackageJson.common.wakeup) {
|
|
1204
|
-
|
|
1205
|
-
} else {
|
|
1206
|
-
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
|
-
/*
|
|
1210
|
-
* The following check is logical related to package.json. It is placed here as the check must be performed only
|
|
1211
|
-
* if wwwOnly attribute is not set at io-package.json. Please note that these errors use error number form package.json range.
|
|
1212
|
-
*
|
|
1213
|
-
*/
|
|
1214
|
-
|
|
1215
|
-
if (!context.ioPackageJson.common.onlyWWW) {
|
|
1216
|
-
if (!context.packageJson.engines) {
|
|
1217
|
-
context.warnings.push(`[W026] "{'engines' : { 'node' >= '${recommendedNodeVersion}' } }" is required at package.json`);
|
|
1218
|
-
} else {
|
|
1219
|
-
if (!context.packageJson.engines.node) {
|
|
1220
|
-
context.warnings.push(`[W026] "{'engines' : { 'node' >= '${recommendedNodeVersion}' } }" is required at package.json`);
|
|
1221
|
-
} else {
|
|
1222
|
-
context.checks.push('engines attribute containing node requirements exist.');
|
|
1223
|
-
// 'engines': { 'node': '>= 18' }
|
|
1224
|
-
// 'engines': { 'node': '>= 18.1.2' }
|
|
1225
|
-
// 'engines': { 'node': '>= 18.1.2 < 19' }
|
|
1226
|
-
const nodeVal = context.packageJson.engines.node;
|
|
1227
|
-
let match = nodeVal.match(/^^(?<cmp>[<>=~]+)?\s*(?<vers>\d+(\.\d+(\.\d+)?)?(\-\w+\.\d+)?)/m);
|
|
1228
|
-
if ( ! match ) {
|
|
1229
|
-
context.warnings.push(`[W027] {'engines' : { 'node' : '${nodeVal}' } }" is not parseable.`);
|
|
1230
|
-
} else {
|
|
1231
|
-
//console.log( `${JSON.stringify(match.groups)}`);
|
|
1232
|
-
if ( match.groups.cmp !== '>' && match.groups.cmp !== '>=' ) {
|
|
1233
|
-
context.warnings.push(`[W026] "{'engines' : { 'node' >= '${recommendedNodeVersion}' } }" is required at package.json`);
|
|
1234
|
-
} else {
|
|
1235
|
-
//console.log( `${match.groups.vers} - ${recommendedNodeVersion}`);
|
|
1236
|
-
if ( ! compareVersions.compare( match.groups.vers, requiredNodeVersion, '>=')) {
|
|
1237
|
-
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.`);
|
|
1238
|
-
} else if ( ! compareVersions.compare( match.groups.vers, recommendedNodeVersion, '>=')) {
|
|
1239
|
-
context.warnings.push(`[W028] Minimum node.js version ${recommendedNodeVersion} recommended. Please adapt "{'engines' : { 'node' >= '${match.groups.vers}' } }" at package.json.`);
|
|
1240
|
-
} else {
|
|
1241
|
-
context.checks.push('Correct node.js version requested by "engines" attribute at package.json.');
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
|
-
}
|
|
1247
|
-
} else {
|
|
1248
|
-
context.checks.push('"engines" check skipped for wwwOnly adapter.');
|
|
1249
|
-
}
|
|
1250
|
-
/* end of foreign check */
|
|
1251
|
-
|
|
1436
|
+
//if (context.ioPackageJson.common.wakeup) {
|
|
1437
|
+
// context.warnings.push(`[W174] "common.wakeup" is deprectaed. Please remove from io-package.json`);
|
|
1438
|
+
//} else {
|
|
1439
|
+
// context.checks.push('"common.wakeup" does not exist in io-package.json');
|
|
1440
|
+
//}
|
|
1252
1441
|
|
|
1253
1442
|
if (context.ioPackageJson.common.restartAdapters) {
|
|
1254
1443
|
const restartAdaptersArray = context.ioPackageJson.common.restartAdapters;
|
|
@@ -1263,6 +1452,32 @@ function checkIOPackageJson(context) {
|
|
|
1263
1452
|
context.checks.push('"restartAdapters" check skipped as object not present.');
|
|
1264
1453
|
}
|
|
1265
1454
|
|
|
1455
|
+
for (const blacklist in blacklistIOPackageJson) {
|
|
1456
|
+
//console.log(`checking blacklist ${blacklist}`);
|
|
1457
|
+
let tmp = context.ioPackageJson;
|
|
1458
|
+
let log = '';
|
|
1459
|
+
for (const element of blacklist.split('.')){
|
|
1460
|
+
log = log + '.' + element;
|
|
1461
|
+
//console.log(` check ${log}`);
|
|
1462
|
+
tmp = tmp[element];
|
|
1463
|
+
if ( !tmp ){
|
|
1464
|
+
//console.log(` ${log} does not exist`);
|
|
1465
|
+
break
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
if (tmp) {
|
|
1469
|
+
if (blacklistIOPackageJson[blacklist].err) {
|
|
1470
|
+
context.errors.push(`[E184] ${blacklistIOPackageJson[blacklist].msg}`);
|
|
1471
|
+
} else {
|
|
1472
|
+
context.warnings.push(`[W184] ${blacklistIOPackageJson[blacklist].msg}`);
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
//else {
|
|
1476
|
+
// console.log(`blacklist ${blacklist} no match`);
|
|
1477
|
+
//}
|
|
1478
|
+
}
|
|
1479
|
+
context.checks.push('"blacklist (io-package)" checked.');
|
|
1480
|
+
|
|
1266
1481
|
if (context.ioPackageJson.common.extIcon) {
|
|
1267
1482
|
return downloadFile(context.ioPackageJson.common.extIcon, null, true)
|
|
1268
1483
|
.then(icon => {
|
|
@@ -1279,7 +1494,7 @@ function checkIOPackageJson(context) {
|
|
|
1279
1494
|
}
|
|
1280
1495
|
|
|
1281
1496
|
context.checks.push('"extIcon" could be downloaded');
|
|
1282
|
-
if (!context.ioPackageJson.onlyWWW && context.packageJson.main) {
|
|
1497
|
+
if (!context.ioPackageJson.common.onlyWWW && context.packageJson.main) {
|
|
1283
1498
|
return downloadFile(context.githubUrl, '/' + context.packageJson.main)
|
|
1284
1499
|
.then(() => context.checks.push(context.packageJson.main + ' could be downloaded'))
|
|
1285
1500
|
.catch(() => context.errors.push(`[E124] Main file not found under URL: ${context.githubUrl}/${context.packageJson.main}`))
|
|
@@ -1295,7 +1510,8 @@ function checkIOPackageJson(context) {
|
|
|
1295
1510
|
}
|
|
1296
1511
|
// do not put any code behind this line
|
|
1297
1512
|
|
|
1298
|
-
// max number is
|
|
1513
|
+
// max number is E184
|
|
1514
|
+
// free 144, 174
|
|
1299
1515
|
}
|
|
1300
1516
|
});
|
|
1301
1517
|
});
|
|
@@ -1342,10 +1558,15 @@ function checkNpm(context) {
|
|
|
1342
1558
|
if (!body['dist-tags'] ||
|
|
1343
1559
|
context.packageJson.version !== body['dist-tags'].latest
|
|
1344
1560
|
) {
|
|
1345
|
-
|
|
1346
|
-
(
|
|
1561
|
+
if ( compareVersions.compare( body['dist-tags'].latest, context.packageJson.version, '>=' )) {
|
|
1562
|
+
context.errors.push(`[E203] Version of package.json (${context.packageJson.version}) lower than latest version on NPM (${
|
|
1563
|
+
(body['dist-tags'] && body['dist-tags'].latest) || JSON.stringify(body)})`);
|
|
1564
|
+
} else {
|
|
1565
|
+
context.warnings.push(`[W202] Version of package.json (${context.packageJson.version}) doesn't match latest version on NPM (${
|
|
1566
|
+
(body['dist-tags'] && body['dist-tags'].latest) || JSON.stringify(body)})`);
|
|
1567
|
+
}
|
|
1347
1568
|
} else {
|
|
1348
|
-
context.checks.push(
|
|
1569
|
+
context.checks.push(`Version of package.json ${context.packageJson.version} matches latest version on NPM`);
|
|
1349
1570
|
}
|
|
1350
1571
|
}
|
|
1351
1572
|
|
|
@@ -1565,7 +1786,7 @@ function checkCode(context) {
|
|
|
1565
1786
|
'.releaseconfig.json',
|
|
1566
1787
|
|
|
1567
1788
|
// add all potential files anyway. If they exist they must be valid.
|
|
1568
|
-
// if the are
|
|
1789
|
+
// if the are not needed a warning could be issued
|
|
1569
1790
|
'admin/index_m.html',
|
|
1570
1791
|
'admin/words.js',
|
|
1571
1792
|
'admin/jsonConfig.json',
|
|
@@ -2073,7 +2294,7 @@ function makeResponse(code, data) {
|
|
|
2073
2294
|
}
|
|
2074
2295
|
|
|
2075
2296
|
function check(request, ctx, callback) {
|
|
2076
|
-
console.log('PROCESS: ' + JSON.stringify(request));
|
|
2297
|
+
// console.log('PROCESS: ' + JSON.stringify(request));
|
|
2077
2298
|
if (!request.queryStringParameters.url) {
|
|
2078
2299
|
return callback(null, makeResponse(500, {error: 'No github URL provided'}));
|
|
2079
2300
|
} else {
|
|
@@ -2095,6 +2316,8 @@ function check(request, ctx, callback) {
|
|
|
2095
2316
|
context.branch = githubBranch || null;
|
|
2096
2317
|
|
|
2097
2318
|
getGithubApiData(context)
|
|
2319
|
+
.then(context => getPackageJson(context))
|
|
2320
|
+
.then(context => getIOPackageJson(context))
|
|
2098
2321
|
.then(context => checkPackageJson(context))
|
|
2099
2322
|
.then(context => checkIOPackageJson(context))
|
|
2100
2323
|
.then(context => checkNpm(context))
|
package/package.json
CHANGED
package/doc/readme.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const issues = require('./issues');
|
|
3
|
-
const languages = ['en'];
|
|
4
|
-
|
|
5
|
-
// try to extract error description from index.js
|
|
6
|
-
function extractFromIndex() {
|
|
7
|
-
let added = false;
|
|
8
|
-
const lines = fs.readFileSync(`${__dirname}/../index.js`, {encoding: 'utf8'}).split('\n');
|
|
9
|
-
for (let i = 0; i < lines.length; i++) {
|
|
10
|
-
const m = lines[i].match(/`(\[[EW]\d\d\d] [^`]+)`/) || lines[i].match(/'(\[[EW]\d\d\d] [^`]+)'/) || lines[i].match(/"(\[[EW]\d\d\d] [^`]+)"/);
|
|
11
|
-
if (m) {
|
|
12
|
-
const parts = m[1].match(/\[([EW]\d\d\d)] (.+)/);
|
|
13
|
-
if (parts) {
|
|
14
|
-
console.log(parts[1], parts[2]);
|
|
15
|
-
if (!issues[parts[1]]) {
|
|
16
|
-
// cut off the last part
|
|
17
|
-
parts[2] = parts[2].replace(/"/g, '`');
|
|
18
|
-
issues[parts[1]] = {
|
|
19
|
-
title: parts[2],
|
|
20
|
-
};
|
|
21
|
-
added = true;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (added) {
|
|
27
|
-
// sort issues
|
|
28
|
-
const newIssues = {};
|
|
29
|
-
const keys = Object.keys(issues).sort();
|
|
30
|
-
keys.forEach(key => newIssues[key] = issues[key]);
|
|
31
|
-
|
|
32
|
-
fs.writeFileSync(`${__dirname}/issues.json`, JSON.stringify(newIssues, null, 2));
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
extractFromIndex();
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const explanationTitle = {
|
|
41
|
-
en: 'Explanation',
|
|
42
|
-
de: 'Erklärung',
|
|
43
|
-
ru: 'Объяснение',
|
|
44
|
-
fr: 'Explication',
|
|
45
|
-
nl: 'Uitleg',
|
|
46
|
-
'pt-pt': 'Explicação',
|
|
47
|
-
it: 'Spiegazione',
|
|
48
|
-
es: 'Explicación',
|
|
49
|
-
uk: 'Пояснення',
|
|
50
|
-
pl: 'Wyjaśnienie',
|
|
51
|
-
'zh-cn': '解释',
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const stepsTitle = {
|
|
55
|
-
en: 'Required step to resolve the problem',
|
|
56
|
-
de: 'Erforderlicher Schritt zur Behebung des Problems',
|
|
57
|
-
ru: 'Необходимый шаг для устранения проблемы',
|
|
58
|
-
fr: 'Étape requise pour résoudre le problème',
|
|
59
|
-
nl: 'Vereiste stap om het probleem op te lossen',
|
|
60
|
-
'pt-pt': 'Etapa necessária para resolver o problema',
|
|
61
|
-
it: 'Passaggio richiesto per risolvere il problema',
|
|
62
|
-
es: 'Paso requerido para resolver el problema',
|
|
63
|
-
uk: 'Необхідний крок для вирішення проблеми',
|
|
64
|
-
pl: 'Wymagany krok do rozwiązania problemu',
|
|
65
|
-
'zh-cn': '解决问题所需的步骤',
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const notesTitle = {
|
|
69
|
-
en: 'Technical notes',
|
|
70
|
-
de: 'Technische Notizen',
|
|
71
|
-
ru: 'Технические заметки',
|
|
72
|
-
fr: 'Notes techniques',
|
|
73
|
-
nl: 'Technische notities',
|
|
74
|
-
'pt-pt': 'Notas técnicas',
|
|
75
|
-
it: 'Note tecniche',
|
|
76
|
-
es: 'Notas técnicas',
|
|
77
|
-
uk: 'Технічні примітки',
|
|
78
|
-
pl: 'Notatki techniczne',
|
|
79
|
-
'zh-cn': '技术说明',
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
// try to find possible languages
|
|
84
|
-
Object.keys(issues).forEach(issue => {
|
|
85
|
-
const entry = issues[issue];
|
|
86
|
-
if (entry.title && typeof entry.title === 'object') {
|
|
87
|
-
const langs = Object.keys(entry.title);
|
|
88
|
-
langs.forEach(lang => !languages.includes(lang) && languages.push(lang));
|
|
89
|
-
}
|
|
90
|
-
if (entry.explanation && typeof entry.explanation === 'object') {
|
|
91
|
-
const langs = Object.keys(entry.explanation);
|
|
92
|
-
langs.forEach(lang => !languages.includes(lang) && languages.push(lang));
|
|
93
|
-
}
|
|
94
|
-
if (entry.resolving && typeof entry.resolving === 'object') {
|
|
95
|
-
const langs = Object.keys(entry.resolving);
|
|
96
|
-
langs.forEach(lang => !languages.includes(lang) && languages.push(lang));
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
function getText(text, lang) {
|
|
101
|
-
if (typeof text === 'object') {
|
|
102
|
-
if (text[lang]) {
|
|
103
|
-
return text[lang];
|
|
104
|
-
} else {
|
|
105
|
-
return text.en;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return text;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
languages.forEach(lang => {
|
|
112
|
-
// generate one language file for each language
|
|
113
|
-
const lines = [];
|
|
114
|
-
const content = [
|
|
115
|
-
'# Explanation of repo checker issues',
|
|
116
|
-
'## Content',
|
|
117
|
-
];
|
|
118
|
-
|
|
119
|
-
Object.keys(issues).forEach(issue => {
|
|
120
|
-
const entry = issues[issue];
|
|
121
|
-
const title = `[${issue}] ${getText(entry.title, lang)}`;
|
|
122
|
-
const explanation = getText(entry.explanation, lang);
|
|
123
|
-
const resolving = getText(entry.resolving, lang);
|
|
124
|
-
const note = getText(entry.note, lang);
|
|
125
|
-
|
|
126
|
-
// link => e001-cannot-parse-packetjson
|
|
127
|
-
content.push(`- [${issue} ${getText(entry.title, lang)}](#${title.toLowerCase()
|
|
128
|
-
.replace(/\s/g, '-')
|
|
129
|
-
.replace(/\[/g, '')
|
|
130
|
-
.replace(/]/g, '')
|
|
131
|
-
.replace(/[^-\w\d]/g, '')
|
|
132
|
-
})`);
|
|
133
|
-
lines.push(`### ${title}`);
|
|
134
|
-
if (explanation) {
|
|
135
|
-
lines.push(`#### ${getText(explanationTitle, lang)}`);
|
|
136
|
-
lines.push(explanation);
|
|
137
|
-
}
|
|
138
|
-
if (resolving) {
|
|
139
|
-
lines.push(`#### ${getText(stepsTitle, lang)}`);
|
|
140
|
-
lines.push(resolving);
|
|
141
|
-
}
|
|
142
|
-
if (note) {
|
|
143
|
-
lines.push(`#### ${getText(notesTitle, lang)}`);
|
|
144
|
-
lines.push(note);
|
|
145
|
-
}
|
|
146
|
-
lines.push('');
|
|
147
|
-
});
|
|
148
|
-
content.push('');
|
|
149
|
-
content.push('## Issues');
|
|
150
|
-
fs.writeFileSync(`${__dirname}/issues_${lang}.md`, `${content.join('\n')}\n${lines.join('\n')}\n`, {encoding: 'utf8'});
|
|
151
|
-
});
|