@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
|
@@ -0,0 +1,603 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
'use strict';
|
|
3
|
+
/*
|
|
4
|
+
This module is a support module for iobroker.repochecker
|
|
5
|
+
|
|
6
|
+
Area checked: Adapter Code
|
|
7
|
+
Numbering : 500 - 599
|
|
8
|
+
|
|
9
|
+
Extension to check jsonConfig
|
|
10
|
+
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
|
|
15
|
+
Open questions:
|
|
16
|
+
- should HEADER have size attributes ?
|
|
17
|
+
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const common = require('./common.js');
|
|
21
|
+
|
|
22
|
+
let responsiveErrorLimit = 5;
|
|
23
|
+
|
|
24
|
+
const stdAttributes = [
|
|
25
|
+
'xl',
|
|
26
|
+
'lg',
|
|
27
|
+
'md',
|
|
28
|
+
'sm',
|
|
29
|
+
'xs',
|
|
30
|
+
|
|
31
|
+
'darkStyle',
|
|
32
|
+
'default',
|
|
33
|
+
'defaultFunc',
|
|
34
|
+
'disabled',
|
|
35
|
+
'doNotSave',
|
|
36
|
+
'help',
|
|
37
|
+
'helpLink',
|
|
38
|
+
'hidden',
|
|
39
|
+
'hideOnlyControl',
|
|
40
|
+
'label',
|
|
41
|
+
'newLine',
|
|
42
|
+
'noMultiEdit',
|
|
43
|
+
'noTranslation',
|
|
44
|
+
'onChange',
|
|
45
|
+
'placeholder',
|
|
46
|
+
'style',
|
|
47
|
+
'tooltip',
|
|
48
|
+
'validator',
|
|
49
|
+
'validatorErrorText',
|
|
50
|
+
'validatorNoSaveOnError',
|
|
51
|
+
|
|
52
|
+
'#include'
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
const validComponents = {
|
|
56
|
+
'accordion':check_accordion,
|
|
57
|
+
'alive': check_alive,
|
|
58
|
+
'autocomplete': check_autocomplete,
|
|
59
|
+
'autocompleteSendTo': check_autocompleteSendTo,
|
|
60
|
+
|
|
61
|
+
'certificate': check_certificate,
|
|
62
|
+
'certificates': check_certificates,
|
|
63
|
+
'certificateCollection': check_certificateCollection,
|
|
64
|
+
'checkbox': check_checkbox,
|
|
65
|
+
'checkLicense': check_checkLicense,
|
|
66
|
+
'chips': check_chips,
|
|
67
|
+
'color': check_color,
|
|
68
|
+
'coordinates': check_coordinates,
|
|
69
|
+
'cron': check_cron,
|
|
70
|
+
'custom': check_custom,
|
|
71
|
+
'datePicker': check_datePicker,
|
|
72
|
+
'deviceManager': check_deviceManager,
|
|
73
|
+
'divider': check_divider,
|
|
74
|
+
|
|
75
|
+
'file': check_file,
|
|
76
|
+
'fileSelector': check_fileSelector,
|
|
77
|
+
'func': check_func,
|
|
78
|
+
|
|
79
|
+
'header': check_header,
|
|
80
|
+
|
|
81
|
+
'image': check_image,
|
|
82
|
+
'imageSendTo': check_imageSendTo,
|
|
83
|
+
'instance': check_instance,
|
|
84
|
+
'interface': check_interface,
|
|
85
|
+
'ip': check_ip,
|
|
86
|
+
|
|
87
|
+
'jsonEditor': check_jsonEditor,
|
|
88
|
+
|
|
89
|
+
'language': check_language,
|
|
90
|
+
'license': check_license,
|
|
91
|
+
|
|
92
|
+
'number': check_number,
|
|
93
|
+
|
|
94
|
+
'objectId': check_objectId,
|
|
95
|
+
|
|
96
|
+
'password': check_password,
|
|
97
|
+
'pattern': check_pattern,
|
|
98
|
+
'port': check_port,
|
|
99
|
+
|
|
100
|
+
'qrCode': check_qrCode,
|
|
101
|
+
|
|
102
|
+
'room': check_room,
|
|
103
|
+
|
|
104
|
+
'select': check_select,
|
|
105
|
+
'selectSendTo': check_selectSendTo,
|
|
106
|
+
'sendTo': check_sendTo,
|
|
107
|
+
'setState': check_setState,
|
|
108
|
+
'slider': check_slider,
|
|
109
|
+
'state': check_state,
|
|
110
|
+
'staticImage': check_staticImage,
|
|
111
|
+
'staticLink': check_staticLink,
|
|
112
|
+
'staticText': check_staticText,
|
|
113
|
+
|
|
114
|
+
'table': check_table,
|
|
115
|
+
'text': check_text,
|
|
116
|
+
'textSendTo': check_textSendTo,
|
|
117
|
+
'timePicker': check_timePicker,
|
|
118
|
+
|
|
119
|
+
'user': check_user,
|
|
120
|
+
'uuid': check_uuid,
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
function handleResponsiveError(context, msg) {
|
|
124
|
+
if (responsiveErrorLimit) {
|
|
125
|
+
context.errors.push(`${msg}`);
|
|
126
|
+
responsiveErrorLimit--;
|
|
127
|
+
if (responsiveErrorLimit === 0) {
|
|
128
|
+
context.errors.push(`[E510] responsive check: maximum issues reached, please fix reported ones and recheck`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function chk_responsive (context, path, jsonConfig){
|
|
134
|
+
common.debug(`chk_responsive ${path}`);
|
|
135
|
+
const missing = [];
|
|
136
|
+
if (!jsonConfig.xs) missing.push('xs');
|
|
137
|
+
if (!jsonConfig.sm) missing.push('sm');
|
|
138
|
+
if (!jsonConfig.md) missing.push('md');
|
|
139
|
+
if (!jsonConfig.lg) missing.push('lg');
|
|
140
|
+
if (!jsonConfig.xl) missing.push('xl');
|
|
141
|
+
if (missing.length) {
|
|
142
|
+
handleResponsiveError(context, `[E507] responsive check: missing size attributes [${missing.join(',')}] at ${path}`);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if ( jsonConfig.xs && jsonConfig.xs != 12) {
|
|
146
|
+
handleResponsiveError(context, `[E508] responsive check: attribute "xs" should specify a value of "12" at ${path}`);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
let ii = 12;
|
|
150
|
+
if (jsonConfig.xs) ii = jsonConfig.xs;
|
|
151
|
+
if (jsonConfig.sm && jsonConfig.sm > ii ) {
|
|
152
|
+
handleResponsiveError(context, `[E509] responsive check: "sm" value (${jsonConfig.sm}) greater then value for smaller displays`);
|
|
153
|
+
} else {
|
|
154
|
+
ii = jsonConfig.sm;
|
|
155
|
+
}
|
|
156
|
+
if (jsonConfig.md && jsonConfig.md > ii ) {
|
|
157
|
+
handleResponsiveError(context, `[E509] responsive check: "md" value (${jsonConfig.md}) greater then value for smaller displays`);
|
|
158
|
+
} else {
|
|
159
|
+
ii = jsonConfig.md;
|
|
160
|
+
}
|
|
161
|
+
if (jsonConfig.lg && jsonConfig.lg > ii ) {
|
|
162
|
+
handleResponsiveError(context, `[E509] responsive check: "lg" value (${jsonConfig.lg}) greater then value for smaller displays`);
|
|
163
|
+
} else {
|
|
164
|
+
ii = jsonConfig.lg;
|
|
165
|
+
}
|
|
166
|
+
if (jsonConfig.xl && jsonConfig.xl > ii ) {
|
|
167
|
+
handleResponsiveError(context, `[E509] responsive check: "xl" value (${jsonConfig.xl}) greater then value for smaller displays`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function check_accordion (context, path, jsonConfig, inTable){
|
|
172
|
+
common.debug(`check_accordion ${path}`);
|
|
173
|
+
chk_responsive(context, path, jsonConfig);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function check_alive(context, path, jsonConfig, inTable){
|
|
177
|
+
common.debug(`check_alive ${path}`);
|
|
178
|
+
chk_responsive(context, path, jsonConfig);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function check_autocomplete(context, path, jsonConfig, inTable){
|
|
182
|
+
common.debug(`check_autocomplete ${path}`);
|
|
183
|
+
chk_responsive(context, path, jsonConfig);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function check_autocompleteSendTo(context, path, jsonConfig, inTable){
|
|
187
|
+
common.debug(`check_autocompleteSendTo ${path}`);
|
|
188
|
+
chk_responsive(context, path, jsonConfig);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function check_certificate(context, path, jsonConfig, inTable){
|
|
192
|
+
common.debug(`check_certificate ${path}`);
|
|
193
|
+
chk_responsive(context, path, jsonConfig);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function check_certificates(context, path, jsonConfig, inTable){
|
|
197
|
+
common.debug(`check_certificates ${path}`);
|
|
198
|
+
chk_responsive(context, path, jsonConfig);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function check_certificateCollection(context, path, jsonConfig, inTable){
|
|
202
|
+
common.debug(`check_certificateCollection ${path}`);
|
|
203
|
+
chk_responsive(context, path, jsonConfig);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function check_checkbox(context, path, jsonConfig, inTable){
|
|
207
|
+
common.debug(`check_checkbox ${path}`);
|
|
208
|
+
chk_responsive(context, path, jsonConfig);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function check_checkLicense(context, path, jsonConfig, inTable){
|
|
212
|
+
common.debug(`check_checkLicense ${path}`);
|
|
213
|
+
chk_responsive(context, path, jsonConfig);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function check_chips(context, path, jsonConfig, inTable){
|
|
217
|
+
common.debug(`check_chips ${path}`);
|
|
218
|
+
chk_responsive(context, path, jsonConfig);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function check_color(context, path, jsonConfig, inTable){
|
|
222
|
+
common.debug(`check_color ${path}`);
|
|
223
|
+
chk_responsive(context, path, jsonConfig);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function check_coordinates(context, path, jsonConfig, inTable){
|
|
227
|
+
common.debug(`check_coordinates ${path}`);
|
|
228
|
+
chk_responsive(context, path, jsonConfig);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function check_cron(context, path, jsonConfig, inTable){
|
|
232
|
+
common.debug(`check_staticText ${path}`);
|
|
233
|
+
chk_responsive(context, path, jsonConfig);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function check_custom(context, path, jsonConfig, inTable){
|
|
237
|
+
common.debug(`check_custom ${path}`);
|
|
238
|
+
chk_responsive(context, path, jsonConfig);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function check_datePicker(context, path, jsonConfig, inTable){
|
|
242
|
+
common.debug(`check_datePicker ${path}`);
|
|
243
|
+
chk_responsive(context, path, jsonConfig);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function check_deviceManager(context, path, jsonConfig, inTable){
|
|
247
|
+
common.debug(`check_deviceManager ${path}`);
|
|
248
|
+
chk_responsive(context, path, jsonConfig);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function check_divider(context, path, jsonConfig, inTable){
|
|
252
|
+
common.debug(`check_divider ${path}`);
|
|
253
|
+
chk_responsive(context, path, jsonConfig);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function check_file(context, path, jsonConfig, inTable){
|
|
257
|
+
common.debug(`check_file ${path}`);
|
|
258
|
+
chk_responsive(context, path, jsonConfig);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function check_fileSelector(context, path, jsonConfig, inTable){
|
|
262
|
+
common.debug(`check_fileSelector ${path}`);
|
|
263
|
+
chk_responsive(context, path, jsonConfig);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function check_func(context, path, jsonConfig, inTable){
|
|
267
|
+
common.debug(`check_func ${path}`);
|
|
268
|
+
chk_responsive(context, path, jsonConfig);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function check_header(context, path, jsonConfig, inTable){
|
|
272
|
+
common.debug(`check_header ${path}`);
|
|
273
|
+
// chk_responsive(context, path, jsonConfig); // must be discussed
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function check_image(context, path, jsonConfig, inTable){
|
|
277
|
+
common.debug(`check_image ${path}`);
|
|
278
|
+
chk_responsive(context, path, jsonConfig);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function check_imageSendTo(context, path, jsonConfig, inTable){
|
|
282
|
+
common.debug(`check_imageSendTo ${path}`);
|
|
283
|
+
chk_responsive(context, path, jsonConfig);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function check_instance(context, path, jsonConfig, inTable){
|
|
287
|
+
common.debug(`check_instance ${path}`);
|
|
288
|
+
chk_responsive(context, path, jsonConfig);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function check_interface(context, path, jsonConfig, inTable){
|
|
292
|
+
common.debug(`check_interface ${path}`);
|
|
293
|
+
chk_responsive(context, path, jsonConfig);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function check_ip(context, path, jsonConfig, inTable){
|
|
297
|
+
common.debug(`check_ip ${path}`);
|
|
298
|
+
chk_responsive(context, path, jsonConfig);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function check_jsonEditor(context, path, jsonConfig, inTable){
|
|
302
|
+
common.debug(`check_jsonEditor ${path}`);
|
|
303
|
+
chk_responsive(context, path, jsonConfig);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function check_language(context, path, jsonConfig, inTable){
|
|
307
|
+
common.debug(`check_language ${path}`);
|
|
308
|
+
chk_responsive(context, path, jsonConfig);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function check_license(context, path, jsonConfig, inTable){
|
|
312
|
+
common.debug(`check_license ${path}`);
|
|
313
|
+
chk_responsive(context, path, jsonConfig);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function check_number(context, path, jsonConfig, inTable){
|
|
317
|
+
common.debug(`check_number ${path}`);
|
|
318
|
+
chk_responsive(context, path, jsonConfig);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function check_objectId(context, path, jsonConfig, inTable){
|
|
322
|
+
common.debug(`check_objectId ${path}`);
|
|
323
|
+
chk_responsive(context, path, jsonConfig);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function check_password(context, path, jsonConfig, inTable){
|
|
327
|
+
common.debug(`check_password ${path}`);
|
|
328
|
+
chk_responsive(context, path, jsonConfig);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function check_pattern(context, path, jsonConfig, inTable){
|
|
332
|
+
common.debug(`check_pattern ${path}`);
|
|
333
|
+
chk_responsive(context, path, jsonConfig);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function check_port(context, path, jsonConfig, inTable){
|
|
337
|
+
common.debug(`check_port ${path}`);
|
|
338
|
+
chk_responsive(context, path, jsonConfig);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function check_qrCode(context, path, jsonConfig, inTable){
|
|
342
|
+
common.debug(`check_qrCode ${path}`);
|
|
343
|
+
chk_responsive(context, path, jsonConfig);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function check_room(context, path, jsonConfig, inTable){
|
|
347
|
+
common.debug(`check_room ${path}`);
|
|
348
|
+
chk_responsive(context, path, jsonConfig);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function check_select(context, path, jsonConfig, inTable){
|
|
352
|
+
common.debug(`check_select ${path}`);
|
|
353
|
+
chk_responsive(context, path, jsonConfig);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function check_selectSendTo(context, path, jsonConfig, inTable){
|
|
357
|
+
common.debug(`check_selectSendTo ${path}`);
|
|
358
|
+
chk_responsive(context, path, jsonConfig);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function check_sendTo(context, path, jsonConfig, inTable){
|
|
362
|
+
common.debug(`check_sendTo ${path}`);
|
|
363
|
+
chk_responsive(context, path, jsonConfig);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function check_setState(context, path, jsonConfig, inTable){
|
|
367
|
+
common.debug(`check_setState ${path}`);
|
|
368
|
+
chk_responsive(context, path, jsonConfig);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function check_slider(context, path, jsonConfig, inTable){
|
|
372
|
+
common.debug(`check_slider ${path}`);
|
|
373
|
+
chk_responsive(context, path, jsonConfig);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function check_state(context, path, jsonConfig, inTable){
|
|
377
|
+
common.debug(`check_state ${path}`);
|
|
378
|
+
chk_responsive(context, path, jsonConfig);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function check_staticImage(context, path, jsonConfig, inTable){
|
|
382
|
+
common.debug(`check_staticImage ${path}`);
|
|
383
|
+
chk_responsive(context, path, jsonConfig);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function check_staticLink(context, path, jsonConfig, inTable){
|
|
387
|
+
common.debug(`check_staticLink ${path}`);
|
|
388
|
+
chk_responsive(context, path, jsonConfig);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function check_staticText(context, path, jsonConfig, inTable){
|
|
392
|
+
common.debug(`check_staticText ${path}`);
|
|
393
|
+
chk_responsive(context, path, jsonConfig);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function check_table(context, path, jsonConfig, inTable){
|
|
397
|
+
common.debug(`check_table ${path}`);
|
|
398
|
+
chk_responsive(context, path, jsonConfig);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function check_text(context, path, jsonConfig, inTable){
|
|
402
|
+
common.debug(`check_text ${path}`);
|
|
403
|
+
chk_responsive(context, path, jsonConfig);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function check_textSendTo(context, path, jsonConfig, inTable){
|
|
407
|
+
common.debug(`check_textSendTo ${path}`);
|
|
408
|
+
chk_responsive(context, path, jsonConfig);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function check_timePicker(context, path, jsonConfig, inTable){
|
|
412
|
+
common.debug(`check_timePicker ${path}`);
|
|
413
|
+
chk_responsive(context, path, jsonConfig);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
function check_user(context, path, jsonConfig, inTable){
|
|
417
|
+
common.debug(`check_user ${path}`);
|
|
418
|
+
chk_responsive(context, path, jsonConfig);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
function check_uuid(context, path, jsonConfig, inTable){
|
|
422
|
+
common.debug(`check_uuid ${path}`);
|
|
423
|
+
chk_responsive(context, path, jsonConfig);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
function checkComponent(context, path, jsonConfig) {
|
|
428
|
+
common.debug(`checkComponent (${path})`);
|
|
429
|
+
|
|
430
|
+
const type = jsonConfig.type;
|
|
431
|
+
if (!type) {
|
|
432
|
+
context.errors.push(`[E502] no type specified at ${path}`);
|
|
433
|
+
}
|
|
434
|
+
common.debug(` type ${type}`);
|
|
435
|
+
|
|
436
|
+
if (validComponents[type] === undefined) {
|
|
437
|
+
context.errors.push(`[E504] unexpected component "${type}" detected at ${path}`);
|
|
438
|
+
} else if (typeof(validComponents[type]) === 'function') {
|
|
439
|
+
(validComponents[type])(context, path, jsonConfig, false);
|
|
440
|
+
} else {
|
|
441
|
+
common.debug(`no checks defined for component ${type}`);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function checkPanel(context, path, jsonConfig, isRoot) {
|
|
447
|
+
common.debug(`checkPanel(${path})`);
|
|
448
|
+
|
|
449
|
+
const rootAttributes = [
|
|
450
|
+
'i18n',
|
|
451
|
+
];
|
|
452
|
+
|
|
453
|
+
const myAttributes = [
|
|
454
|
+
'type',
|
|
455
|
+
|
|
456
|
+
'collapsable',
|
|
457
|
+
'color',
|
|
458
|
+
'icon',
|
|
459
|
+
'innerStyle',
|
|
460
|
+
'items',
|
|
461
|
+
'label',
|
|
462
|
+
];
|
|
463
|
+
|
|
464
|
+
const validAttributes = stdAttributes.concat(myAttributes).concat(isRoot?rootAttributes:[]);
|
|
465
|
+
|
|
466
|
+
for (const key in jsonConfig) {
|
|
467
|
+
common.debug(` scanning ${key}`);
|
|
468
|
+
|
|
469
|
+
if (!validAttributes.includes(key)) {
|
|
470
|
+
context.errors.push(`[E503] unexpected type "${key}" detected at ${path}`);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
if (key === 'type') {
|
|
474
|
+
if (jsonConfig[key] !== 'panel') {
|
|
475
|
+
console.log( `INTERNAL ERROR: unexpected type ${jsonConfig[key]} encounterd while scanning "panel"`);
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
if (key === 'items') {
|
|
481
|
+
for (const subkey in jsonConfig['items']) {
|
|
482
|
+
const type = jsonConfig['items'][subkey].type;
|
|
483
|
+
common.debug(` item ${subkey} / ${type}`);
|
|
484
|
+
if (!type) {
|
|
485
|
+
context.errors.push(`[E502] no type specified at ${path}`);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
checkComponent(context, `${path}/${subkey}`, jsonConfig['items'][subkey]);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function checkTabs(context, path, jsonConfig) {
|
|
495
|
+
common.debug(`${path}`);
|
|
496
|
+
|
|
497
|
+
// const validTypes = [
|
|
498
|
+
// 'panel'
|
|
499
|
+
// ];
|
|
500
|
+
|
|
501
|
+
// const validAttributes = [
|
|
502
|
+
// 'type',
|
|
503
|
+
|
|
504
|
+
// 'collapsable',
|
|
505
|
+
// 'color',
|
|
506
|
+
// 'icon',
|
|
507
|
+
// 'iconPosition',
|
|
508
|
+
// ];
|
|
509
|
+
|
|
510
|
+
for (const key in jsonConfig) {
|
|
511
|
+
common.debug(` scanning ${key}`);
|
|
512
|
+
|
|
513
|
+
const type = jsonConfig[key].type;
|
|
514
|
+
common.debug(` item ${key} / ${type}`);
|
|
515
|
+
if (!type) {
|
|
516
|
+
context.errors.push(`[E502] no type specified at ${path}; expected "panel"`);
|
|
517
|
+
}
|
|
518
|
+
if (type !== 'panel') {
|
|
519
|
+
context.errors.push(`[E503] unexpected type "${key}" detected at ${path}; expected "panel"`);
|
|
520
|
+
} else {
|
|
521
|
+
checkPanel(context, `${path}/${key}`, jsonConfig[key]);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
//main entry
|
|
527
|
+
function checkJsonConfig(context, path, jsonConfig) {
|
|
528
|
+
common.debug(`checkCode_jsonConfig({context}, ${path}, {jsonConfig}`);
|
|
529
|
+
|
|
530
|
+
const commonAttributes = [
|
|
531
|
+
'i18n',
|
|
532
|
+
'items',
|
|
533
|
+
'type',
|
|
534
|
+
];
|
|
535
|
+
|
|
536
|
+
const panelAttributes = [
|
|
537
|
+
'collapsable',
|
|
538
|
+
'color',
|
|
539
|
+
'icon',
|
|
540
|
+
'innerStyle',
|
|
541
|
+
'label',
|
|
542
|
+
];
|
|
543
|
+
|
|
544
|
+
const tabsAttributes = [
|
|
545
|
+
'iconPosition',
|
|
546
|
+
'tabsStyle',
|
|
547
|
+
];
|
|
548
|
+
|
|
549
|
+
const validTypes = [
|
|
550
|
+
'panel',
|
|
551
|
+
'tabs',
|
|
552
|
+
];
|
|
553
|
+
|
|
554
|
+
let baseType = 'panel';
|
|
555
|
+
if (!jsonConfig['type']) {
|
|
556
|
+
console.log(`*ERROR* base type (panel / tabs) not specified`);
|
|
557
|
+
} else {
|
|
558
|
+
baseType = jsonConfig['type'];
|
|
559
|
+
common.debug(` base type ${baseType}`);
|
|
560
|
+
if (!validTypes.includes(baseType)) {
|
|
561
|
+
context.errors.push(`[E500] unexpected base type "!${baseType}" detected at ${path}`);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
let validAttributes = commonAttributes;
|
|
566
|
+
if (baseType === 'panel') validAttributes = validAttributes.concat(panelAttributes);
|
|
567
|
+
if (baseType === 'tabs') validAttributes = validAttributes.concat(tabsAttributes);
|
|
568
|
+
|
|
569
|
+
for (const key in jsonConfig) {
|
|
570
|
+
common.debug(``);
|
|
571
|
+
common.debug(`scanning base attribute ${key}`);
|
|
572
|
+
if (!validAttributes.includes(key)) {
|
|
573
|
+
context.errors.push(`[E501] unexpected attribute "${key}" detected at ${path}`);
|
|
574
|
+
}
|
|
575
|
+
if (key === 'items') {
|
|
576
|
+
if (baseType == 'panel') {
|
|
577
|
+
checkPanel( context, `${path}/items`, jsonConfig, true);
|
|
578
|
+
} else if (baseType == 'tabs') {
|
|
579
|
+
checkTabs( context, `${path}/items`, jsonConfig['items'], false);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
exports.checkJsonConfig = checkJsonConfig;
|
|
588
|
+
|
|
589
|
+
// List of error and warnings used at this module
|
|
590
|
+
// ----------------------------------------------
|
|
591
|
+
|
|
592
|
+
// [500] unexpected base type "!${baseType}" detected at ${path}
|
|
593
|
+
// [501] unexpected attribute "${key}" detected at ${path}
|
|
594
|
+
// [502] no type specified at ${path}
|
|
595
|
+
// [503] unexpected type "${key}" detected at ${path}
|
|
596
|
+
// [504] unexpected component "${type}" detected at ${path}
|
|
597
|
+
// [505]
|
|
598
|
+
// [506]
|
|
599
|
+
// [507] responsive check: missing size attributes [${missing.join(',')}] at ${path}
|
|
600
|
+
// [508] responsive check: attribute "xs" should specify a value of "12" at ${path}
|
|
601
|
+
// [509] responsive check: "sm" value (${jsonConfig.sm}) greater then value for smaller displays
|
|
602
|
+
// [510] responsive check: maximum issues reached, please fix reported ones and recheck
|
|
603
|
+
|
package/lib/M700_License.js
CHANGED
|
@@ -27,10 +27,10 @@ async function checkLicenseFile(context) {
|
|
|
27
27
|
try {
|
|
28
28
|
data = await common.downloadFile(context.githubUrl, '/LICENSE');
|
|
29
29
|
} catch (e) {
|
|
30
|
-
if (e.status
|
|
30
|
+
if (e.status == 404) {
|
|
31
31
|
context.errors.push('[E700] File LICENSE not found. Please add.');
|
|
32
|
-
} else{
|
|
33
|
-
context.errors.push(
|
|
32
|
+
} else {
|
|
33
|
+
context.errors.push(`[E702] Cannot read LICENSE file. Please check. (Status ${e.status})`);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
if (data) {
|
|
@@ -61,7 +61,7 @@ async function checkLicenseFile(context) {
|
|
|
61
61
|
}
|
|
62
62
|
m = text.match(/(\d\d\d\d)/);
|
|
63
63
|
if (m) {
|
|
64
|
-
if (Number(m[1])>licenseYear) {
|
|
64
|
+
if (Number(m[1]) > licenseYear) {
|
|
65
65
|
licenseYear = Number(m[1]);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -71,7 +71,7 @@ async function checkLicenseFile(context) {
|
|
|
71
71
|
console.log(`Commit year ${commitYear}`);
|
|
72
72
|
console.log(`NPM year ${npmYear}`);
|
|
73
73
|
|
|
74
|
-
const valid = (licenseYear === year || licenseYear >= commitYear || licenseYear >=npmYear);
|
|
74
|
+
const valid = (licenseYear === year || licenseYear >= commitYear || licenseYear >= npmYear);
|
|
75
75
|
if (!valid) {
|
|
76
76
|
const m = text.match(/(\d\d\d\d)-\d\d\d\d/);
|
|
77
77
|
if (m) {
|