@iobroker/repochecker 3.0.7 → 3.1.1

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
@@ -20,6 +20,18 @@ Branch (`master/main/dev`) is optional.
20
20
  -->
21
21
 
22
22
  ## Changelog
23
+ ### 3.1.1 (2024-10-04)
24
+ * (mcm1957) "[E166] 'common.mode: extension' is unknown" has been fixed [#308]
25
+ * (mcm1957) "[E904] file iob_npm.done found in repository, but not found in .gitignore" removed as covered by [E503]. [#309]
26
+ * (mcm1957) "[E500] node_modules found" has been retricted to adapetr root. [#297]
27
+ * (mcm1957) Do not check main entry if common.mode none or extension.
28
+ * (mcm1957) Change "[W113] Adapter should support compact mode" text and honor common.compact set to false. [#300]
29
+
30
+ ### 3.1.0 (2024-09-29)
31
+ * (mcm1957) "@iobroker/plugin-sentry" blacklisted as dependency [#301]
32
+ * (mcm1957) Accept .ts files as main file too. [#303]
33
+ * (mcm1957) [E405] and [E426] incorrect path has been corrected. [#299]
34
+
23
35
  ### 3.0.7 (2024-09-19)
24
36
  * (mcm1957) "[W523] 'package-lock.json"'not found in repo!" reduced to suggestion. [#298]
25
37
 
package/index.js CHANGED
@@ -94,7 +94,7 @@ function getGithubApiData(context) {
94
94
  })
95
95
  .catch(e => {
96
96
  context.errors.push(`[E000] FATAL: cannot access repository ${context.githubUrlApi}`);
97
- reject(e.toJSON());
97
+ reject(e);
98
98
  });// E0xx
99
99
  });
100
100
  }
@@ -31,6 +31,40 @@ const devDependenciesPackageJson = {
31
31
  },
32
32
  };
33
33
 
34
+ const blacklistedDependenciesPackageJson = {
35
+ 'npm': {
36
+ msg: "'npm'must not be listed as dependency at package.json. Please remove.",
37
+ err: true
38
+ },
39
+ 'iobroker.js-controller': {
40
+ msg: "'iobroker.js-controller' must not be listed as dependency at package.json. Please remove.",
41
+ err: true
42
+ },
43
+ '@iobroker/dev-server': {
44
+ msg: "'@iobroker/dev-server' must not be listed as dependency at package.json. Please remove.",
45
+ err: true
46
+ },
47
+ '@iobroker/plugin-sentry': {
48
+ msg: "'@iobroker/plugin-sentry' must not be listed as dependency at package.json as it will crash js-controller 7 systems. Please remove and create new release.",
49
+ err: true
50
+ },
51
+ };
52
+
53
+ const blacklistedDevDependenciesPackageJson = {
54
+ 'npm': {
55
+ msg: "'npm'must not be listed as devDependency at package.json. Please remove.",
56
+ err: true
57
+ },
58
+ 'iobroker.js-controller': {
59
+ msg: "'iobroker.js-controller' must not be listed as devDependency at package.json. Please remove.",
60
+ err: true
61
+ },
62
+ '@iobroker/plugin-sentry': {
63
+ msg: "'@iobroker/plugin-sentry' must not be listed as devDependency at package.json. Please remove.",
64
+ err: true
65
+ },
66
+ };
67
+
34
68
  const blacklistPackageJson = {
35
69
 
36
70
  };
@@ -201,28 +235,52 @@ async function checkPackageJson(context) {
201
235
  context.errors.push('[E031] No devDependencies declared at package.json. Please correct package.json');
202
236
  }
203
237
 
204
- if ((context.packageJson.dependencies && context.packageJson.dependencies.npm) || (context.packageJson.optionalDependencies && context.packageJson.optionalDependencies.npm)) {
205
- context.errors.push('[E023] Do not include "npm" as dependency!');
206
- } else {
207
- context.checks.push('npm is not in dependencies');
238
+ if (context.packageJson.dependencies) {
239
+ for (const blacklist in blacklistedDependenciesPackageJson) {
240
+ if (context.packageJson.dependencies[blacklist]) {
241
+ if (blacklistedDependenciesPackageJson[blacklist].err){
242
+ context.errors.push(`[E050] ${blacklistedDependenciesPackageJson[blacklist].msg}`);
243
+ } else {
244
+ context.warnings.push(`[W051] ${blacklistedDependenciesPackageJson[blacklist].msg}`);
245
+ }
246
+ }
247
+ }
208
248
  }
209
249
 
210
- if ((context.packageJson.dependencies && context.packageJson.dependencies['iobroker.js-controller']) ||
211
- (context.packageJson.devDependencies && context.packageJson.devDependencies['iobroker.js-controller']) ||
212
- (context.packageJson.optionalDependencies && context.packageJson.optionalDependencies['iobroker.js-controller'])
213
- ) {
214
- context.errors.push('[E025] "iobroker.js-controller" must not be listed as dependency at package.json');
215
- } else {
216
- context.checks.push('iobroker.js-controller is not in dependencies');
250
+ if (context.packageJson.devDependencies) {
251
+ for (const blacklist in blacklistedDevDependenciesPackageJson) {
252
+ if (context.packageJson.devDependencies[blacklist]) {
253
+ if (blacklistedDevDependenciesPackageJson[blacklist].err){
254
+ context.errors.push(`[E052] ${blacklistedDevDependenciesPackageJson[blacklist].msg}`);
255
+ } else {
256
+ context.warnings.push(`[W053] ${blacklistedDevDependenciesPackageJson[blacklist].msg}`);
257
+ }
258
+ }
259
+ }
217
260
  }
218
261
 
219
- if ((context.packageJson.dependencies && context.packageJson.dependencies['@iobroker/dev-server']) ||
220
- (context.packageJson.optionalDependencies && context.packageJson.optionalDependencies['@iobroker/dev-server'])
221
- ) {
222
- context.errors.push('[E011] "@iobroker/dev-server" must not be listed as dependency at package.json');
223
- } else {
224
- context.checks.push('iobroker.@iobroker/dev-server is not in dependencies');
225
- }
262
+ // if ((context.packageJson.dependencies && context.packageJson.dependencies.npm) || (context.packageJson.optionalDependencies && context.packageJson.optionalDependencies.npm)) {
263
+ // context.errors.push('[E023] Do not include "npm" as dependency!');
264
+ // } else {
265
+ // context.checks.push('npm is not in dependencies');
266
+ // }
267
+
268
+ // if ((context.packageJson.dependencies && context.packageJson.dependencies['iobroker.js-controller']) ||
269
+ // (context.packageJson.devDependencies && context.packageJson.devDependencies['iobroker.js-controller']) ||
270
+ // (context.packageJson.optionalDependencies && context.packageJson.optionalDependencies['iobroker.js-controller'])
271
+ // ) {
272
+ // context.errors.push('[E025] "iobroker.js-controller" must not be listed as dependency at package.json');
273
+ // } else {
274
+ // context.checks.push('iobroker.js-controller is not in dependencies');
275
+ // }
276
+
277
+ // if ((context.packageJson.dependencies && context.packageJson.dependencies['@iobroker/dev-server']) ||
278
+ // (context.packageJson.optionalDependencies && context.packageJson.optionalDependencies['@iobroker/dev-server'])
279
+ // ) {
280
+ // context.errors.push('[E011] "@iobroker/dev-server" must not be listed as dependency at package.json');
281
+ // } else {
282
+ // context.checks.push('iobroker.@iobroker/dev-server is not in dependencies');
283
+ // }
226
284
 
227
285
  if (!context.ioPackageJson.common.onlyWWW) {
228
286
  if (!context.packageJson.engines) {
@@ -391,7 +449,7 @@ async function checkPackageJson(context) {
391
449
  }
392
450
 
393
451
  // single free 008
394
- // first free 050
452
+ // first free 054
395
453
 
396
454
  return context;
397
455
  }
@@ -412,7 +470,7 @@ exports.checkPackageJson = checkPackageJson;
412
470
  // [008] - free -
413
471
  // [009] No version found in the package.json
414
472
  // [010] No description found in the package.json
415
- // [011] "@iobroker/dev-server" must not be listed as dependency at package.json'
473
+ // [011] ### "@iobroker/dev-server" must not be listed as dependency at package.json'
416
474
  // [012] Invalid repository object in package.json
417
475
  // [013] No author found in the package.json
418
476
  // [014] NPM information found in package.json. Please remove all attributes starting with "_"
@@ -425,9 +483,9 @@ exports.checkPackageJson = checkPackageJson;
425
483
  // [020] Name of adapter in package.json must be lowercase and be equal to "iobroker.${adapterName.toLowerCase()}". Now is "${packageJson.name}"
426
484
  // [021] "licenses" in package.json are deprecated. Please remove and use "license": "NAME" field.
427
485
  // [022] Adapter name is reserved. Please rename adapter.
428
- // [023] Do not include "npm" as dependency!
486
+ // [023] ### Do not include "npm" as dependency!
429
487
  // [024] Adapter name "${adapterName}" may not start with '_'y!
430
- // [025] "iobroker.js-controller" must not be listed as dependency at package.json'
488
+ // [025] ### "iobroker.js-controller" must not be listed as dependency at package.json'
431
489
  // [026] "{'engines': {'node'>='${requiredNodeVersion}'}}" is required at package.json, "{'engines':{'node'>='${recommendedNodeVersion}'}}" is recommended
432
490
  // [026] "{'engines': {'node'>='${requiredNodeVersion}'}}" is required at package.json, "{'engines':{'node'>='${recommendedNodeVersion}'}}" is recommended
433
491
  // [027] Engines clause at at package.json ({'engines' : { 'node' : '${nodeVal}' } }") is not parseable.
@@ -455,3 +513,8 @@ exports.checkPackageJson = checkPackageJson;
455
513
  // [047] dependency should not require a specific version. Use "~1.2.3" or "^1.2.3" syntax. Please update "${dependency}:${context.packageJson.dependencies[dependency]}"
456
514
  // [048] devDependency should not require a specific version. Use "~1.2.3" or "^1.2.3" syntax. Please update "${dependency}:${context.packageJson.devDependencies[dependency]}"
457
515
  // [049] "keywords" within package.json must contain some keywords besides "${context.packageJson.keywords.join(', ')}" related to adapter
516
+ // [E050] ${blacklistedDependenciesPackageJson[blacklist].msg}
517
+ // [W051] ${blacklistedDependenciesPackageJson[blacklist].msg}.
518
+ // [E052] ${blacklistedDevDependenciesPackageJson[blacklist].msg}
519
+ // [W053] ${blacklistedDevDependenciesPackageJson[blacklist].msg}
520
+
@@ -269,7 +269,11 @@ async function checkIOPackageJson(context) {
269
269
  }
270
270
 
271
271
  if (!context.ioPackageJson.common.compact && !context.ioPackageJson.common.onlyWWW) {
272
- context.warnings.push('[W113] Adapter should support compact mode');
272
+ if (context.ioPackageJson.common.compact === undefined ) {
273
+ context.warnings.push('[W113] Please test whether adapter can support compact mode, if not set "common.compact:false" at io-package.json');
274
+ } else {
275
+ context.warnings.push('[S139] Please evaluate whether adapter can be modified to support compact mode');
276
+ }
273
277
  } else if (!context.ioPackageJson.common.onlyWWW) {
274
278
  context.checks.push('"common.compact" found in io-package.json');
275
279
  }
@@ -435,14 +439,17 @@ async function checkIOPackageJson(context) {
435
439
 
436
440
  }
437
441
 
438
- // now check the package.json again, because it is valid only for onlyWWW
439
- if (!context.packageJson.main) {
440
- !context.ioPackageJson.common.onlyWWW && context.errors.push('[E143] No main found in the package.json');
441
- } else {
442
- context.checks.push('"main" found in package.json');
443
-
444
- if (context.ioPackageJson.common.mode !== 'none' && !context.packageJson.main.endsWith('.js')) {
445
- !context.ioPackageJson.common.onlyWWW && context.errors.push(`[E163] common.mode "${context.ioPackageJson.common.mode}" requires JavaScript file for "main" in package.json`);
442
+ // check main entry
443
+ if ((context.ioPackageJson.common.mode !== 'none') && (context.ioPackageJson.common.mode !== 'extension')) {
444
+ if (!context.packageJson.main) {
445
+ !context.ioPackageJson.common.onlyWWW && context.errors.push('[E143] No main found in the package.json');
446
+ } else {
447
+ context.checks.push('"main" found in package.json');
448
+ if (!context.packageJson.main.endsWith('.js') && !context.packageJson.main.endsWith('.ts')) {
449
+ !context.ioPackageJson.common.onlyWWW && context.errors.push(`[E163] common.mode "${context.ioPackageJson.common.mode}" requires JavaScript or Typescript file for "main" in package.json`);
450
+ } else {
451
+ context.checks.push('"main" references .js or .ts file');
452
+ }
446
453
  }
447
454
  }
448
455
 
@@ -646,7 +653,7 @@ async function checkIOPackageJson(context) {
646
653
  }
647
654
  }
648
655
 
649
- // single free 139
656
+ // single free
650
657
  // first free 187
651
658
 
652
659
  return context;
@@ -696,8 +703,8 @@ exports.checkIOPackageJson = checkIOPackageJson;
696
703
  // [135] "common.tier" is required in io-package.json. Please check https://github.com/ioBroker/ioBroker.docs/blob/master/docs/en/dev/objectsschema.md#adapter.
697
704
  // [136] No "common.news" found for actual version ${context.ioPackageJson.common.version} in io-package.json
698
705
  // [137] "common.automaticUpgrade" will be defined by the user. Please remove from io-package.json
699
- // [138] Main file not found under URL: ${context.githubUrl}/${context.packageJson.main} and not located at build/ directory too.`
700
- // [139]
706
+ // [138] Main file not found under URL: ${context.githubUrl}/${context.packageJson.main} and not located at build/ directory too.
707
+ // [139] Please evaluate whether adapter can be modified to support compact mode.
701
708
  // [140] width and height of logo are not equal
702
709
  // [141] logo is too small. It must be greater or equal than 32x32
703
710
  // [142] logo is too big. It must be less or equal than 512x512
@@ -60,8 +60,8 @@ async function checkRepository(context) {
60
60
  } else {
61
61
  context.checks.push('Icon found in latest repository');
62
62
 
63
- if (!context.latestRepo[context.adapterName].icon.startsWith(url)) {
64
- context.errors.push(`[E405] Icon must be in the following path: ${url}; correct sources-dist.json`);
63
+ if (!context.latestRepo[context.adapterName].icon.startsWith(`${url}admin/`)) {
64
+ context.errors.push(`[E405] Icon must be in the following path: ${url}admin/; correct sources-dist.json`);
65
65
  } else {
66
66
  context.checks.push('Icon found in latest repository');
67
67
  }
@@ -113,8 +113,8 @@ async function checkRepository(context) {
113
113
  } else {
114
114
  context.checks.push('Icon found in stable repository');
115
115
 
116
- if (!context.stableRepo[context.adapterName].icon.startsWith(url)) {
117
- context.errors.push(`[E426] Icon must be in the following path: ${url}; correct sources-dist-stable.json`);
116
+ if (!context.stableRepo[context.adapterName].icon.startsWith(`${url}admin/`)) {
117
+ context.errors.push(`[E426] Icon must be in the following path: ${url}admin/; correct sources-dist-stable.json`);
118
118
  } else {
119
119
  context.checks.push('Icon (stable) found in latest repository');
120
120
  }
package/lib/M500_Code.js CHANGED
@@ -150,14 +150,20 @@ async function checkCode(context) {
150
150
  const promises = [];
151
151
  await (function () { return new Promise(_resolve => {
152
152
  common.debug('init bufferstream');
153
+ let root='';
153
154
  bufferStream
154
155
  .pipe(unzipper.Parse())
155
156
  .on('entry', entry => {
156
157
  common.debug('on.entry ' + entry.path);
157
- if (!found && entry.type === 'Directory' && entry.path.match(/\/node_modules\/$/)) {
158
+ if (root === '') {
159
+ root=entry.path;
160
+ console.log(`Directory root set to ${root}`);
161
+ }
162
+ //if (!found && entry.type === 'Directory' && entry.path.match(/\/node_modules\/$/)) {
163
+ if (!found && entry.type === 'Directory' && entry.path === `${root}node_modules/`) {
158
164
  console.log(`Found ${entry.path}`);
159
165
  found = true;
160
- context.errors.push('[E500] node_modules found in repo. Please delete it');
166
+ context.errors.push('[E500] Directory node_modules found in root of repository. Please delete directory.');
161
167
  }
162
168
 
163
169
  // Get a list of all files and `.npmignore` + `.gitignore`
@@ -28,7 +28,6 @@ async function checkGitIgnore(context) {
28
28
  '.idea',
29
29
  'tmp',
30
30
  'node_modules',
31
- 'iob_npm.done',
32
31
  ];
33
32
 
34
33
  // https://raw.githubusercontent.com/userName/ioBroker.adaptername/${context.branch}/.gitignore
package/lib/config.js CHANGED
@@ -384,7 +384,7 @@ const allowedModes = {
384
384
  'daemon': 'always running process (will be restarted if process exits)',
385
385
  'schedule': 'is started by schedule found in system.adapter…common.schedule - reacts on changes of .schedule by rescheduling with new state',
386
386
  'once': 'his adapter will be started every time the system.adapter.. object changed. It will not be restarted after termination.',
387
- 'extension': ''
387
+ 'extension': 'this adapter provides a web extension only'
388
388
  };
389
389
  const allowedTypes = {
390
390
  'alarm': 'security of home, car, boat, ...',
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.0.7",
2
+ "version": "3.1.1",
3
3
  "name": "@iobroker/repochecker",
4
4
  "dependencies": {
5
5
  "axios": "^1.7.7",