@iobroker/legacy-testing 1.0.9 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022-2023 bluefox <dogafox@gmail.com>
3
+ Copyright (c) 2022-2024 bluefox <dogafox@gmail.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -14,6 +14,9 @@ Set process.env.JS_CONTROLLER_VERSION to version e.g. `5.0.5-alpha.0-20230617-46
14
14
 
15
15
  ## Changelog
16
16
  <!-- ### **WORK IN PROGRESS** -->
17
+ ### 1.0.10 (2024-04-10)
18
+ * (bluefox) Added support for vis-2 testing
19
+
17
20
  ### 1.0.9 (2023-12-19)
18
21
  * (foxriver76) create folder on initialization
19
22
 
@@ -24,7 +27,7 @@ Set process.env.JS_CONTROLLER_VERSION to version e.g. `5.0.5-alpha.0-20230617-46
24
27
  * (foxriver76) allow re-initialization after config change
25
28
 
26
29
  ### 1.0.6 (2023-12-19)
27
- * (foxriver76) allow to specify the `rootDir`
30
+ * (foxriver76) allow specifying the `rootDir`
28
31
 
29
32
  ### 1.0.5 (2023-12-15)
30
33
  * (bluefox) Added support for vis-1 testing
@@ -63,7 +66,7 @@ Set process.env.JS_CONTROLLER_VERSION to version e.g. `5.0.5-alpha.0-20230617-46
63
66
  ## License
64
67
  MIT License
65
68
 
66
- Copyright (c) 2022-2023 bluefox <dogafox@gmail.com>
69
+ Copyright (c) 2022-2024 bluefox <dogafox@gmail.com>
67
70
 
68
71
  Permission is hereby granted, free of charge, to any person obtaining a copy
69
72
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.9",
2
+ "version": "1.0.10",
3
3
  "name": "@iobroker/legacy-testing",
4
4
  "main": "setup.js",
5
5
  "files": [
@@ -26,8 +26,8 @@
26
26
  "email": "dogafox@gmail.com"
27
27
  },
28
28
  "dependencies": {
29
- "mocha": "^10.2.0",
30
- "chai": "^4.3.10"
29
+ "mocha": "^10.4.0",
30
+ "chai": "^4.4.1"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@alcalzone/release-script": "^3.7.0",
package/setup.js CHANGED
@@ -459,6 +459,22 @@ async function installJsController(preInstalledAdapters, cb) {
459
459
  await storeOriginalFiles();
460
460
  cb && cb(true);
461
461
  } else {
462
+ if (preInstalledAdapters) {
463
+ for (let p = 0; p < preInstalledAdapters.length; p++) {
464
+ // if not installed
465
+ const parts = preInstalledAdapters[p].split('@');
466
+ const name = parts[0];
467
+ const version = parts[1];
468
+ if (!fs.existsSync(`${rootDir}tmp/node_modules/${name}`)) {
469
+ await installAdapterAsync(preInstalledAdapters[p]);
470
+ } else {
471
+ const pack = require(`${rootDir}tmp/node_modules/${name}/package.json`);
472
+ if (pack.version !== version) {
473
+ await installAdapterAsync(preInstalledAdapters[p]);
474
+ }
475
+ }
476
+ }
477
+ }
462
478
  setTimeout(() => {
463
479
  console.log('installJsController: js-controller installed');
464
480
  cb && cb(false);
@@ -560,8 +576,9 @@ function clearDB() {
560
576
  * @param {LegacyTestingOptions} options specify attributes which should be overridden
561
577
  */
562
578
  function setOptions(options) {
563
- if (options.rootDir) {
579
+ if (options.rootDir && fs.existsSync(options.rootDir) && rootDir !== options.rootDir) {
564
580
  rootDir = options.rootDir
581
+ initialize();
565
582
  }
566
583
  }
567
584
 
@@ -8,7 +8,8 @@ const expect = require('chai').expect;
8
8
  const fs = require('fs');
9
9
 
10
10
  // node_modules/@iobroker/legacy-testing/tests/testPackageFiles.js
11
- const adapterDir = `${__dirname}/../../../../`;
11
+ const adapterDir = process.env.IOBROKER_ROOT_DIR || `${__dirname}/../../../../`;
12
+ const alternativeAdapterDir = `${__dirname}/../../../../`;
12
13
 
13
14
  describe('Test package.json and io-package.json', () => {
14
15
  it('Test package files', done => {
@@ -52,7 +53,7 @@ describe('Test package.json and io-package.json', () => {
52
53
  console.log();
53
54
  }
54
55
 
55
- expect(fs.existsSync(`${adapterDir}/README.md`), 'ERROR: README.md needs to exist! Please create one with description, detail information and changelog. English is mandatory.').to.be.true;
56
+ expect(fs.existsSync(`${adapterDir}/README.md`) || fs.existsSync(`${alternativeAdapterDir}/README.md`), 'ERROR: README.md needs to exist! Please create one with description, detail information and changelog. English is mandatory.').to.be.true;
56
57
 
57
58
  if (!ioPackage.common.titleLang || typeof ioPackage.common.titleLang !== 'object') {
58
59
  console.log('WARNING: titleLang is not existing in io-package.json. Please add');
@@ -85,7 +86,7 @@ describe('Test package.json and io-package.json', () => {
85
86
  }
86
87
 
87
88
  const licenseFileExists = fs.existsSync(`${adapterDir}/LICENSE`);
88
- const fileContentReadme = fs.readFileSync(`${adapterDir}/README.md`, 'utf8');
89
+ const fileContentReadme = fs.existsSync(`${alternativeAdapterDir}/README.md`) ? fs.readFileSync(`${alternativeAdapterDir}/README.md`, 'utf8') : fs.readFileSync(`${adapterDir}/README.md`, 'utf8');
89
90
 
90
91
  if (!fileContentReadme.includes('## Changelog')) {
91
92
  console.log('Warning: The README.md should have a section ## Changelog');