@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/lib/M250_Npm.js
CHANGED
|
@@ -10,15 +10,13 @@
|
|
|
10
10
|
const axios = require('axios');
|
|
11
11
|
const compareVersions = require('compare-versions');
|
|
12
12
|
|
|
13
|
-
|
|
14
13
|
// disable axios caching
|
|
15
14
|
axios.defaults.headers = {
|
|
16
15
|
'Cache-Control': 'no-cache',
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
Pragma: 'no-cache',
|
|
17
|
+
Expires: '0',
|
|
19
18
|
};
|
|
20
19
|
|
|
21
|
-
|
|
22
20
|
// const common = require('./common.js');
|
|
23
21
|
|
|
24
22
|
async function checkNpm(context) {
|
|
@@ -27,7 +25,7 @@ async function checkNpm(context) {
|
|
|
27
25
|
try {
|
|
28
26
|
const response = await axios(`https://registry.npmjs.org/iobroker.${context.adapterName}`);
|
|
29
27
|
body = response.data;
|
|
30
|
-
} catch
|
|
28
|
+
} catch {
|
|
31
29
|
/* */
|
|
32
30
|
}
|
|
33
31
|
// bug in NPM some modules could be accessed via normal web page, but not by API
|
|
@@ -37,37 +35,44 @@ async function checkNpm(context) {
|
|
|
37
35
|
if (!_response.data) {
|
|
38
36
|
context.errors.push('[E250] Not found on npm. Please publish');
|
|
39
37
|
return context;
|
|
40
|
-
}
|
|
41
|
-
|
|
38
|
+
}
|
|
39
|
+
body = _response.data;
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
context.checks.push('Adapter found on npm');
|
|
42
|
+
if (!body.includes('href="/~bluefox"') && body.includes('href="/~iobluefox"')) {
|
|
43
|
+
context.errors.push(
|
|
44
|
+
`[E251] Bluefox was not found in the collaborators on NPM!. Please execute in adapter directory: "npm owner add bluefox iobroker.${context.adapterName}"`,
|
|
45
|
+
);
|
|
46
|
+
} else {
|
|
47
|
+
context.checks.push('Bluefox found in collaborators on NPM');
|
|
49
48
|
}
|
|
50
|
-
} catch
|
|
49
|
+
} catch {
|
|
51
50
|
context.errors.push('[E250] Not found on npm. Please publish');
|
|
52
51
|
return context;
|
|
53
52
|
}
|
|
54
53
|
} else {
|
|
55
54
|
context.checks.push('Adapter found on npm');
|
|
56
|
-
if (
|
|
55
|
+
if (
|
|
56
|
+
!body.maintainers ||
|
|
57
57
|
!body.maintainers.length ||
|
|
58
|
-
!body.maintainers.find(user => user.name === 'bluefox' || user.name === 'iobluefox')
|
|
59
|
-
|
|
58
|
+
!body.maintainers.find(user => user.name === 'bluefox' || user.name === 'iobluefox')
|
|
59
|
+
) {
|
|
60
|
+
context.errors.push(
|
|
61
|
+
`[E251] Bluefox was not found in the collaborators on NPM!. Please execute in adapter directory: "npm owner add bluefox iobroker.${context.adapterName}"`,
|
|
62
|
+
);
|
|
60
63
|
} else {
|
|
61
64
|
context.checks.push('Bluefox found in collaborators on NPM');
|
|
62
65
|
}
|
|
63
66
|
|
|
64
|
-
if (!body['dist-tags'] ||
|
|
65
|
-
context.packageJson.version !== body['dist-tags'].latest
|
|
66
|
-
) {
|
|
67
|
+
if (!body['dist-tags'] || context.packageJson.version !== body['dist-tags'].latest) {
|
|
67
68
|
if (compareVersions.compare(body['dist-tags'].latest, context.packageJson.version, '>=')) {
|
|
68
|
-
context.errors.push(
|
|
69
|
+
context.errors.push(
|
|
70
|
+
`[E253] Version of package.json (${context.packageJson.version}) lower than latest version on NPM (${(body['dist-tags'] && body['dist-tags'].latest) || JSON.stringify(body)})`,
|
|
71
|
+
);
|
|
69
72
|
} else {
|
|
70
|
-
context.warnings.push(
|
|
73
|
+
context.warnings.push(
|
|
74
|
+
`[W252] Version of package.json (${context.packageJson.version}) doesn't match latest version on NPM (${(body['dist-tags'] && body['dist-tags'].latest) || JSON.stringify(body)})`,
|
|
75
|
+
);
|
|
71
76
|
}
|
|
72
77
|
} else {
|
|
73
78
|
context.checks.push(`Version of package.json ${context.packageJson.version} matches latest version on NPM`);
|
|
@@ -84,9 +89,13 @@ async function checkNpm(context) {
|
|
|
84
89
|
}
|
|
85
90
|
if (missingVersions.length) {
|
|
86
91
|
if (missingVersions.length === 1) {
|
|
87
|
-
context.errors.push(
|
|
92
|
+
context.errors.push(
|
|
93
|
+
`[E254] Version "${missingVersions.join(', ')}" listed at common.news at io-package.json does not exist at NPM. Please remove from news section.`,
|
|
94
|
+
);
|
|
88
95
|
} else {
|
|
89
|
-
context.errors.push(
|
|
96
|
+
context.errors.push(
|
|
97
|
+
`[E254] Versions "${missingVersions.join(', ')}" listed at common.news at io-package.json do not exist at NPM. Please remove from news section.`,
|
|
98
|
+
);
|
|
90
99
|
}
|
|
91
100
|
} else {
|
|
92
101
|
context.checks.push(`All versions listed at news exist at npm`);
|
|
@@ -111,4 +120,4 @@ exports.checkNpm = checkNpm;
|
|
|
111
120
|
// [252] Version of package.json (${context.packageJson.version}) doesn't match latest version on NPM (${
|
|
112
121
|
// [253] Version of package.json (${context.packageJson.version}) lower than latest version on NPM (${
|
|
113
122
|
// [254] Version "${missingVersions.join(', ')}" listed at common.news at io-package.json does not exist at NPM. Please remove from news section.
|
|
114
|
-
// [254] Versions "${missingVersions.join(', ')}" listed at common.news at io-package.json do not exist at NPM. Please remove from news section.
|
|
123
|
+
// [254] Versions "${missingVersions.join(', ')}" listed at common.news at io-package.json do not exist at NPM. Please remove from news section.
|
package/lib/M300_Testing.js
CHANGED
|
@@ -12,7 +12,13 @@
|
|
|
12
12
|
async function checkTests(context) {
|
|
13
13
|
console.log('\ncheckTests [E300 - E399]');
|
|
14
14
|
// if found some file in `\.github\workflows` with the test inside => it is OK too
|
|
15
|
-
if (
|
|
15
|
+
if (
|
|
16
|
+
context &&
|
|
17
|
+
context.filesList.find(
|
|
18
|
+
name =>
|
|
19
|
+
name.startsWith('.github/workflows/') && name.endsWith('.yml') && name.toLowerCase().includes('test'),
|
|
20
|
+
)
|
|
21
|
+
) {
|
|
16
22
|
context.checks.push('Tests found on github actions');
|
|
17
23
|
return context;
|
|
18
24
|
}
|
package/lib/M400_Repository.js
CHANGED
|
@@ -13,8 +13,8 @@ const compareVersions = require('compare-versions');
|
|
|
13
13
|
// disable axios caching
|
|
14
14
|
axios.defaults.headers = {
|
|
15
15
|
'Cache-Control': 'no-cache',
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
Pragma: 'no-cache',
|
|
17
|
+
Expires: '0',
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const common = require('./common.js');
|
|
@@ -22,12 +22,17 @@ const common = require('./common.js');
|
|
|
22
22
|
async function checkRepository(context) {
|
|
23
23
|
console.log('\ncheckRepository [E400 - E499]');
|
|
24
24
|
|
|
25
|
-
if (context.ioPackageJson && context.ioPackageJson.common && context.ioPackageJson.common.type) {
|
|
25
|
+
if (context.ioPackageJson && context.ioPackageJson.common && context.ioPackageJson.common.type) {
|
|
26
|
+
/* TODO: why check type here ? */
|
|
26
27
|
// download latest repo
|
|
27
|
-
const response = await axios(
|
|
28
|
+
const response = await axios(
|
|
29
|
+
'https://raw.githubusercontent.com/ioBroker/ioBroker.repositories/master/sources-dist.json',
|
|
30
|
+
);
|
|
28
31
|
let body = response.data;
|
|
29
32
|
if (!body) {
|
|
30
|
-
context.errors.push(
|
|
33
|
+
context.errors.push(
|
|
34
|
+
'[E400] Cannot download https://raw.githubusercontent.com/ioBroker/ioBroker.repositories/master/sources-dist.json',
|
|
35
|
+
);
|
|
31
36
|
} else {
|
|
32
37
|
context.latestRepo = body;
|
|
33
38
|
if (!context.latestRepo[context.adapterName]) {
|
|
@@ -42,9 +47,13 @@ async function checkRepository(context) {
|
|
|
42
47
|
context.checks.push('Adapter found in latest repository');
|
|
43
48
|
|
|
44
49
|
if (context.latestRepo[context.adapterName].type !== context.ioPackageJson.common.type) {
|
|
45
|
-
context.errors.push(
|
|
50
|
+
context.errors.push(
|
|
51
|
+
`[E402] Types of adapter in latest repository and in io-package.json are different "${context.latestRepo[context.adapterName].type}" !== "${context.ioPackageJson.common.type}"`,
|
|
52
|
+
);
|
|
46
53
|
} else {
|
|
47
|
-
context.checks.push(
|
|
54
|
+
context.checks.push(
|
|
55
|
+
`Types of adapter in latest repository and in io-package.json are equal: "${context.latestRepo[context.adapterName].type}"`,
|
|
56
|
+
);
|
|
48
57
|
}
|
|
49
58
|
|
|
50
59
|
if (context.latestRepo[context.adapterName].version) {
|
|
@@ -61,7 +70,9 @@ async function checkRepository(context) {
|
|
|
61
70
|
context.checks.push('Icon found in latest repository');
|
|
62
71
|
|
|
63
72
|
if (!context.latestRepo[context.adapterName].icon.startsWith(`${url}admin/`)) {
|
|
64
|
-
context.errors.push(
|
|
73
|
+
context.errors.push(
|
|
74
|
+
`[E405] Icon must be in the following path: ${url}admin/; correct sources-dist.json`,
|
|
75
|
+
);
|
|
65
76
|
} else {
|
|
66
77
|
context.checks.push('Icon found in latest repository');
|
|
67
78
|
}
|
|
@@ -72,7 +83,9 @@ async function checkRepository(context) {
|
|
|
72
83
|
context.checks.push('Meta URL(latest) found in latest repository');
|
|
73
84
|
|
|
74
85
|
if (context.latestRepo[context.adapterName].meta !== `${url}io-package.json`) {
|
|
75
|
-
context.errors.push(
|
|
86
|
+
context.errors.push(
|
|
87
|
+
`[E407] Meta URL must be equal to ${url}io-package.json; correct sources-dist.json`,
|
|
88
|
+
);
|
|
76
89
|
} else {
|
|
77
90
|
context.checks.push('Meta URL (latest) is OK in latest repository');
|
|
78
91
|
}
|
|
@@ -81,17 +94,25 @@ async function checkRepository(context) {
|
|
|
81
94
|
}
|
|
82
95
|
|
|
83
96
|
// download stable repo
|
|
84
|
-
let _response = await axios(
|
|
97
|
+
let _response = await axios(
|
|
98
|
+
'https://raw.githubusercontent.com/ioBroker/ioBroker.repositories/master/sources-dist-stable.json',
|
|
99
|
+
);
|
|
85
100
|
body = _response.data;
|
|
86
101
|
if (!body) {
|
|
87
|
-
context.errors.push(
|
|
102
|
+
context.errors.push(
|
|
103
|
+
'[E420] Cannot download https://raw.githubusercontent.com/ioBroker/ioBroker.repositories/master/sources-dist-stable.json',
|
|
104
|
+
);
|
|
88
105
|
} else {
|
|
89
106
|
context.stableRepo = body;
|
|
90
107
|
if (context.stableRepo[context.adapterName]) {
|
|
91
108
|
if (context.stableRepo[context.adapterName].type !== context.ioPackageJson.common.type) {
|
|
92
|
-
context.errors.push(
|
|
109
|
+
context.errors.push(
|
|
110
|
+
`[E422] Types of adapter in stable repository and in io-package.json are different "${context.stableRepo[context.adapterName].type}" !== "${context.ioPackageJson.common.type}"`,
|
|
111
|
+
);
|
|
93
112
|
} else {
|
|
94
|
-
context.checks.push(
|
|
113
|
+
context.checks.push(
|
|
114
|
+
`Types of adapter in stable repository and in io-package.json are equal: "${context.stableRepo[context.adapterName].type}"`,
|
|
115
|
+
);
|
|
95
116
|
}
|
|
96
117
|
|
|
97
118
|
if (!context.latestRepo[context.adapterName]) {
|
|
@@ -114,7 +135,9 @@ async function checkRepository(context) {
|
|
|
114
135
|
context.checks.push('Icon found in stable repository');
|
|
115
136
|
|
|
116
137
|
if (!context.stableRepo[context.adapterName].icon.startsWith(`${url}admin/`)) {
|
|
117
|
-
context.errors.push(
|
|
138
|
+
context.errors.push(
|
|
139
|
+
`[E426] Icon must be in the following path: ${url}admin/; correct sources-dist-stable.json`,
|
|
140
|
+
);
|
|
118
141
|
} else {
|
|
119
142
|
context.checks.push('Icon (stable) found in latest repository');
|
|
120
143
|
}
|
|
@@ -126,7 +149,9 @@ async function checkRepository(context) {
|
|
|
126
149
|
context.checks.push('Meta URL (stable) found in latest repository');
|
|
127
150
|
|
|
128
151
|
if (context.stableRepo[context.adapterName].meta !== `${url}io-package.json`) {
|
|
129
|
-
context.errors.push(
|
|
152
|
+
context.errors.push(
|
|
153
|
+
`[E428] Meta URL must be equal to ${url}io-package.json; correct sources-dist-stable.json`,
|
|
154
|
+
);
|
|
130
155
|
} else {
|
|
131
156
|
context.checks.push('Meta URL (stable) is OK in latest repository');
|
|
132
157
|
}
|
|
@@ -138,7 +163,7 @@ async function checkRepository(context) {
|
|
|
138
163
|
body = _response.data;
|
|
139
164
|
if (!body) {
|
|
140
165
|
context.errors.push('[E429] Cannot download http://repo.iobroker.live/sources-dist-latest.json');
|
|
141
|
-
throw
|
|
166
|
+
throw 'Cannot download http://repo.iobroker.live/sources-dist-latest.json'; // ABORT to avoid generating unuseable report
|
|
142
167
|
} else {
|
|
143
168
|
context.latestRepoLive = body;
|
|
144
169
|
}
|
|
@@ -147,7 +172,7 @@ async function checkRepository(context) {
|
|
|
147
172
|
body = _response.data;
|
|
148
173
|
if (!body) {
|
|
149
174
|
context.errors.push('[E430] Cannot download http://repo.iobroker.live/sources-dist.json');
|
|
150
|
-
throw
|
|
175
|
+
throw 'Cannot download http://repo.iobroker.live/sources-dist.json'; // ABORT to avoid generating unuseable report
|
|
151
176
|
} else {
|
|
152
177
|
context.stableRepoLive = body;
|
|
153
178
|
}
|
|
@@ -156,49 +181,79 @@ async function checkRepository(context) {
|
|
|
156
181
|
if (context.ioPackageJson.common.dependencies) {
|
|
157
182
|
const dependencies = common.getDependencies(context.ioPackageJson.common.dependencies);
|
|
158
183
|
for (const dependency in dependencies) {
|
|
159
|
-
|
|
160
184
|
if (!context.latestRepoLive[dependency]) {
|
|
161
|
-
context.errors.push(
|
|
185
|
+
context.errors.push(
|
|
186
|
+
`[E431] Dependency '${dependency}':'${dependencies[dependency]}' not available at latest repository`,
|
|
187
|
+
);
|
|
162
188
|
} else {
|
|
163
189
|
const versDependency = dependencies[dependency];
|
|
164
190
|
const versRepository = context.latestRepoLive[dependency].version;
|
|
165
191
|
//console.log( `DEBUG: dependency ${dependency} - ${versDependency} - latest ${versRepository}`);
|
|
166
192
|
if (!versDependency.startsWith('>=')) {
|
|
167
|
-
context.warnings.push(
|
|
193
|
+
context.warnings.push(
|
|
194
|
+
`[W432] Dependency '${dependency}':'${dependencies[dependency]}' should specify '>='`,
|
|
195
|
+
);
|
|
168
196
|
} else {
|
|
169
197
|
try {
|
|
170
|
-
if (
|
|
171
|
-
|
|
198
|
+
if (
|
|
199
|
+
!compareVersions.compare(
|
|
200
|
+
versRepository,
|
|
201
|
+
versDependency.replace('>=', '').trim(),
|
|
202
|
+
'>=',
|
|
203
|
+
)
|
|
204
|
+
) {
|
|
205
|
+
context.errors.push(
|
|
206
|
+
`[E431] Dependency '${dependency}':'${dependencies[dependency]}' not available at latest repository`,
|
|
207
|
+
);
|
|
172
208
|
} else {
|
|
173
|
-
context.checks.push(
|
|
209
|
+
context.checks.push(
|
|
210
|
+
`Dependency '${dependency}':'${dependencies[dependency]}' available at latest repository`,
|
|
211
|
+
);
|
|
174
212
|
}
|
|
175
213
|
} catch (e) {
|
|
176
|
-
context.errors.push(
|
|
214
|
+
context.errors.push(
|
|
215
|
+
`[E435] Dependency '${dependency}':'${dependencies[dependency]}' cannot be parsed - ${e}`,
|
|
216
|
+
);
|
|
177
217
|
}
|
|
178
218
|
}
|
|
179
219
|
}
|
|
180
220
|
|
|
181
221
|
if (!context.stableRepoLive[dependency]) {
|
|
182
|
-
context.warnings.push(
|
|
222
|
+
context.warnings.push(
|
|
223
|
+
`[W433] Dependency '${dependency}':'${dependencies[dependency]}' not available at stable repository`,
|
|
224
|
+
);
|
|
183
225
|
} else {
|
|
184
226
|
const versDependency = dependencies[dependency];
|
|
185
227
|
const versRepository = context.stableRepoLive[dependency].version;
|
|
186
228
|
//console.log( `DEBUG: dependency ${dependency} - ${versDependency} - latest ${versRepository}`);
|
|
187
229
|
if (!versDependency.startsWith('>=')) {
|
|
188
|
-
context.warnings.push(
|
|
230
|
+
context.warnings.push(
|
|
231
|
+
`[W434] Dependency '${dependency}':'${dependencies[dependency]}' should specify '>='`,
|
|
232
|
+
);
|
|
189
233
|
} else {
|
|
190
234
|
try {
|
|
191
|
-
if (
|
|
192
|
-
|
|
235
|
+
if (
|
|
236
|
+
!compareVersions.compare(
|
|
237
|
+
versRepository,
|
|
238
|
+
versDependency.replace('>=', '').trim(),
|
|
239
|
+
'>=',
|
|
240
|
+
)
|
|
241
|
+
) {
|
|
242
|
+
context.errors.push(
|
|
243
|
+
`[E433] Dependency '${dependency}':'${dependencies[dependency]}' not available at stable repository`,
|
|
244
|
+
);
|
|
193
245
|
} else {
|
|
194
|
-
context.checks.push(
|
|
246
|
+
context.checks.push(
|
|
247
|
+
`Dependency '${dependency}':'${dependencies[dependency]}' available at stable repository`,
|
|
248
|
+
);
|
|
195
249
|
}
|
|
196
250
|
} catch (e) {
|
|
197
|
-
context.errors.push(
|
|
251
|
+
context.errors.push(
|
|
252
|
+
`[E435] Dependency '${dependency}':'${dependencies[dependency]}' cannot be parsed - ${e}`,
|
|
253
|
+
);
|
|
198
254
|
}
|
|
199
255
|
}
|
|
200
256
|
}
|
|
201
|
-
|
|
202
257
|
}
|
|
203
258
|
} else {
|
|
204
259
|
context.checks.push('common.dependency check skipped');
|
|
@@ -207,45 +262,76 @@ async function checkRepository(context) {
|
|
|
207
262
|
if (context.ioPackageJson.common.globalDependencies) {
|
|
208
263
|
const dependencies = common.getDependencies(context.ioPackageJson.common.globalDependencies);
|
|
209
264
|
for (const dependency in dependencies) {
|
|
210
|
-
|
|
211
265
|
if (!context.latestRepoLive[dependency]) {
|
|
212
|
-
context.errors.push(
|
|
266
|
+
context.errors.push(
|
|
267
|
+
`[E431] Dependency '${dependency}':'${dependencies[dependency]}' not available at latest repository`,
|
|
268
|
+
);
|
|
213
269
|
} else {
|
|
214
270
|
const versDependency = dependencies[dependency];
|
|
215
271
|
const versRepository = context.latestRepoLive[dependency].version;
|
|
216
272
|
//console.log( `DEBUG: dependency ${dependency} - ${versDependency} - latest ${versRepository}`);
|
|
217
273
|
if (!versDependency.startsWith('>=')) {
|
|
218
|
-
context.warnings.push(
|
|
274
|
+
context.warnings.push(
|
|
275
|
+
`[W432] Dependency '${dependency}':'${dependencies[dependency]}' should specify '>='`,
|
|
276
|
+
);
|
|
219
277
|
} else {
|
|
220
278
|
try {
|
|
221
|
-
if (
|
|
222
|
-
|
|
279
|
+
if (
|
|
280
|
+
!compareVersions.compare(
|
|
281
|
+
versRepository,
|
|
282
|
+
versDependency.replace('>=', '').trim(),
|
|
283
|
+
'>=',
|
|
284
|
+
)
|
|
285
|
+
) {
|
|
286
|
+
context.errors.push(
|
|
287
|
+
`[E431] Dependency '${dependency}':'${dependencies[dependency]}' not available at latest repository`,
|
|
288
|
+
);
|
|
223
289
|
} else {
|
|
224
|
-
context.checks.push(
|
|
290
|
+
context.checks.push(
|
|
291
|
+
`Dependency '${dependency}':'${dependencies[dependency]}' available at latest repository`,
|
|
292
|
+
);
|
|
225
293
|
}
|
|
226
294
|
} catch (e) {
|
|
227
|
-
context.errors.push(
|
|
295
|
+
context.errors.push(
|
|
296
|
+
`[E435] Dependency '${dependency}':'${dependencies[dependency]}' cannot be parsed - ${e}`,
|
|
297
|
+
);
|
|
228
298
|
}
|
|
229
299
|
}
|
|
230
300
|
}
|
|
231
301
|
|
|
232
302
|
if (!context.stableRepoLive[dependency]) {
|
|
233
|
-
context.warnings.push(
|
|
303
|
+
context.warnings.push(
|
|
304
|
+
`[W433] Dependency '${dependency}':'${dependencies[dependency]}' not available at stable repository`,
|
|
305
|
+
);
|
|
234
306
|
} else {
|
|
235
307
|
const versDependency = dependencies[dependency];
|
|
236
308
|
const versRepository = context.stableRepoLive[dependency].version;
|
|
237
309
|
//console.log( `DEBUG: dependency ${dependency} - ${versDependency} - latest ${versRepository}`);
|
|
238
310
|
if (!versDependency.startsWith('>=')) {
|
|
239
|
-
context.warnings.push(
|
|
311
|
+
context.warnings.push(
|
|
312
|
+
`[W434] Dependency '${dependency}':'${dependencies[dependency]}' should specify '>='`,
|
|
313
|
+
);
|
|
240
314
|
} else {
|
|
241
315
|
try {
|
|
242
|
-
if (
|
|
243
|
-
|
|
316
|
+
if (
|
|
317
|
+
!compareVersions.compare(
|
|
318
|
+
versRepository,
|
|
319
|
+
versDependency.replace('>=', '').trim(),
|
|
320
|
+
'>=',
|
|
321
|
+
)
|
|
322
|
+
) {
|
|
323
|
+
context.errors.push(
|
|
324
|
+
`[E433] Dependency '${dependency}':'${dependencies[dependency]}' not available at stable repository`,
|
|
325
|
+
);
|
|
244
326
|
} else {
|
|
245
|
-
context.checks.push(
|
|
327
|
+
context.checks.push(
|
|
328
|
+
`Dependency '${dependency}':'${dependencies[dependency]}' available at stable repository`,
|
|
329
|
+
);
|
|
246
330
|
}
|
|
247
331
|
} catch (e) {
|
|
248
|
-
context.errors.push(
|
|
332
|
+
context.errors.push(
|
|
333
|
+
`[E435] Dependency '${dependency}':'${dependencies[dependency]}' cannot be parsed - ${e}`,
|
|
334
|
+
);
|
|
249
335
|
}
|
|
250
336
|
}
|
|
251
337
|
}
|
|
@@ -253,7 +339,6 @@ async function checkRepository(context) {
|
|
|
253
339
|
} else {
|
|
254
340
|
context.checks.push('common.globalDependency check skipped');
|
|
255
341
|
}
|
|
256
|
-
|
|
257
342
|
} else {
|
|
258
343
|
context.checks.push(`Dependency checks skipped due to repository access errors`);
|
|
259
344
|
}
|
package/lib/M500_Code.js
CHANGED
|
@@ -72,7 +72,7 @@ function extractWords(words) {
|
|
|
72
72
|
const resultFunc = new Function(`return ${words};`);
|
|
73
73
|
|
|
74
74
|
return resultFunc();
|
|
75
|
-
} catch
|
|
75
|
+
} catch {
|
|
76
76
|
return null;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -81,7 +81,7 @@ function getAllFiles(context, dirPath, root, filesList) {
|
|
|
81
81
|
const skipDirectories = ['.dev-server', 'node_modules', '.git', '.vscode'];
|
|
82
82
|
const files = fs.readdirSync(dirPath);
|
|
83
83
|
filesList = filesList || [];
|
|
84
|
-
files.forEach(
|
|
84
|
+
files.forEach(file => {
|
|
85
85
|
if (fs.statSync(path.join(dirPath, file)).isDirectory()) {
|
|
86
86
|
if (!skipDirectories.includes(file)) {
|
|
87
87
|
filesList = getAllFiles(context, path.join(dirPath, file), [root, file].join('/'), filesList);
|
|
@@ -123,9 +123,9 @@ async function checkCode(context) {
|
|
|
123
123
|
'src/package.json', // check if react is used
|
|
124
124
|
];
|
|
125
125
|
|
|
126
|
-
context.cfg.allowedLanguages.forEach(
|
|
126
|
+
context.cfg.allowedLanguages.forEach(lang => readFiles.push(`admin/i18n/${lang}/translations.json`));
|
|
127
127
|
|
|
128
|
-
context.cfg.allowedLanguages.forEach(
|
|
128
|
+
context.cfg.allowedLanguages.forEach(lang => readFiles.push(`admin/i18n/${lang}.json`));
|
|
129
129
|
|
|
130
130
|
if (context.packageJson.main) {
|
|
131
131
|
readFiles.push(context.packageJson.main);
|
|
@@ -175,13 +175,13 @@ async function checkCode(context) {
|
|
|
175
175
|
// parse zip file
|
|
176
176
|
const promises = [];
|
|
177
177
|
await (function () {
|
|
178
|
-
return new Promise(
|
|
178
|
+
return new Promise(_resolve => {
|
|
179
179
|
common.debug('init bufferstream');
|
|
180
180
|
let root = '';
|
|
181
181
|
bufferStream
|
|
182
182
|
.pipe(unzipper.Parse())
|
|
183
|
-
.on('entry',
|
|
184
|
-
common.debug(
|
|
183
|
+
.on('entry', entry => {
|
|
184
|
+
common.debug(`on.entry ${entry.path}`);
|
|
185
185
|
if (root === '') {
|
|
186
186
|
root = entry.path;
|
|
187
187
|
console.log(`Directory root set to ${root}`);
|
|
@@ -201,7 +201,7 @@ async function checkCode(context) {
|
|
|
201
201
|
|
|
202
202
|
if (readFiles.includes(name)) {
|
|
203
203
|
promises.push(
|
|
204
|
-
new Promise(
|
|
204
|
+
new Promise(resolve => {
|
|
205
205
|
const wstream = new WMStrm(name);
|
|
206
206
|
wstream.on('finish', () => {
|
|
207
207
|
context[`/${name}`] = memStore[name].toString();
|
|
@@ -312,13 +312,13 @@ async function checkCode(context) {
|
|
|
312
312
|
// at least 3 languages must be in
|
|
313
313
|
const words = extractWords(context['/admin/words.js']);
|
|
314
314
|
if (words) {
|
|
315
|
-
const problem = Object.keys(words).filter(
|
|
315
|
+
const problem = Object.keys(words).filter(word => !words[word].de || !words[word].ru);
|
|
316
316
|
if (problem.length > 3) {
|
|
317
317
|
context.errors.push(
|
|
318
318
|
`[E506] More non translated in german or russian words found in admin/words.js. You can use https://translator.iobroker.in/ for translations`,
|
|
319
319
|
);
|
|
320
320
|
} else {
|
|
321
|
-
problem.forEach(
|
|
321
|
+
problem.forEach(word => {
|
|
322
322
|
if (!words[word].de) {
|
|
323
323
|
context.errors.push(
|
|
324
324
|
`[E506] Word "${word}" is not translated to german in admin/words.js. You can use https://translator.iobroker.in/ for translations`,
|
|
@@ -357,7 +357,7 @@ async function checkCode(context) {
|
|
|
357
357
|
|
|
358
358
|
if (jsonConfig) {
|
|
359
359
|
if (jsonConfig.i18n === true) {
|
|
360
|
-
context.cfg.allowedLanguages.forEach(
|
|
360
|
+
context.cfg.allowedLanguages.forEach(lang => {
|
|
361
361
|
if (context[`/admin/i18n/${lang}/translations.json`]) {
|
|
362
362
|
try {
|
|
363
363
|
JSON.parse(context[`/admin/i18n/${lang}/translations.json`]);
|
|
@@ -382,8 +382,11 @@ async function checkCode(context) {
|
|
|
382
382
|
context.warnings.push(`[W522] Why did you decide not to use i18n support?`);
|
|
383
383
|
}
|
|
384
384
|
|
|
385
|
-
M500__jsonConfig.checkJsonConfig(
|
|
386
|
-
|
|
385
|
+
M500__jsonConfig.checkJsonConfig(
|
|
386
|
+
context,
|
|
387
|
+
`admin/jsonConfig.json${context['/admin/jsonConfig.json'] ? '' : '5'}`,
|
|
388
|
+
jsonConfig,
|
|
389
|
+
);
|
|
387
390
|
} // if (jsonConfig) ...
|
|
388
391
|
}
|
|
389
392
|
|
|
@@ -419,7 +422,7 @@ async function checkCode(context) {
|
|
|
419
422
|
'[E517] JavaScript-Rules support is declared, but no location in property common.javascriptRules.url defined',
|
|
420
423
|
);
|
|
421
424
|
}
|
|
422
|
-
if (!context.filesList.includes(
|
|
425
|
+
if (!context.filesList.includes(`admin/${context.ioPackageJson.common.javascriptRules.url}`)) {
|
|
423
426
|
context.errors.push(
|
|
424
427
|
`[E516] "${context.ioPackageJson.common.javascriptRules.url}" not found, but JavaScript-Rules support is declared`,
|
|
425
428
|
);
|
|
@@ -428,7 +431,7 @@ async function checkCode(context) {
|
|
|
428
431
|
|
|
429
432
|
const forbiddenFiles = ['iob_npm.done', 'iob', 'iobroker'];
|
|
430
433
|
|
|
431
|
-
forbiddenFiles.forEach(
|
|
434
|
+
forbiddenFiles.forEach(file => {
|
|
432
435
|
if (context.filesList.includes(file)) {
|
|
433
436
|
context.errors.push(`[E503] File "${file}" found in repo! Please remove file.`);
|
|
434
437
|
}
|
|
@@ -471,7 +474,7 @@ async function checkCode(context) {
|
|
|
471
474
|
'[E518] "@alcalzone/release-script" (>=3.0.0) is used, but ".releaseconfig.json" not found. Please create.',
|
|
472
475
|
);
|
|
473
476
|
} else {
|
|
474
|
-
console.log(
|
|
477
|
+
console.log(`context[/.releaseconfig.json: ${context['/.releaseconfig.json']}`);
|
|
475
478
|
try {
|
|
476
479
|
const releaseConfigJson = JSON.parse(context['/.releaseconfig.json']);
|
|
477
480
|
console.log(`releaseConfigJson: ${releaseConfigJson}`);
|
|
@@ -538,8 +541,8 @@ async function checkCode(context) {
|
|
|
538
541
|
}
|
|
539
542
|
}
|
|
540
543
|
if (
|
|
541
|
-
context[
|
|
542
|
-
!context[
|
|
544
|
+
context[`/${context.packageJson.main}`].includes('setTimeout(') &&
|
|
545
|
+
!context[`/${context.packageJson.main}`].includes('clearTimeout(')
|
|
543
546
|
) {
|
|
544
547
|
if (context.ioPackageJson.common.compact) {
|
|
545
548
|
// if compact mode supported, it is critical
|