@iobroker/legacy-testing 1.0.8 → 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,12 @@ 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
+
20
+ ### 1.0.9 (2023-12-19)
21
+ * (foxriver76) create folder on initialization
22
+
17
23
  ### 1.0.8 (2023-12-19)
18
24
  * (foxriver76) use hardcoded appName instead of inference with a heuristic approach
19
25
 
@@ -21,7 +27,7 @@ Set process.env.JS_CONTROLLER_VERSION to version e.g. `5.0.5-alpha.0-20230617-46
21
27
  * (foxriver76) allow re-initialization after config change
22
28
 
23
29
  ### 1.0.6 (2023-12-19)
24
- * (foxriver76) allow to specify the `rootDir`
30
+ * (foxriver76) allow specifying the `rootDir`
25
31
 
26
32
  ### 1.0.5 (2023-12-15)
27
33
  * (bluefox) Added support for vis-1 testing
@@ -60,7 +66,7 @@ Set process.env.JS_CONTROLLER_VERSION to version e.g. `5.0.5-alpha.0-20230617-46
60
66
  ## License
61
67
  MIT License
62
68
 
63
- Copyright (c) 2022-2023 bluefox <dogafox@gmail.com>
69
+ Copyright (c) 2022-2024 bluefox <dogafox@gmail.com>
64
70
 
65
71
  Permission is hereby granted, free of charge, to any person obtaining a copy
66
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.8",
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
@@ -35,6 +35,8 @@ initialize();
35
35
  function initialize() {
36
36
  pkg = require(`${rootDir}package.json`);
37
37
  pkg.main = pkg.main || 'main.js';
38
+
39
+ !fs.existsSync(`${rootDir}tmp`) && fs.mkdirSync(`${rootDir}tmp`);
38
40
  }
39
41
 
40
42
  /** Lowercase application name */
@@ -106,8 +108,6 @@ function copyFolderRecursiveSync(source, target, ignore) {
106
108
  }
107
109
  }
108
110
 
109
- !fs.existsSync(`${rootDir}tmp`) && fs.mkdirSync(`${rootDir}tmp`);
110
-
111
111
  async function storeOriginalFiles() {
112
112
  console.log('Store original files...');
113
113
  const dataDir = `${rootDir}tmp/${appName}-data/`;
@@ -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');