@iobroker/js-controller-cli 4.0.0-alpha.63-20220129-b1a625fb → 4.0.0-alpha.67-20220131-6621d47f

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.
@@ -2,11 +2,11 @@
2
2
  const CLI = require('./messages.js');
3
3
  const CLICommand = require('./cliCommand.js');
4
4
  const { formatValue } = require('./cliTools');
5
- const { tools } = require('@iobroker/js-controller-common');
5
+ const { tools, EXIT_CODES } = require('@iobroker/js-controller-common');
6
6
 
7
7
  /** Command iobroker object ... */
8
8
  module.exports = class CLIObjects extends CLICommand {
9
- /** @param {import('./cliCommand').CLICommandOptions} options */
9
+ /** @param {CLICommandOptions} options */
10
10
  constructor(options) {
11
11
  super(options);
12
12
  }
@@ -40,6 +40,10 @@ module.exports = class CLIObjects extends CLICommand {
40
40
  return this.getDBVersion(args);
41
41
  case 'setDBVersion':
42
42
  return this.setDBVersion();
43
+ case 'activateSets':
44
+ return this.activateSets();
45
+ case 'deactivateSets':
46
+ return this.deactivateSets();
43
47
  default:
44
48
  CLI.error.unknownCommand('object', command);
45
49
  showHelp();
@@ -47,6 +51,51 @@ module.exports = class CLIObjects extends CLICommand {
47
51
  }
48
52
  }
49
53
 
54
+ /**
55
+ * Activates the usage of Redis Sets
56
+ */
57
+ activateSets() {
58
+ const { callback, dbConnect } = this.options;
59
+ dbConnect(async (objects, states) => {
60
+ if (!parseInt(await objects.getMeta('objects.features.useSets'))) {
61
+ // all hosts need to be stopped for this
62
+ if (await tools.isHostRunning(objects, states)) {
63
+ console.log('Cannot activate the usage of Redis Sets while one or more hosts are running');
64
+ return void callback(EXIT_CODES.CONTROLLER_RUNNING);
65
+ }
66
+
67
+ await objects.activateSets();
68
+ const noMigrated = await objects.migrateToSets();
69
+
70
+ if (noMigrated) {
71
+ console.log(`Successfully migrated ${noMigrated} objects to Redis Sets`);
72
+ }
73
+ console.log(
74
+ `Successfully activated the usage of Redis Sets. Please make sure to only use js-controller 4.0 or higher on all hosts!`
75
+ );
76
+ } else {
77
+ console.log('Redis Sets are already activated.');
78
+ }
79
+ return void callback();
80
+ });
81
+ }
82
+
83
+ /**
84
+ * Deactivates the usage of Redis Sets
85
+ */
86
+ deactivateSets() {
87
+ const { callback, dbConnect } = this.options;
88
+ dbConnect(async objects => {
89
+ if (parseInt(await objects.getMeta('objects.features.useSets'))) {
90
+ await objects.deactivateSets();
91
+ console.log(`Successfully deactivated the usage of Redis Sets.`);
92
+ } else {
93
+ console.log('Redis Sets are already deactivated.');
94
+ }
95
+ return void callback();
96
+ });
97
+ }
98
+
50
99
  /**
51
100
  * Get the protocol version
52
101
  */
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@iobroker/js-controller-cli",
3
- "version": "4.0.0-alpha.63-20220129-b1a625fb",
3
+ "version": "4.0.0-alpha.67-20220131-6621d47f",
4
4
  "engines": {
5
5
  "node": ">=12.0.0"
6
6
  },
7
7
  "dependencies": {
8
- "@iobroker/js-controller-common": "4.0.0-alpha.63-20220129-b1a625fb",
9
- "@iobroker/js-controller-common-db": "4.0.0-alpha.63-20220129-b1a625fb",
8
+ "@iobroker/js-controller-common": "4.0.0-alpha.67-20220131-6621d47f",
9
+ "@iobroker/js-controller-common-db": "4.0.0-alpha.67-20220131-6621d47f",
10
10
  "chokidar": "^3.5.2",
11
11
  "daemonize2": "^0.4.2",
12
12
  "debug": "^4.3.3",
@@ -38,5 +38,5 @@
38
38
  "lib/",
39
39
  "index.js"
40
40
  ],
41
- "gitHead": "80f291dcb0467f22482e131d223757438d87b9d0"
41
+ "gitHead": "9079df08acfa9720e1e1747d3476950e7ec51ca5"
42
42
  }