@iobroker/repochecker 3.4.4 → 3.5.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 CHANGED
@@ -33,6 +33,20 @@ npx @iobroker/repochecker https://github.com/ioBroker/ioBroker.javascript --loca
33
33
  -->
34
34
 
35
35
  ## Changelog
36
+ ### 3.5.0 (2025-02-18)
37
+
38
+ - (mcm1957) Fixed dependency warning ([W174]) has been reduces to suggestion. [#374]
39
+ - (mcm1957) Some changes to jsonConfig check have been implemented.
40
+ - (mcm1957) common.supportCustoms check has been added. [#379]
41
+ - (mcm1957) Check that key listed at encryptedNative or protectedNative is listed at native too. [#218]
42
+ - (mcm1957) Check that key listed at encryptedNative is listed at protectedNative too. [#342]
43
+ - (mcm1957) Check that extension adapters require web adapter. [#311]
44
+ - (mcm1957) List of suspicious keys to protect has been extended. [#358]
45
+ - (mcm1957) checking of 'admin' globalDependency has been added.
46
+ - (mcm1957) checking of 'publishConfig.registry' has been added.
47
+ - (mcm1957) New commandline option --noinfo added.
48
+ - (mcm1957) Logging has been adapted.
49
+
36
50
  ### 3.4.4 (2025-02-12)
37
51
 
38
52
  - (mcm1957) Some external attributes added to valid package.json attributes.
package/index.js CHANGED
@@ -71,7 +71,8 @@ axios.defaults.headers = {
71
71
 
72
72
  function getGithubApiData(context) {
73
73
  return new Promise((resolve, reject) => {
74
- console.log('\ngetGithubApiData');
74
+ common.debug('getGithubApiData');
75
+ common.debug(`reading url '${context.githubUrlApi}'`);
75
76
  axios
76
77
  .get(context.githubUrlApi, { cache: false })
77
78
  .then(response => {
@@ -80,13 +81,13 @@ function getGithubApiData(context) {
80
81
 
81
82
  if (!context.branch) {
82
83
  context.branch = context.githubApiData.default_branch; // main vs. master
83
- console.log(`Branch was not defined by user - checking branch: ${context.branch}`);
84
+ common.debug(`Branch was not defined by user - checking branch: ${context.branch}`);
84
85
  }
85
86
 
86
87
  context.githubUrl = `${context.githubUrlOriginal.replace('https://github.com', 'https://raw.githubusercontent.com')}/${context.branch}`;
87
- console.log(`Original URL: ${context.githubUrlOriginal}`);
88
- console.log(`raw: ${context.githubUrl}`);
89
- console.log(`api: ${context.githubUrlApi}`);
88
+ common.debug(`Original URL: ${context.githubUrlOriginal}`);
89
+ common.debug(`raw: ${context.githubUrl}`);
90
+ common.debug(`api: ${context.githubUrlApi}`);
90
91
 
91
92
  resolve(context);
92
93
  })
@@ -110,10 +111,16 @@ function makeResponse(code, data) {
110
111
 
111
112
  function check(request, ctx, callback) {
112
113
  // console.log('PROCESS: ' + JSON.stringify(request));
114
+ console.log('');
115
+
113
116
  if (!request.queryStringParameters.url) {
114
117
  return callback(null, makeResponse(500, { error: 'No github URL provided' }));
115
118
  }
116
- const context = { checks: [], errors: [], warnings: [] };
119
+ const context = {};
120
+ context.checks = [];
121
+ context.warnings = [];
122
+ context.errors = [];
123
+
117
124
  let githubUrl = request.queryStringParameters.url;
118
125
  const githubBranch = request.queryStringParameters.branch;
119
126
 
@@ -174,7 +181,6 @@ function check(request, ctx, callback) {
174
181
  result: 'Errors found',
175
182
  checks: context.checks,
176
183
  errors: context.errors,
177
- issues,
178
184
  warnings: context.warnings,
179
185
  version,
180
186
  hasTravis: context.hasTravis,
@@ -217,6 +223,13 @@ if (typeof module !== 'undefined' && module.parent) {
217
223
  common.setLocal(true);
218
224
  }
219
225
 
226
+ if (process.argv.includes('--noinfo')) {
227
+ process.argv.splice(process.argv.indexOf('--noinfo'), 1);
228
+ common.setInfo(common.isDebug() ? true : false);
229
+ } else {
230
+ common.setInfo(true);
231
+ }
232
+
220
233
  // Get url from parameters if possible
221
234
  if (process.argv.length > 2) {
222
235
  repoUrl = process.argv[2];
@@ -225,7 +238,7 @@ if (typeof module !== 'undefined' && module.parent) {
225
238
  repoUrl = `https://github.com/${repoUrl}`;
226
239
  }
227
240
  } else {
228
- console.log('ERROR: No repository specified');
241
+ common.error('No repository specified');
229
242
  process.exit(1);
230
243
  }
231
244
 
@@ -234,7 +247,7 @@ if (typeof module !== 'undefined' && module.parent) {
234
247
  repoBranch = process.argv[3];
235
248
  }
236
249
 
237
- console.log(`Checking repository ${repoUrl} (branch ${repoBranch})`);
250
+ common.info(`Checking repository ${repoUrl} (branch ${repoBranch})`);
238
251
  check(
239
252
  {
240
253
  queryStringParameters: {
@@ -245,13 +258,15 @@ if (typeof module !== 'undefined' && module.parent) {
245
258
  null,
246
259
  (err, data) => {
247
260
  const context = JSON.parse(data.body);
248
- console.log(context.result);
261
+ console.log(`\nFINAL status '${context.result}'`);
249
262
 
250
- console.log('\n\n########## SUMMARY ##########\n');
251
- if (context.checks.length) {
252
- context.checks.forEach(msg => {
253
- console.log(msg);
254
- });
263
+ if (common.isInfo()) {
264
+ console.log('\n\n########## SUMMARY ##########\n');
265
+ if (context.checks.length) {
266
+ context.checks.forEach(msg => {
267
+ console.log(msg);
268
+ });
269
+ }
255
270
  }
256
271
 
257
272
  console.log('\n\n########## SUMMARY of ISSUES ##########');
@@ -205,7 +205,7 @@ const validObjectsPackageJson = [
205
205
  'peerDependenciesMeta',
206
206
  // 'private',
207
207
  'publishConfig',
208
- 'readmeFilename', // undocumented
208
+ 'readmeFilename', // undocumented
209
209
  'repository',
210
210
  'scripts',
211
211
  'snyc', // inofficial - extension for snyc package
@@ -216,7 +216,7 @@ const validObjectsPackageJson = [
216
216
  ];
217
217
 
218
218
  async function getPackageJson(context) {
219
- console.log('\ngetPackageJson');
219
+ console.log('[init] getting package.json');
220
220
 
221
221
  const packageJson = await common.downloadFile(context.githubUrl, '/package.json');
222
222
  context.packageJson = packageJson;
@@ -231,7 +231,7 @@ async function getPackageJson(context) {
231
231
  }
232
232
 
233
233
  async function checkPackageJson(context) {
234
- console.log('\ncheckPackageJson [E001 - E099]');
234
+ console.log('\n[E001 - E099] checking package.json');
235
235
 
236
236
  let passed;
237
237
 
@@ -305,15 +305,15 @@ async function checkPackageJson(context) {
305
305
  }
306
306
 
307
307
  for (const blacklist in blacklistPackageJson) {
308
- // console.log(`checking blacklist ${blacklist}`);
308
+ common.debug(`checking blacklist ${blacklist}`);
309
309
  let tmp = context.packageJson;
310
310
  let log = '';
311
311
  for (const element of blacklist.split('.')) {
312
312
  log = `${log}.${element}`;
313
- //console.log(` check ${log}`);
313
+ //common.debug(` check ${log}`);
314
314
  tmp = tmp[element];
315
315
  if (!tmp) {
316
- //console.log(` ${log} does not exist`);
316
+ //common.debug(` ${log} does not exist`);
317
317
  break;
318
318
  }
319
319
  }
@@ -438,6 +438,26 @@ async function checkPackageJson(context) {
438
438
  context.checks.push('maintainers not found in package.json');
439
439
  }
440
440
 
441
+ if (context.packageJson.publishConfig) {
442
+ context.warnings.push(
443
+ '[S052] "publishConfig" attribute at package.json is not required in modest cases. Please check and eventually remove.',
444
+ );
445
+ if (
446
+ context.packageJson.publishConfig.registry &&
447
+ context.packageJson.publishConfig.registry !== 'https://registry.npmjs.org'
448
+ ) {
449
+ context.errors.push(
450
+ '[E053] "publishConfig.registry" mut point to "https://registry.npmjs.org" at package.json.',
451
+ );
452
+ } else {
453
+ context.checks.push(
454
+ 'publishConfig.registry exists at package.json and points to "https://registry.npmjs.org"',
455
+ );
456
+ }
457
+ } else {
458
+ context.checks.push('publishConfig not found in package.json');
459
+ }
460
+
441
461
  if (context.cfg.reservedAdapterNames.includes(adapterName)) {
442
462
  context.errors.push('[E022] Adapter name is reserved. Please rename adapter.');
443
463
  } else {
@@ -469,7 +489,7 @@ async function checkPackageJson(context) {
469
489
  } else {
470
490
  context.warnings.push(`[W050] ${blacklistedDependenciesPackageJson[blacklist].msg}`);
471
491
  }
472
- passed = false;
492
+ passed = false;
473
493
  }
474
494
  }
475
495
  }
@@ -646,7 +666,7 @@ async function checkPackageJson(context) {
646
666
 
647
667
  // check dependcy requirements
648
668
  for (const dependency in dependenciesPackageJson) {
649
- console.log(`checking dependency ${dependency} ...`);
669
+ common.debug(`checking dependency ${dependency} ...`);
650
670
 
651
671
  if (dependenciesPackageJson[dependency].onlyWWW === false && context.cfg.onlyWWW) {
652
672
  continue;
@@ -661,7 +681,7 @@ async function checkPackageJson(context) {
661
681
  let dependencyVersion = context.packageJson.dependencies[`${dependency}`] || '';
662
682
  dependencyVersion = dependencyVersion.replace(/[\^~]/, '').trim();
663
683
 
664
- console.log(` exists: ${exists}, optional: ${optional}, alternatives: [${alternatives}]`);
684
+ common.debug(` exists: ${exists}, optional: ${optional}, alternatives: [${alternatives}]`);
665
685
 
666
686
  if (exists) {
667
687
  // if dependency exists, version requirements must be met
@@ -679,8 +699,8 @@ async function checkPackageJson(context) {
679
699
  } else {
680
700
  // if dependency does not exist check if alternate exists
681
701
  let found = '';
682
- for (const alternative of alternatives){
683
- if (context.packageJson.dependencies[`${alternative}`]){
702
+ for (const alternative of alternatives) {
703
+ if (context.packageJson.dependencies[`${alternative}`]) {
684
704
  found = alternative;
685
705
  }
686
706
  }
@@ -702,7 +722,7 @@ async function checkPackageJson(context) {
702
722
 
703
723
  // check devDependcy requirements
704
724
  for (const dependency in devDependenciesPackageJson) {
705
- console.log(`checking devDependency ${dependency} ...`);
725
+ common.debug(`checking devDependency ${dependency} ...`);
706
726
 
707
727
  if (devDependenciesPackageJson[dependency].onlyWWW === false && context.cfg.onlyWWW) {
708
728
  continue;
@@ -717,7 +737,7 @@ async function checkPackageJson(context) {
717
737
  let dependencyVersion = context.packageJson.devDependencies[`${dependency}`] || '';
718
738
  dependencyVersion = dependencyVersion.replace(/[\^~]/, '');
719
739
 
720
- console.log(` exists: ${exists}, optional: ${optional}, alternatives: [${alternatives}]`);
740
+ common.debug(` exists: ${exists}, optional: ${optional}, alternatives: [${alternatives}]`);
721
741
 
722
742
  if (exists) {
723
743
  // if dependency exists, version requirements must be met
@@ -735,8 +755,8 @@ async function checkPackageJson(context) {
735
755
  } else {
736
756
  // if dependency does not existscheck if alternate exists
737
757
  let found = '';
738
- for (const alternative of alternatives){
739
- if (context.packageJson.devDependencies[`${alternative}`]){
758
+ for (const alternative of alternatives) {
759
+ if (context.packageJson.devDependencies[`${alternative}`]) {
740
760
  found = alternative;
741
761
  }
742
762
  }
@@ -791,7 +811,7 @@ async function checkPackageJson(context) {
791
811
  );
792
812
  } else {
793
813
  context.warnings.push(
794
- `[W047] dependency should not require a specific version. Use "~1.2.3" or "^1.2.3" syntax. Please update "${dependency}:${context.packageJson.dependencies[dependency]}"`,
814
+ `[S047] dependency should not require a specific version. Use "~1.2.3" or "^1.2.3" syntax. Please update "${dependency}:${context.packageJson.dependencies[dependency]}"`,
795
815
  );
796
816
  }
797
817
  }
@@ -3,7 +3,7 @@
3
3
  This module is a support module for iobroker.repochecker
4
4
 
5
5
  Area checked: io-package.json
6
- Numbering : 100 - 199, 250 - 249
6
+ Numbering : 100 - 199, 200 - 249
7
7
 
8
8
  */
9
9
 
@@ -13,7 +13,7 @@ const sizeOf = require('image-size');
13
13
  const common = require('./common.js');
14
14
 
15
15
  async function getIOPackageJson(context) {
16
- console.log('\ngetIOPackageJson');
16
+ console.log('[init] getting io-package.json');
17
17
 
18
18
  const ioPackageJson = await common.downloadFile(context.githubUrl, '/io-package.json');
19
19
  context.ioPackageJson = ioPackageJson;
@@ -30,6 +30,9 @@ async function getIOPackageJson(context) {
30
30
  const recommendedJsControllerVersion = '5.0.19';
31
31
  let requiredJsControllerVersion = '5.0.19';
32
32
 
33
+ const recommendedAdminVersion = '7.4.10';
34
+ let requiredAdminVersion = '6.0.0'; // set to 6.17.14 if jsonConfig is used
35
+
33
36
  const blacklistIOPackageJson = {
34
37
  $schema: {
35
38
  msg: 'Please remove "$schema" from io-package.json. You may set schema at your IDE to add edit-support.',
@@ -94,7 +97,7 @@ const blacklistIOPackageJson = {
94
97
  };
95
98
 
96
99
  async function checkIOPackageJson(context) {
97
- console.log('\ncheckIOPackage [E100 - E249]');
100
+ console.log('\n[E100 - E249] checking io-package.json');
98
101
 
99
102
  if (!context.ioPackageJson.native) {
100
103
  context.errors.push('[E101] io-package.json must have at least empty "native" attribute');
@@ -103,29 +106,29 @@ async function checkIOPackageJson(context) {
103
106
 
104
107
  // Generic check for potential credentials that should have a counterpart in encryptedNative/protectedNative
105
108
  const suspiciousPhrases = [
106
- 'apikey',
107
- 'api_key',
108
- 'credential',
109
- 'mypassword',
110
- 'pass',
111
- 'passwd',
112
- 'password',
113
- 'passwort',
114
- 'pin',
115
- 'private_pw',
116
- 'psk',
117
- 'pwd',
118
- 'secret',
119
- 'token',
109
+ '^.*api.?key$',
110
+ '^.*credential$',
111
+ '^pass$',
112
+ '^.*passwd$',
113
+ '^.*password$',
114
+ '^.*passwort$',
115
+ '^.*pin$',
116
+ '^private.*',
117
+ '^private_pw$',
118
+ '^psk$',
119
+ '^pwd$',
120
+ '^.*secret$',
121
+ '^.*token$',
120
122
  ];
121
- //const regex = new RegExp(suspiciousPhrases.join('|'), 'i');
122
123
 
123
- let suspiciousKeys = Object.keys(context.ioPackageJson.native) || [];
124
- // console.log(`native keys: ${suspiciousKeys.join()}`);
125
- //suspiciousKeys = suspiciousKeys.filter( key => regex.test(key));
126
- suspiciousKeys = suspiciousKeys.filter(key => suspiciousPhrases.includes(key.toLowerCase()));
127
- // console.log(`suspicious keys: ${suspiciousKeys.join()}`);
124
+ // let suspiciousKeys = Object.keys(context.ioPackageJson.native) || [];
125
+ // suspiciousKeys = suspiciousKeys.filter(key => suspiciousPhrases.includes(key.toLowerCase()));
126
+
127
+ const regex = new RegExp(suspiciousPhrases.join('|'), 'i');
128
+ const nativeKeys = Object.keys(context.ioPackageJson.native) || [];
128
129
 
130
+ const suspiciousKeys = nativeKeys.filter(key => regex.test(key.toLowerCase()));
131
+ common.debug(`Suspicious key test: native: ${nativeKeys} - suspiciousKeys: ${suspiciousKeys}`);
129
132
  if (suspiciousKeys.length) {
130
133
  if (context.ioPackageJson.protectedNative) {
131
134
  const missingProtected = suspiciousKeys.filter(
@@ -157,6 +160,35 @@ async function checkIOPackageJson(context) {
157
160
  );
158
161
  }
159
162
  }
163
+
164
+ for (const key of context.ioPackageJson.encryptedNative || []) {
165
+ if (!context.ioPackageJson.protectedNative.includes(key)) {
166
+ context.warnings.push(
167
+ `[W193] Encrypted native "${key}" should be listed at "protectedNative" in io-package.json`,
168
+ );
169
+ }
170
+ }
171
+
172
+ for (const key of context.ioPackageJson.protectedNative || []) {
173
+ if (!context.ioPackageJson.encryptedNative.includes(key)) {
174
+ context.warnings.push(
175
+ `[S194] Consider adding protected native "${key}" to "encryptedNative" in io-package.json`,
176
+ );
177
+ }
178
+ }
179
+
180
+ for (const key of [
181
+ ...new Set([
182
+ ...(context.ioPackageJson.protectedNative || []),
183
+ ...(context.ioPackageJson.encryptedNative || []),
184
+ ]),
185
+ ]) {
186
+ if (context.ioPackageJson.native[key] === undefined){
187
+ context.warnings.push(
188
+ `[W195] Protected or encrypted element "${key}" should be listed at "native" in io-package.json`,
189
+ );
190
+ }
191
+ }
160
192
  }
161
193
 
162
194
  if (!context.ioPackageJson.common) {
@@ -164,6 +196,7 @@ async function checkIOPackageJson(context) {
164
196
  return context;
165
197
  }
166
198
  context.checks.push('"common" found in io-package.json');
199
+
167
200
  if (!context.ioPackageJson.common.name || context.ioPackageJson.common.name !== context.adapterName.toLowerCase()) {
168
201
  context.errors.push(
169
202
  `[E103] "common.name" in io-package.json must be equal to "${context.adapterName.toLowerCase()}'". Now is ${context.ioPackageJson.common.name}`,
@@ -172,15 +205,6 @@ async function checkIOPackageJson(context) {
172
205
  context.checks.push('"common.name" is valid in io-package.json');
173
206
  }
174
207
 
175
- // /*
176
- // if (context.ioPackageJson.common.title) {
177
- // context.warnings.push('[W158] "common.title" is deprecated in io-package.json. Please remove from io-package.json.');
178
- // }
179
-
180
- // if (context.ioPackageJson.common.main) {
181
- // context.warnings.push('[W177] "common.main" is deprecated in io-package.json. For js-controller >= 3.3 please use package.json main and remove "common.main" from io-package.json.');
182
- // }
183
-
184
208
  if (context.ioPackageJson.common.materialize) {
185
209
  if (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config) {
186
210
  context.warnings.push(
@@ -191,6 +215,8 @@ async function checkIOPackageJson(context) {
191
215
  '[W178] "common.materialize" is deprecated for admin >= 5 at io-package.json. Please use property "common.adminUI.config".',
192
216
  );
193
217
  }
218
+ } else {
219
+ context.checks.push('"common.materialize" does not exist in io-package.json');
194
220
  }
195
221
 
196
222
  if (context.ioPackageJson.common.materializeTab) {
@@ -203,12 +229,10 @@ async function checkIOPackageJson(context) {
203
229
  '[W179] "common.materializeTab" is deprecated for admin >= 5 at io-package.json. Please use property "common.adminUI.tab".',
204
230
  );
205
231
  }
232
+ } else {
233
+ context.checks.push('"common.materializeTab" does not exist in io-package.json');
206
234
  }
207
235
 
208
- // if (context.ioPackageJson.common.noConfig) {
209
- // context.warnings.push('[W180] "common.noConfig" is deprecated in io-package.json. For admin version >= 5 please use "common.adminUI.config":"none".');
210
- // }
211
- // */
212
236
  if (!context.ioPackageJson.common.titleLang) {
213
237
  context.errors.push('[E104] No "common.titleLang" found in io-package.json');
214
238
  } else {
@@ -271,6 +295,8 @@ async function checkIOPackageJson(context) {
271
295
  }
272
296
  }
273
297
 
298
+ // TODO - check format of version to be xx.xx.xx[-text.nn]
299
+
274
300
  if (!context.ioPackageJson.common.desc) {
275
301
  context.errors.push('[E108] No "common.desc" found in io-package.json');
276
302
  } else {
@@ -299,6 +325,8 @@ async function checkIOPackageJson(context) {
299
325
  }
300
326
  }
301
327
 
328
+ // TODO - report unknown languages
329
+
302
330
  if (!context.ioPackageJson.common.keywords) {
303
331
  context.errors.push(
304
332
  '[E169] "common.keywords" must be an array within io-package.json and contain some useful keywords',
@@ -366,6 +394,8 @@ async function checkIOPackageJson(context) {
366
394
  context.checks.push('"common.compact" found in io-package.json');
367
395
  }
368
396
 
397
+ // TODO compact ignored for onlyWW and so it cpould be suggested to be removed
398
+
369
399
  if (
370
400
  context.ioPackageJson.common.noConfig &&
371
401
  context.ioPackageJson.common.adminUI &&
@@ -465,6 +495,13 @@ async function checkIOPackageJson(context) {
465
495
  '[E167] scheduled adapters must have "common.schedule" property in io-package.json',
466
496
  );
467
497
  }
498
+
499
+ if (
500
+ context.ioPackageJson.common.mode === 'extension' &&
501
+ !context.ioPackageJson.common.dependencies.find(dep => Object.keys(dep).find(attr => attr === 'web'))
502
+ ) {
503
+ context.errors.push('[E192] extension adapters must list web adapter as dependency in io-package.json');
504
+ }
468
505
  }
469
506
  }
470
507
 
@@ -578,10 +615,6 @@ async function checkIOPackageJson(context) {
578
615
  }
579
616
  }
580
617
 
581
- //if (context.ioPackageJson.common.installedFrom) {
582
- // context.errors.push('[E144] common.installedFrom field found in io-package.json. Must be removed.');
583
- //}
584
-
585
618
  if (context.ioPackageJson.instanceObjects) {
586
619
  const instanceObjects = context.ioPackageJson.instanceObjects;
587
620
  if (!(instanceObjects instanceof Array)) {
@@ -650,8 +683,18 @@ async function checkIOPackageJson(context) {
650
683
  );
651
684
  }
652
685
 
653
- let currentJsControllerVersion = undefined;
686
+ if (context.ioPackageJson.common.supportsCustoms) {
687
+ if (!context.ioPackageJson.common.adminUI?.custom && context.ioPackageJson.common.adminUI?.custom !== 'json') {
688
+ context.errors.push(`[E196] "common.supportCustoms" requires "common.adminUI.custom" to be defined`);
689
+ } else {
690
+ context.checks.push('"support.customs" is set and "adminUI.custom" requires "json"');
691
+ }
692
+ } else {
693
+ context.checks.push('"support.customs" is not set');
694
+ }
654
695
 
696
+ // check js-controller dependency
697
+ let currentJsControllerVersion = undefined;
655
698
  if (context.ioPackageJson.common.dependencies) {
656
699
  if (!(context.ioPackageJson.common.dependencies instanceof Array)) {
657
700
  context.errors.push(`[E185] "common.dependencies" must be an array at io-package.json`);
@@ -667,11 +710,11 @@ async function checkIOPackageJson(context) {
667
710
  Object.keys(dep).find(attr => attr === 'js-controller'),
668
711
  );
669
712
  if (jsControllerDependency) {
670
- console.log(`Found current js-controller dependency "${jsControllerDependency['js-controller']}"`);
713
+ common.debug(`Found current js-controller dependency "${jsControllerDependency['js-controller']}"`);
671
714
 
672
715
  if (!jsControllerDependency['js-controller'].startsWith('>=')) {
673
716
  context.errors.push(
674
- `[E159] common.dependencies "js-controller" dependency should always allow future versions (>=x.x.x) - recommended: {"js-controller": ">=${recommendedJsControllerVersion}"}`,
717
+ `[E159] common.dependencies "js-controller" dependency should always allow future versions (>=x.x.x) - recommended: {"js-controller": ">=${recommendedJsControllerVersion}"}.`,
675
718
  );
676
719
  } else {
677
720
  currentJsControllerVersion = jsControllerDependency['js-controller'].replace(/[^\d.]/g, '');
@@ -705,9 +748,9 @@ async function checkIOPackageJson(context) {
705
748
  }
706
749
  }
707
750
 
708
- /*
709
- increase dependency as required by addition features
710
- */
751
+ //
752
+ // increase dependency as required by addition features
753
+ //
711
754
  if (context.ioPackageJson && context.ioPackageJson.common && context.ioPackageJson.common.supportedMessges) {
712
755
  requiredJsControllerVersion = common.maxVersion(requiredJsControllerVersion, '5.0.18');
713
756
  }
@@ -737,16 +780,97 @@ async function checkIOPackageJson(context) {
737
780
  );
738
781
  }
739
782
 
740
- if (context.ioPackageJson.common.globalDependencies) {
741
- const dependencyArray = common.getDependencyArray(context.ioPackageJson.common.globalDependencies);
783
+ // check admin dependency
784
+ let requireAdmin =
785
+ context.ioPackageJson.common.materialize ||
786
+ context.ioPackageJson.common.materializeTab ||
787
+ (context.ioPackageJson.common.adminUI?.config && context.ioPackageJson.common.adminUI?.config !== 'none') ||
788
+ (context.ioPackageJson.common.adminUI?.custom && context.ioPackageJson.common.adminUI?.custom !== 'none') ||
789
+ (context.ioPackageJson.common.adminUI?.tab && context.ioPackageJson.common.adminUI?.tab !== 'none');
790
+ common.debug(`admin dependency is ${requireAdmin ? '' : 'not'}required`);
791
+
792
+ if (context.cfg.hasJsonConfig) {
793
+ requiredAdminVersion = common.maxVersion(requiredAdminVersion, '6.17.14');
794
+ }
742
795
 
796
+ let currentAdminVersion = undefined;
797
+ if (context.ioPackageJson.common.globalDependencies) {
743
798
  if (!(context.ioPackageJson.common.globalDependencies instanceof Array)) {
744
799
  context.errors.push(`[E186] "common.globalDependencies" must be an array at io-package.json`);
745
800
  } else {
801
+ const dependencyArray = common.getDependencyArray(context.ioPackageJson.common.globalDependencies);
802
+
746
803
  // js-controller is not allowed in global dependencies (dependencies only)
747
804
  if (dependencyArray.includes('js-controller')) {
748
805
  context.errors.push(`[E161] "js-controller" is not allowed in common.globalDependencies`);
749
806
  }
807
+
808
+ const adminDependency = context.ioPackageJson.common.globalDependencies.find(dep =>
809
+ Object.keys(dep).find(attr => attr === 'admin'),
810
+ );
811
+ if (adminDependency) {
812
+ common.debug(`Found current admin dependency "${adminDependency['js-controller']}"`);
813
+
814
+ if (!adminDependency['admin'].startsWith('>=')) {
815
+ context.errors.push(
816
+ `[E189] common.dependencies "admin" dependency should always allow future versions (>=x.x.x) - recommended: {"admin": ">=${recommendedAdminVersion}"}.`,
817
+ );
818
+ } else {
819
+ currentAdminVersion = adminDependency['admin'].replace(/[^\d.]/g, '');
820
+ }
821
+ if (!requireAdmin) {
822
+ context.errors.push(
823
+ `[S191] admin dependency (${adminDependency['admin']}) at io-package.json is not required. Feel free to remove.`,
824
+ );
825
+ }
826
+ } else {
827
+ if (requireAdmin) {
828
+ if (requiredAdminVersion !== recommendedAdminVersion) {
829
+ context.errors.push(
830
+ `[E190] admin dependency missing. admin ${requiredAdminVersion} is required as minimum, ${recommendedAdminVersion} is recommended. Please add to globalDependencies at io-package.json.`,
831
+ );
832
+ } else {
833
+ context.errors.push(
834
+ `[E190] admin dependency missing. admin ${requiredAdminVersion} is required as minimum. Please add to globalDependencies at io-package.json.`,
835
+ );
836
+ }
837
+ }
838
+ }
839
+ }
840
+ } else {
841
+ if (requireAdmin) {
842
+ context.errors.push(`[E186] "common.globalDependencies" must be an array at io-package.json`);
843
+ if (requiredAdminVersion !== recommendedAdminVersion) {
844
+ context.errors.push(
845
+ `[E190] admin dependency missing. admin ${requiredAdminVersion} is required as minimum, ${recommendedAdminVersion} is recommended. Please add to dependencies at io-package.json.`,
846
+ );
847
+ } else {
848
+ context.errors.push(
849
+ `[E190] admin dependency missing. admin ${requiredAdminVersion} is required as minimum. Please add to dependencies at io-package.json.`,
850
+ );
851
+ }
852
+ }
853
+ }
854
+
855
+ if (currentAdminVersion && compareVersions.compare(requiredAdminVersion, currentAdminVersion, '>')) {
856
+ if (requiredAdminVersion !== recommendedAdminVersion) {
857
+ context.errors.push(
858
+ `[E157] admin ${currentAdminVersion} listed as dependency but ${requiredAdminVersion} is required as minimum, ${recommendedAdminVersion} is recommended. Please update globalDependency at io-package.json.`,
859
+ );
860
+ } else {
861
+ context.errors.push(
862
+ `[E157] admin ${currentAdminVersion} listed as dependency but ${requiredAdminVersion} is required as minimum. Please update globalDependency at io-package.json.`,
863
+ );
864
+ }
865
+ } else if (currentAdminVersion && compareVersions.compare(recommendedAdminVersion, currentAdminVersion, '>')) {
866
+ context.warnings.push(
867
+ `[W156] admin ${currentAdminVersion} listed as dependency but ${recommendedAdminVersion} is recommended. Please consider updating globalDependency at io-package.json.`,
868
+ );
869
+ } else {
870
+ if (requireAdmin) {
871
+ context.checks.push('"admin" dependendy satisfied');
872
+ } else {
873
+ context.checks.push('"admin" dependendy not required');
750
874
  }
751
875
  }
752
876
 
@@ -843,15 +967,23 @@ async function checkIOPackageJson(context) {
843
967
  }
844
968
  context.checks.push('"extIcon" could be downloaded');
845
969
 
970
+ // @ts-expect-error sizeOf does not have typing
846
971
  const image = sizeOf(icon);
972
+ common.debug(`logo ${context.ioPackageJson.common.icon} width: ${image.width}, height: ${image.height}`);
847
973
  if (image.width !== image.height) {
848
- context.errors.push('[E140] width and height of logo are not equal');
974
+ context.errors.push('[E140] width and height of logo (specified at "common.extIcon") are not equal');
849
975
  } else {
850
- context.checks.push('Width and height of logo are equal');
976
+ context.checks.push('width and height of "extIcon" logo are equal');
851
977
  if (image.width < 32) {
852
- context.errors.push('[E141] logo is too small. It must be greater or equal than 32x32');
978
+ context.errors.push(
979
+ '[E141] logo (specified at "common.extIcon") is too small. It must be greater or equal than 32x32',
980
+ );
853
981
  } else if (image.width > 512) {
854
- context.errors.push('[E142] logo is too big. It must be less or equal than 512x512');
982
+ context.errors.push(
983
+ '[E142] logo (specified at "common.extIcon") is too big. It must be less or equal than 512x512',
984
+ );
985
+ } else {
986
+ context.checks.push('"extIcon" logo is of correct size');
855
987
  }
856
988
  }
857
989
  } catch (e) {
@@ -983,4 +1115,12 @@ exports.checkIOPackageJson = checkIOPackageJson;
983
1115
  // [185] "common.dependencies" must be an array at io-package.json
984
1116
  // [186] "common.globalDependencies" must be an array at io-package.json
985
1117
  // [187] "common.materialize" replaced by property "common.adminUI.config" at io-package.json. Please remove.
986
- // [188] "common.materializeTab" replaced by property "common.adminUI.tab" at io-package.json. Please remove.
1118
+ // [188] "common.materializeTab" replaced by property "common.adminUI.tab" at io-package.json. Please remove.
1119
+ // [189] common.dependencies "admin" dependency should always allow future versions (>=x.x.x) - recommended: {"admin": ">=${recommendedAdminVersion}".
1120
+ // [190] admin dependency missing. admin ${requiredAdminVersion} is required as minimum, ${recommendedAdminVersion} is recommended. Please add to dependencies at io-package.json.
1121
+ // [191] admin dependency (${adminDependency['admin']}) at io-package.json is not required. Feel free to remove.
1122
+ // [192] extension adapters must list web adapter as dependency in io-package.json
1123
+ // [193] Encrypted native "${encrypted}" not listed at "protectedNative" in io-package.json
1124
+ // [194] Protected native "${protected}" not listed at "encryptedNative" in io-package.json
1125
+ // [195] Protected or encrypted element "${protected}" not listed as "native" in io-package.json
1126
+ // [196] "common.supportCustoms" requires "common.adminUI.custom" to be defined`
package/lib/M250_Npm.js CHANGED
@@ -20,7 +20,7 @@ axios.defaults.headers = {
20
20
  // const common = require('./common.js');
21
21
 
22
22
  async function checkNpm(context) {
23
- console.log('\ncheckNpm [E250 - 299]');
23
+ console.log('\n[E250 - E299] checkNpm');
24
24
  let body;
25
25
  try {
26
26
  const response = await axios(`https://registry.npmjs.org/iobroker.${context.adapterName}`);
@@ -10,7 +10,7 @@
10
10
  // const common = require('./common.js');
11
11
 
12
12
  async function checkTests(context) {
13
- console.log('\ncheckTests [E300 - E399]');
13
+ console.log('\n[E300 - E399] checkTests');
14
14
  // if found some file in `\.github\workflows` with the test inside => it is OK too
15
15
  if (
16
16
  context &&
@@ -20,7 +20,7 @@ axios.defaults.headers = {
20
20
  const common = require('./common.js');
21
21
 
22
22
  async function checkRepository(context) {
23
- console.log('\ncheckRepository [E400 - E499]');
23
+ console.log('\n[E400 - E499] checkRepository');
24
24
 
25
25
  if (context.ioPackageJson && context.ioPackageJson.common && context.ioPackageJson.common.type) {
26
26
  /* TODO: why check type here ? */
@@ -230,7 +230,7 @@ async function checkRepository(context) {
230
230
  // format already checked at latest repository check
231
231
  // context.warnings.push(
232
232
  // `[W434] Dependency '${dependency}':'${dependencies[dependency]}' should specify '>='`,
233
- // );
233
+ // );
234
234
  } else {
235
235
  try {
236
236
  if (
package/lib/M500_Code.js CHANGED
@@ -98,7 +98,7 @@ function getAllFiles(context, dirPath, root, filesList) {
98
98
 
99
99
  // E5xx
100
100
  async function checkCode(context) {
101
- console.log('\ncheckCode [E5xx]');
101
+ console.log('\n[E500 - E599] checkCode');
102
102
 
103
103
  const readFiles = [
104
104
  '.npmignore',
@@ -165,7 +165,7 @@ async function checkCode(context) {
165
165
  getAllFiles(context, process.cwd(), '', context.filesList);
166
166
  } else {
167
167
  const data = await common.downloadFile(context.githubUrlOriginal, `/archive/${context.branch}.zip`, true);
168
- console.log(`${context.branch}.zip ${data.length} bytes`);
168
+ common.debug(`${context.branch}.zip ${data.length} bytes`);
169
169
 
170
170
  let found = false;
171
171
  const bufferStream = new stream.PassThrough();
@@ -184,11 +184,11 @@ async function checkCode(context) {
184
184
  common.debug(`on.entry ${entry.path}`);
185
185
  if (root === '') {
186
186
  root = entry.path;
187
- console.log(`Directory root set to ${root}`);
187
+ common.debug(`Directory root set to ${root}`);
188
188
  }
189
189
  //if (!found && entry.type === 'Directory' && entry.path.match(/\/node_modules\/$/)) {
190
190
  if (!found && entry.type === 'Directory' && entry.path === `${root}node_modules/`) {
191
- console.log(`Found ${entry.path}`);
191
+ common.debug(`Found ${entry.path}`);
192
192
  found = true;
193
193
  context.errors.push(
194
194
  '[E500] Directory node_modules found in root of repository. Please delete directory.',
@@ -233,25 +233,25 @@ async function checkCode(context) {
233
233
  (context.packageJson.devDependencies['@iobroker/adapter-react-v5'] ||
234
234
  context.packageJson.devDependencies['react'])
235
235
  ) {
236
- console.log('REACT detected at package devDependencies');
236
+ common.info('REACT detected at package devDependencies');
237
237
  usesReact = true;
238
238
  }
239
239
  if (
240
240
  context.packageJson.dependencies &&
241
241
  (context.packageJson.dependencies['@iobroker/adapter-react-v5'] || context.packageJson.dependencies['react'])
242
242
  ) {
243
- console.log('REACT detected at package dependencies');
243
+ common.info('REACT detected at package dependencies');
244
244
  usesReact = true;
245
245
  }
246
246
  if (context['/src-admin/package.json']) {
247
247
  //console.log('"src-admin/package.json" exists');
248
248
  const packageJson = JSON.parse(context['/src-admin/package.json']);
249
249
  if (packageJson.devDependencies && packageJson.devDependencies['@iobroker/adapter-react-v5']) {
250
- console.log('REACT detected at src-admin/package devDependencies');
250
+ common.info('REACT detected at src-admin/package devDependencies');
251
251
  usesReact = true;
252
252
  }
253
253
  if (packageJson.dependencies && packageJson.dependencies['@iobroker/adapter-react-v5']) {
254
- console.log('REACT detected at src-admin/package dependencies');
254
+ common.info('REACT detected at src-admin/package dependencies');
255
255
  usesReact = true;
256
256
  }
257
257
  }
@@ -262,14 +262,14 @@ async function checkCode(context) {
262
262
  packageJson.devDependencies &&
263
263
  (packageJson.devDependencies['@iobroker/adapter-react-v5'] || packageJson.devDependencies['react'])
264
264
  ) {
265
- console.log('REACT detected at src-widgets/package devDependencies');
265
+ common.info('REACT detected at src-widgets/package devDependencies');
266
266
  usesReact = true;
267
267
  }
268
268
  if (
269
269
  packageJson.dependencies &&
270
270
  (packageJson.dependencies['@iobroker/adapter-react-v5'] || packageJson.dependencies['react'])
271
271
  ) {
272
- console.log('REACT detected at src-widgets/package dependencies');
272
+ common.info('REACT detected at src-widgets/package dependencies');
273
273
  usesReact = true;
274
274
  }
275
275
  }
@@ -473,13 +473,13 @@ async function checkCode(context) {
473
473
  '[E518] "@alcalzone/release-script" (>=3.0.0) is used, but ".releaseconfig.json" not found. Please create.',
474
474
  );
475
475
  } else {
476
- console.log(`context[/.releaseconfig.json: ${context['/.releaseconfig.json']}`);
476
+ common.debug(`context[/.releaseconfig.json: ${context['/.releaseconfig.json']}`);
477
477
  try {
478
478
  const releaseConfigJson = JSON.parse(context['/.releaseconfig.json']);
479
- console.log(`releaseConfigJson: ${releaseConfigJson}`);
479
+ common.debug(`releaseConfigJson: ${releaseConfigJson}`);
480
480
 
481
481
  const plugins = releaseConfigJson.plugins;
482
- console.log(`plugins: ${plugins}`);
482
+ common.debug(`plugins: ${plugins}`);
483
483
  if (!context.packageJson.devDependencies['@alcalzone/release-script-plugin-iobroker']) {
484
484
  context.errors.push(
485
485
  '[E524] "@alcalzone/release-script" requires plugin "@alcalzone/release-script-plugin-iobroker". Please add.',
@@ -147,22 +147,18 @@ function handleResponsiveWarning(context, msg) {
147
147
  function chk_responsive(context, path, jsonConfig, component, opts) {
148
148
  common.debug(`chk_responsive ${path}`);
149
149
 
150
- if (!opts || !opts.sizesOptional) {
150
+ opts = opts || {};
151
+
152
+ const sizes = ['xs', 'sm', 'md', 'lg', 'xl'];
153
+
154
+ common.debug(`json check for ${path}`);
155
+ if (!opts.sizesOptional) {
151
156
  const missing = [];
152
- if (!jsonConfig.xs) {
153
- missing.push('xs');
154
- }
155
- if (!jsonConfig.sm) {
156
- missing.push('sm');
157
- }
158
- if (!jsonConfig.md) {
159
- missing.push('md');
160
- }
161
- if (!jsonConfig.lg) {
162
- missing.push('lg');
163
- }
164
- if (!jsonConfig.xl) {
165
- missing.push('xl');
157
+ for (const size of sizes) {
158
+ common.debug(` ${size} : ${jsonConfig[size]}`);
159
+ if (!jsonConfig[size]) {
160
+ missing.push(size);
161
+ }
166
162
  }
167
163
  if (missing.length) {
168
164
  handleResponsiveError(
@@ -172,7 +168,16 @@ function chk_responsive(context, path, jsonConfig, component, opts) {
172
168
  }
173
169
  }
174
170
 
175
- if (jsonConfig.xs && jsonConfig.xs != 12) {
171
+ for (const size of sizes) {
172
+ if (jsonConfig[size] !== undefined && (jsonConfig[size] > 12 || jsonConfig[size] <= 0)) {
173
+ handleResponsiveError(
174
+ context,
175
+ `[E511] invalid size attributes "${size}":"${jsonConfig[size]}" for ${component} at ${path}. Value must be 1 to 12.`,
176
+ );
177
+ }
178
+ }
179
+
180
+ if (!opts.sizesOptional && jsonConfig.xs && jsonConfig.xs != 12) {
176
181
  handleResponsiveWarning(
177
182
  context,
178
183
  `[W508] attribute "xs" for ${component} should specify a value of "12" at ${path}`,
@@ -276,7 +281,7 @@ function check_coordinates(context, path, jsonConfig, _inTable) {
276
281
  }
277
282
 
278
283
  function check_cron(context, path, jsonConfig, _inTable) {
279
- common.debug(`check_staticText ${path}`);
284
+ common.debug(`check_cron ${path}`);
280
285
  chk_responsive(context, path, jsonConfig, 'cron');
281
286
  }
282
287
 
@@ -630,3 +635,4 @@ exports.checkJsonConfig = checkJsonConfig;
630
635
  // [508] responsive check: attribute "xs" should specify a value of "12" at ${path}
631
636
  // [509] responsive check: "sm" value (${jsonConfig.sm}) greater then value for smaller displays
632
637
  // [510] responsive check: maximum issues reached, please fix reported ones and recheck
638
+ // [511] invalid size attributes "${size}":"${jsonConfig[size]}" for ${component} at ${path}. Value must be 1 to 12.
@@ -20,7 +20,7 @@ function getAuthor(author) {
20
20
 
21
21
  async function checkReadme(context) {
22
22
  // https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/README.md
23
- console.log('\ncheckReadme [E600 - E699]');
23
+ console.log('\n[E600 - E699] checkReadme');
24
24
 
25
25
  const data = await common.downloadFile(context.githubUrl, '/README.md');
26
26
  if (!data) {
@@ -55,7 +55,7 @@ async function checkReadme(context) {
55
55
  }
56
56
  } catch (e) {
57
57
  context.warnings.push('[W606] Could not retrieve timestamp of LATEST revision at npm.');
58
- console.log(`Error executing "npm view" - ${e}`);
58
+ common.error(`executing "npm view" - ${e}`);
59
59
  }
60
60
 
61
61
  const pos = data.indexOf('## License');
@@ -78,10 +78,9 @@ async function checkReadme(context) {
78
78
  }
79
79
  }
80
80
 
81
- console.log(`README year ${readmeYear}`);
82
- console.log(`Current year ${year}`);
83
- console.log(`Commit year ${commitYear}`);
84
- console.log(`NPM year ${npmYear}`);
81
+ common.info(
82
+ `years detected: README ${readmeYear} / Current ${year} / Last commit ${commitYear} / NPM ${npmYear}`,
83
+ );
85
84
 
86
85
  const valid = readmeYear === year || readmeYear >= commitYear || readmeYear >= npmYear;
87
86
  if (readmeYear > year) {
@@ -20,7 +20,7 @@ function getAuthor(author) {
20
20
 
21
21
  async function checkLicenseFile(context) {
22
22
  // https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/LICENSE
23
- console.log('\ncheckLicenseFile [E7xx]');
23
+ console.log('\n[E700 - E799] checkLicenseFile');
24
24
 
25
25
  let data;
26
26
  try {
@@ -65,10 +65,9 @@ async function checkLicenseFile(context) {
65
65
  }
66
66
  }
67
67
 
68
- console.log(`License year ${licenseYear}`);
69
- console.log(`Current year ${year}`);
70
- console.log(`Commit year ${commitYear}`);
71
- console.log(`NPM year ${npmYear}`);
68
+ common.info(
69
+ `years detected: LICENSE ${licenseYear} / Current ${year} / Last commit ${commitYear} / NPM ${npmYear}`,
70
+ );
72
71
 
73
72
  const valid = licenseYear === year || licenseYear >= commitYear || licenseYear >= npmYear;
74
73
  if (licenseYear > year) {
@@ -94,7 +93,7 @@ async function checkLicenseFile(context) {
94
93
  );
95
94
  }
96
95
  } else {
97
- context.checks.push('Valid copyright year ${licenseYear} found in LICENSE');
96
+ context.checks.push(`Valid copyright year ${licenseYear} found in LICENSE`);
98
97
  }
99
98
  }
100
99
  }
@@ -31,7 +31,7 @@ async function getAllIssues(context) {
31
31
  }
32
32
 
33
33
  async function getCommitInfos(context) {
34
- console.log('\ngetCommitInfos');
34
+ console.log('[init] getting commit infos');
35
35
  context.lastCommitSha = '';
36
36
  context.lastCommitYear = 0;
37
37
 
@@ -41,7 +41,7 @@ async function getCommitInfos(context) {
41
41
  common.debug(`reading github commits from ${url}`);
42
42
  response = await axios(url);
43
43
  } catch (e) {
44
- console.log(`[INTERNAL] error downloading commit info from ${url} - ${e}`);
44
+ common.error(`error downloading commit info from ${url} - ${e}`);
45
45
  throw e;
46
46
  }
47
47
 
@@ -62,7 +62,7 @@ async function getCommitInfos(context) {
62
62
  }
63
63
 
64
64
  async function checkGithubRepo(context) {
65
- console.log('\ncheckGithubRepo [E8xx]');
65
+ console.log('\n[E800 - E899] checkGithubRepo');
66
66
 
67
67
  if (!context.githubApiData.description) {
68
68
  context.errors.push(
@@ -25,10 +25,10 @@ function paddingNum(num) {
25
25
 
26
26
  // 900 - ???
27
27
  async function checkGitIgnore(context) {
28
+ console.log('\n[E900 - E950] checkGitIgnore');
28
29
  const checkFiles = ['.idea', 'tmp', 'node_modules'];
29
30
 
30
31
  // https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/.gitignore
31
- console.log('\ncheckGitIgnore [E9xx]');
32
32
 
33
33
  if (!context.filesList) {
34
34
  throw 'FATAL:context.fileslist is undefined';
@@ -86,6 +86,7 @@ async function checkGitIgnore(context) {
86
86
 
87
87
  // 950 - 989
88
88
  async function checkNpmIgnore(context) {
89
+ console.log('\n[E950 - E989] checkNpmIgnore');
89
90
  const checkFiles = [
90
91
  'node_modules/',
91
92
  'test/',
@@ -114,7 +115,6 @@ async function checkNpmIgnore(context) {
114
115
  ];
115
116
 
116
117
  // https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/.npmignore
117
- console.log('\ncheckNpmIgnore [E95x]');
118
118
  if (context.packageJson.files && context.packageJson.files.length) {
119
119
  if (context.filesList.includes('.npmignore')) {
120
120
  context.warnings.push(
package/lib/common.js CHANGED
@@ -16,23 +16,54 @@ axios.defaults.headers.common = {
16
16
  };
17
17
 
18
18
  let gDebug = false;
19
+ let gInfo = true;
20
+ let gLocal = false;
21
+
22
+ // function log(msg) {
23
+ // console.log(`${msg}`);
24
+ // }
25
+
26
+ function debug(msg) {
27
+ gDebug && console.log(`${msg ? '[DEBUG] ' : ''}${msg}`);
28
+ }
29
+
30
+ function info(msg) {
31
+ gInfo && console.log(`${msg ? '[INFO] ' : ''}${msg}`);
32
+ }
33
+
34
+ function warn(msg) {
35
+ console.log(`${msg ? '[WARNING] ' : ''}${msg}`);
36
+ }
37
+
38
+ function error(msg) {
39
+ console.error(`${msg ? '[ERROR] ' : ''}${msg}`);
40
+ }
41
+
42
+ function isDebug() {
43
+ return gDebug;
44
+ }
45
+
46
+ function isInfo() {
47
+ return gInfo;
48
+ }
49
+
50
+ function isLocal() {
51
+ return gLocal;
52
+ }
53
+
19
54
  function setDebug(flag) {
20
55
  gDebug = flag;
21
56
  debug('debug messages have been enabled');
22
57
  }
23
58
 
24
- function debug(msg) {
25
- gDebug && console.log(`[DEBUG] ${msg}`);
59
+ function setInfo(flag) {
60
+ gInfo = flag;
61
+ console.log(`[INFO] info messages have been ${gInfo ? 'enabled' : 'disabled'}`);
26
62
  }
27
63
 
28
- let gLocal = false;
29
64
  function setLocal(flag) {
30
65
  gLocal = flag;
31
- console.log(`[INFO] running in LOCAL mode`);
32
- }
33
-
34
- function isLocal() {
35
- return gLocal;
66
+ info(`running in LOCAL mode`);
36
67
  }
37
68
 
38
69
  function checkLanguages(langObj, languages) {
@@ -41,7 +72,7 @@ function checkLanguages(langObj, languages) {
41
72
 
42
73
  async function downloadFile(githubUrl, path, binary, noError) {
43
74
  if (!isLocal()) {
44
- console.log(`Download ${githubUrl}${path || ''}`);
75
+ debug(`Download ${githubUrl}${path || ''}`);
45
76
  const options = {};
46
77
  if (binary) {
47
78
  options.responseType = 'arraybuffer';
@@ -51,11 +82,11 @@ async function downloadFile(githubUrl, path, binary, noError) {
51
82
  debug(`download succeded`);
52
83
  return response.data;
53
84
  } catch (e) {
54
- (!noError || gDebug) && console.error(`Cannot download ${githubUrl}${path || ''} ${e}`);
85
+ (!noError || gDebug) && error(`Cannot download ${githubUrl}${path || ''} ${e}`);
55
86
  return '';
56
87
  }
57
88
  } else {
58
- console.log(`Download local ${path || ''}`);
89
+ debug(`Download local ${path || ''}`);
59
90
  // remove first / from path
60
91
  path = path.replace(/^\/+/, '');
61
92
  const file = await fs.readFile(path, binary ? null : 'utf8');
@@ -92,7 +123,7 @@ function getDependencyArray(deps) {
92
123
  // ]
93
124
  function getDependencies(deps) {
94
125
  const ret = {};
95
- console.log(`deps: ${JSON.stringify(deps)}, type ${typeof deps}`);
126
+ debug(`deps: ${JSON.stringify(deps)}, type ${typeof deps}`);
96
127
  if (deps instanceof Array) {
97
128
  for (const dep of deps) {
98
129
  if (typeof dep === 'object') {
@@ -104,7 +135,7 @@ function getDependencies(deps) {
104
135
  }
105
136
  }
106
137
  }
107
- console.log(`ret: ${JSON.stringify(ret)}`);
138
+ debug(`ret: ${JSON.stringify(ret)}`);
108
139
  return ret;
109
140
  }
110
141
 
@@ -154,11 +185,19 @@ function validateSemver(p_semver) {
154
185
  return ret.valid && !ret.uncompressed;
155
186
  }
156
187
 
157
- exports.setDebug = setDebug;
158
188
  exports.debug = debug;
159
- exports.setLocal = setLocal;
189
+ exports.info = info;
190
+ exports.error = error;
191
+ exports.warn = warn;
192
+
193
+ exports.isDebug = isDebug;
194
+ exports.isInfo = isInfo;
160
195
  exports.isLocal = isLocal;
161
196
 
197
+ exports.setDebug = setDebug;
198
+ exports.setInfo = setInfo;
199
+ exports.setLocal = setLocal;
200
+
162
201
  exports.checkLanguages = checkLanguages;
163
202
  exports.downloadFile = downloadFile;
164
203
  exports.getDependencyArray = getDependencyArray;
package/lib/config.js CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  */
6
6
 
7
+ const common = require('./common.js');
8
+
7
9
  const allowedLanguages = ['en', 'de', 'ru', 'pt', 'nl', 'fr', 'it', 'es', 'pl', 'uk', 'zh-cn'];
8
10
 
9
11
  const requiredLanguages = [
@@ -421,7 +423,7 @@ const reservedAdapterNames = [
421
423
  ];
422
424
 
423
425
  function initConfig(context) {
424
- console.log(`initConfig`);
426
+ console.log('[init] initializing configuration');
425
427
 
426
428
  context.cfg = {};
427
429
  context.cfg.allowedLanguages = allowedLanguages;
@@ -435,14 +437,18 @@ function initConfig(context) {
435
437
  }
436
438
 
437
439
  function updateConfig(context) {
438
- console.log(`updateConfig`);
440
+ console.log('[init] updating configuration');
439
441
 
440
442
  context.cfg.onlyWWW = !!context.ioPackageJson.common?.onlyWWW;
443
+ context.cfg.hasJsonConfig = !!(
444
+ context.ioPackageJson.common.adminUI?.config === 'json' ||
445
+ context.ioPackageJson.common.adminUI?.custom === 'json'
446
+ );
441
447
 
442
- console.log('');
443
- console.log('Configuration flags set:');
444
- console.log(` onlyWWW: ${context.cfg.onlyWWW ? 'true' : 'false'}`);
445
- console.log('');
448
+ common.info('');
449
+ common.info('Configuration flags set:');
450
+ common.info(` hasJsonConfig: ${context.cfg.hasJsonConfig ? 'true' : 'false'}`);
451
+ common.info(` onlyWWW: ${context.cfg.onlyWWW ? 'true' : 'false'}`);
446
452
  return context;
447
453
  }
448
454
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.4.4",
2
+ "version": "3.5.0",
3
3
  "name": "@iobroker/repochecker",
4
4
  "devDependencies": {
5
5
  "@alcalzone/release-script": "^3.8.0",