@iobroker/js-controller-cli 4.0.0-alpha.4-20210903-73c142c3 → 4.0.0-alpha.40-20220106-d00db6b2
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 +22 -53
- package/README.md +2 -2
- package/index.js +12 -11
- package/lib/cli/cliCert.js +1 -2
- package/lib/cli/cliCompact.js +22 -7
- package/lib/cli/cliDebug.js +2 -7
- package/lib/cli/cliHost.js +5 -8
- package/lib/cli/cliLogs.js +9 -18
- package/lib/cli/cliMessage.js +3 -12
- package/lib/cli/cliObjects.js +112 -25
- package/lib/cli/cliPlugin.js +120 -175
- package/lib/cli/cliProcess.js +23 -15
- package/lib/cli/cliStates.js +88 -29
- package/lib/cli/cliTools.js +2 -4
- package/lib/cli/messages.js +48 -63
- package/lib/setup/setupList.js +843 -0
- package/package.json +12 -7
package/LICENSE
CHANGED
|
@@ -1,53 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
24
|
-
|
|
25
|
-
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
26
|
-
|
|
27
|
-
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
28
|
-
|
|
29
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
30
|
-
|
|
31
|
-
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
32
|
-
|
|
33
|
-
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
34
|
-
|
|
35
|
-
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
36
|
-
|
|
37
|
-
You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
38
|
-
You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
39
|
-
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
40
|
-
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
41
|
-
|
|
42
|
-
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
43
|
-
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
44
|
-
|
|
45
|
-
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
46
|
-
|
|
47
|
-
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
48
|
-
|
|
49
|
-
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
50
|
-
|
|
51
|
-
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
52
|
-
|
|
53
|
-
END OF TERMS AND CONDITIONS
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014-2021 bluefox<dogafox@gmail.com>,
|
|
4
|
+
Copyright (c) 2014 hobbyquaker
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
success:
|
|
3
|
-
warn:
|
|
4
|
-
error:
|
|
5
|
-
tools:
|
|
2
|
+
success: require('./lib/cli/messages').success,
|
|
3
|
+
warn: require('./lib/cli/messages').warn,
|
|
4
|
+
error: require('./lib/cli/messages').error,
|
|
5
|
+
tools: require('./lib/cli/cliTools'),
|
|
6
6
|
command: {
|
|
7
|
-
object:
|
|
8
|
-
state:
|
|
7
|
+
object: require('./lib/cli/cliObjects.js'),
|
|
8
|
+
state: require('./lib/cli/cliStates.js'),
|
|
9
9
|
process: require('./lib/cli/cliProcess.js'),
|
|
10
10
|
message: require('./lib/cli/cliMessage.js'),
|
|
11
|
-
logs:
|
|
12
|
-
host:
|
|
13
|
-
cert:
|
|
11
|
+
logs: require('./lib/cli/cliLogs.js'),
|
|
12
|
+
host: require('./lib/cli/cliHost.js'),
|
|
13
|
+
cert: require('./lib/cli/cliCert.js'),
|
|
14
14
|
compact: require('./lib/cli/cliCompact.js'),
|
|
15
|
-
debug:
|
|
15
|
+
debug: require('./lib/cli/cliDebug.js'),
|
|
16
16
|
plugin: require('./lib/cli/cliPlugin.js')
|
|
17
|
-
}
|
|
17
|
+
},
|
|
18
|
+
setupList: require('./lib/setup/setupList')
|
|
18
19
|
};
|
package/lib/cli/cliCert.js
CHANGED
|
@@ -6,7 +6,6 @@ const { tools } = require('@iobroker/js-controller-common');
|
|
|
6
6
|
|
|
7
7
|
/** Command ioBroker cert ... */
|
|
8
8
|
module.exports = class CLICert extends CLICommand {
|
|
9
|
-
|
|
10
9
|
/** @param {import('./cliCommand.js').CLICommandOptions} options */
|
|
11
10
|
constructor(options) {
|
|
12
11
|
super(options);
|
|
@@ -77,4 +76,4 @@ module.exports = class CLICert extends CLICommand {
|
|
|
77
76
|
});
|
|
78
77
|
});
|
|
79
78
|
}
|
|
80
|
-
};
|
|
79
|
+
};
|
package/lib/cli/cliCompact.js
CHANGED
|
@@ -6,7 +6,6 @@ const fs = require('fs-extra');
|
|
|
6
6
|
|
|
7
7
|
/** Command ioBroker compact ... */
|
|
8
8
|
module.exports = class CLICompact extends CLICommand {
|
|
9
|
-
|
|
10
9
|
/** @param {import('./cliCommand.js').CLICommandOptions} options */
|
|
11
10
|
constructor(options) {
|
|
12
11
|
super(options);
|
|
@@ -111,13 +110,18 @@ module.exports = class CLICompact extends CLICommand {
|
|
|
111
110
|
objects.getObject('system.adapter.' + instance, (err, obj) => {
|
|
112
111
|
if (!err && obj) {
|
|
113
112
|
if (!obj.common.compact) {
|
|
114
|
-
console.log(
|
|
113
|
+
console.log(
|
|
114
|
+
'This adapter does not support compact mode. The below settings will have no effect!'
|
|
115
|
+
);
|
|
115
116
|
console.log();
|
|
116
117
|
} else {
|
|
117
118
|
console.log('Adapter supports compact mode: ' + !!obj.common.compact);
|
|
118
119
|
}
|
|
119
120
|
console.log('Compact mode enabled for instance: ' + !!obj.common.runAsCompactMode);
|
|
120
|
-
console.log(
|
|
121
|
+
console.log(
|
|
122
|
+
'Compact group: ' +
|
|
123
|
+
(obj.common.compactGroup !== undefined ? obj.common.compactGroup : 1)
|
|
124
|
+
);
|
|
121
125
|
return void callback();
|
|
122
126
|
} else {
|
|
123
127
|
CLI.error.invalidInstance(instance);
|
|
@@ -138,7 +142,9 @@ module.exports = class CLICompact extends CLICommand {
|
|
|
138
142
|
objects.getObject('system.adapter.' + instance, (err, obj) => {
|
|
139
143
|
if (!err && obj) {
|
|
140
144
|
if (!obj.common.compact) {
|
|
141
|
-
console.log(
|
|
145
|
+
console.log(
|
|
146
|
+
'This adapter does not support compact mode. The below settings will have no effect!'
|
|
147
|
+
);
|
|
142
148
|
console.log();
|
|
143
149
|
} else {
|
|
144
150
|
console.log('Adapter supports compact mode : ' + !!obj.common.compact);
|
|
@@ -158,8 +164,18 @@ module.exports = class CLICompact extends CLICommand {
|
|
|
158
164
|
newCompactGroup = groupId;
|
|
159
165
|
}
|
|
160
166
|
}
|
|
161
|
-
console.log(
|
|
162
|
-
|
|
167
|
+
console.log(
|
|
168
|
+
'Compact mode enabled for instance: ' +
|
|
169
|
+
(newRunAsCompactMode !== undefined
|
|
170
|
+
? '--> ' + newRunAsCompactMode
|
|
171
|
+
: !!obj.common.runAsCompactMode)
|
|
172
|
+
);
|
|
173
|
+
console.log(
|
|
174
|
+
'Compact group: ' +
|
|
175
|
+
(newCompactGroup !== undefined && obj.common.compactGroup !== newCompactGroup
|
|
176
|
+
? '--> ' + newCompactGroup
|
|
177
|
+
: obj.common.compactGroup)
|
|
178
|
+
);
|
|
163
179
|
if (newRunAsCompactMode !== undefined || newCompactGroup !== undefined) {
|
|
164
180
|
if (newCompactGroup !== undefined) {
|
|
165
181
|
obj.common.compactGroup = newCompactGroup;
|
|
@@ -188,5 +204,4 @@ module.exports = class CLICompact extends CLICommand {
|
|
|
188
204
|
});
|
|
189
205
|
});
|
|
190
206
|
}
|
|
191
|
-
|
|
192
207
|
};
|
package/lib/cli/cliDebug.js
CHANGED
|
@@ -20,10 +20,7 @@ module.exports = class CLICompact extends CLICommand {
|
|
|
20
20
|
const { callback, ...params } = this.options;
|
|
21
21
|
const adapter = args[0];
|
|
22
22
|
if (!adapter) {
|
|
23
|
-
CLI.error.requiredArgumentMissing(
|
|
24
|
-
'adaptername',
|
|
25
|
-
'debug <adaptername>'
|
|
26
|
-
);
|
|
23
|
+
CLI.error.requiredArgumentMissing('adaptername', 'debug <adaptername>');
|
|
27
24
|
return void callback(34);
|
|
28
25
|
}
|
|
29
26
|
|
|
@@ -49,9 +46,7 @@ module.exports = class CLICompact extends CLICommand {
|
|
|
49
46
|
const nodeArgs = [
|
|
50
47
|
...tools.getDefaultNodeArgs(mainFile),
|
|
51
48
|
// --inspect[-brk][=[ip]:[port]]
|
|
52
|
-
`--inspect${params.wait ? '-brk' : ''}${
|
|
53
|
-
!!params.ip || !!params.port ? '=' : ''
|
|
54
|
-
}${params.ip || ''}${
|
|
49
|
+
`--inspect${params.wait ? '-brk' : ''}${!!params.ip || !!params.port ? '=' : ''}${params.ip || ''}${
|
|
55
50
|
!!params.ip && !!params.port ? ':' : ''
|
|
56
51
|
}${params.port || ''}`
|
|
57
52
|
];
|
package/lib/cli/cliHost.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
const CLI = require('./messages.js');
|
|
3
3
|
const CLICommand = require('./cliCommand.js');
|
|
4
|
-
const {enumHosts, enumObjects, getObjectFrom, enumInstances} = require('./cliTools');
|
|
4
|
+
const { enumHosts, enumObjects, getObjectFrom, enumInstances } = require('./cliTools');
|
|
5
5
|
const { tools } = require('@iobroker/js-controller-common');
|
|
6
6
|
const os = require('os');
|
|
7
7
|
const fs = require('fs-extra');
|
|
8
8
|
|
|
9
9
|
/** Command iobroker host ... */
|
|
10
10
|
module.exports = class CLIHost extends CLICommand {
|
|
11
|
-
|
|
12
11
|
/** @param {import('./cliCommand').CLICommandOptions} options */
|
|
13
12
|
constructor(options) {
|
|
14
13
|
super(options);
|
|
@@ -126,7 +125,6 @@ module.exports = class CLIHost extends CLICommand {
|
|
|
126
125
|
// Notify the user that we are done
|
|
127
126
|
CLI.success.hostDeleted(hostname);
|
|
128
127
|
return void callback();
|
|
129
|
-
|
|
130
128
|
} catch (err) {
|
|
131
129
|
CLI.error.unknown(err.message);
|
|
132
130
|
return void callback(1);
|
|
@@ -261,8 +259,8 @@ module.exports = class CLIHost extends CLICommand {
|
|
|
261
259
|
|
|
262
260
|
// Also rename all instances
|
|
263
261
|
const instances = await enumInstances(objects);
|
|
264
|
-
const instancesToRename =
|
|
265
|
-
: instances.filter(i => i.common.host === oldHostname);
|
|
262
|
+
const instancesToRename =
|
|
263
|
+
oldHostname === undefined ? instances : instances.filter(i => i.common.host === oldHostname);
|
|
266
264
|
if (instancesToRename.length > 0) {
|
|
267
265
|
for (const instance of instancesToRename) {
|
|
268
266
|
// Update each instance object
|
|
@@ -272,14 +270,12 @@ module.exports = class CLIHost extends CLICommand {
|
|
|
272
270
|
CLI.warn.noInstancesFoundOnHost(oldHostname);
|
|
273
271
|
}
|
|
274
272
|
return void callback();
|
|
275
|
-
|
|
276
273
|
} catch (err) {
|
|
277
274
|
CLI.error.unknown(err.message);
|
|
278
275
|
return void callback(1);
|
|
279
276
|
}
|
|
280
277
|
});
|
|
281
278
|
}
|
|
282
|
-
|
|
283
279
|
};
|
|
284
280
|
|
|
285
281
|
/**
|
|
@@ -295,7 +291,8 @@ function changeInstanceHost(objects, instance, newHostname) {
|
|
|
295
291
|
instance.ts = Date.now();
|
|
296
292
|
instance.common.host = newHostname;
|
|
297
293
|
// and save it
|
|
298
|
-
objects
|
|
294
|
+
objects
|
|
295
|
+
.setObjectAsync(instance._id, instance)
|
|
299
296
|
.then(() => {
|
|
300
297
|
CLI.success.instanceHostChanged(instance._id, oldInstanceHost, newHostname);
|
|
301
298
|
resolve();
|
package/lib/cli/cliLogs.js
CHANGED
|
@@ -10,7 +10,6 @@ const { tools } = require('@iobroker/js-controller-common');
|
|
|
10
10
|
|
|
11
11
|
/** Command ioBroker state ... */
|
|
12
12
|
module.exports = class CLILogs extends CLICommand {
|
|
13
|
-
|
|
14
13
|
/** @param {import('./cliCommand').CLICommandOptions} options */
|
|
15
14
|
constructor(options) {
|
|
16
15
|
super(options);
|
|
@@ -24,7 +23,6 @@ module.exports = class CLILogs extends CLICommand {
|
|
|
24
23
|
* @param {any[]} args
|
|
25
24
|
*/
|
|
26
25
|
execute(args, params) {
|
|
27
|
-
|
|
28
26
|
/** @type {string | undefined} */
|
|
29
27
|
const adapterName = args[0];
|
|
30
28
|
const watch = params.watch || params.w;
|
|
@@ -36,7 +34,7 @@ module.exports = class CLILogs extends CLICommand {
|
|
|
36
34
|
};
|
|
37
35
|
|
|
38
36
|
const config = fs.readJSONSync(require.resolve(getConfigFileName()));
|
|
39
|
-
const logger = require('
|
|
37
|
+
const logger = require('@iobroker/js-controller-common').logger(config.log);
|
|
40
38
|
let fileName = logger.getFileName();
|
|
41
39
|
if (fileName) {
|
|
42
40
|
let lines = fs.readFileSync(fileName).toString('utf-8').split('\n');
|
|
@@ -60,10 +58,10 @@ module.exports = class CLILogs extends CLICommand {
|
|
|
60
58
|
fileName = fileName.replace(/\\/g, '/');
|
|
61
59
|
const parts = fileName.split('/');
|
|
62
60
|
parts.pop();
|
|
63
|
-
chokidar
|
|
61
|
+
chokidar
|
|
62
|
+
.watch(`${parts.join('/')}/iobroker*`, { awaitWriteFinish: { stabilityThreshold: 500 } })
|
|
64
63
|
.on('all', this.watchHandler.bind(this, options))
|
|
65
|
-
.on('ready', () => this.isReady = true)
|
|
66
|
-
;
|
|
64
|
+
.on('ready', () => (this.isReady = true));
|
|
67
65
|
}
|
|
68
66
|
} else {
|
|
69
67
|
console.log('No log file found');
|
|
@@ -86,12 +84,7 @@ module.exports = class CLILogs extends CLICommand {
|
|
|
86
84
|
watchHandler(options, event, path, stats) {
|
|
87
85
|
if (event === 'add' || !this.fileSizes.has(path)) {
|
|
88
86
|
this.fileSizes.set(path, stats.size);
|
|
89
|
-
if (
|
|
90
|
-
stats.size > 0 && (
|
|
91
|
-
this.isReady
|
|
92
|
-
|| (options.complete && this.isTodaysLogfile(path))
|
|
93
|
-
)
|
|
94
|
-
) {
|
|
87
|
+
if (stats.size > 0 && (this.isReady || (options.complete && this.isTodaysLogfile(path)))) {
|
|
95
88
|
this.streamChange(path, 0, options);
|
|
96
89
|
}
|
|
97
90
|
} else if (event === 'change') {
|
|
@@ -111,7 +104,7 @@ module.exports = class CLILogs extends CLICommand {
|
|
|
111
104
|
*/
|
|
112
105
|
isTodaysLogfile(path) {
|
|
113
106
|
const YYYYMMDDDate = new Date().toJSON().slice(0, 10);
|
|
114
|
-
return path.
|
|
107
|
+
return path.includes(YYYYMMDDDate);
|
|
115
108
|
}
|
|
116
109
|
|
|
117
110
|
/**
|
|
@@ -123,7 +116,7 @@ module.exports = class CLILogs extends CLICommand {
|
|
|
123
116
|
streamChange(path, start, options) {
|
|
124
117
|
const input = fs.createReadStream(path, {
|
|
125
118
|
encoding: 'utf8',
|
|
126
|
-
start
|
|
119
|
+
start,
|
|
127
120
|
autoClose: true
|
|
128
121
|
});
|
|
129
122
|
if (options.adapterName) {
|
|
@@ -131,14 +124,12 @@ module.exports = class CLILogs extends CLICommand {
|
|
|
131
124
|
input
|
|
132
125
|
.pipe(es.split())
|
|
133
126
|
// @ts-ignore
|
|
134
|
-
.pipe(es.filterSync(line => line.
|
|
127
|
+
.pipe(es.filterSync(line => line.includes(options.adapterName)))
|
|
135
128
|
.pipe(es.mapSync(line => line + os.EOL))
|
|
136
|
-
.pipe(process.stdout)
|
|
137
|
-
;
|
|
129
|
+
.pipe(process.stdout);
|
|
138
130
|
} else {
|
|
139
131
|
// just pipe the input through
|
|
140
132
|
tools.pipeLinewise(input, process.stdout);
|
|
141
133
|
}
|
|
142
134
|
}
|
|
143
135
|
};
|
|
144
|
-
|
package/lib/cli/cliMessage.js
CHANGED
|
@@ -6,7 +6,6 @@ const { enumInstances } = require('./cliTools');
|
|
|
6
6
|
|
|
7
7
|
/** Command iobroker object ... */
|
|
8
8
|
module.exports = class CLIMessage extends CLICommand {
|
|
9
|
-
|
|
10
9
|
/** @param {import('./cliCommand').CLICommandOptions} options */
|
|
11
10
|
constructor(options) {
|
|
12
11
|
super(options);
|
|
@@ -19,8 +18,7 @@ module.exports = class CLIMessage extends CLICommand {
|
|
|
19
18
|
execute(args) {
|
|
20
19
|
const { callback, dbConnect, showHelp } = this.options;
|
|
21
20
|
/** @type {[string, string, any?]} */
|
|
22
|
-
|
|
23
|
-
let [adapter, command, message] = (args);
|
|
21
|
+
let [adapter, command, message] = args;
|
|
24
22
|
if (adapter === null || adapter === undefined) {
|
|
25
23
|
CLI.error.requiredArgumentMissing('adapter');
|
|
26
24
|
showHelp();
|
|
@@ -37,11 +35,7 @@ module.exports = class CLIMessage extends CLICommand {
|
|
|
37
35
|
}
|
|
38
36
|
// Try to parse JSON
|
|
39
37
|
// TODO: can we use the methods from cliObjects?
|
|
40
|
-
if (
|
|
41
|
-
typeof message === 'string'
|
|
42
|
-
&& message.startsWith('{')
|
|
43
|
-
&& message.endsWith('}')
|
|
44
|
-
) {
|
|
38
|
+
if (typeof message === 'string' && message.startsWith('{') && message.endsWith('}')) {
|
|
45
39
|
message = JSON.parse(message);
|
|
46
40
|
}
|
|
47
41
|
|
|
@@ -68,12 +62,9 @@ module.exports = class CLIMessage extends CLICommand {
|
|
|
68
62
|
}
|
|
69
63
|
|
|
70
64
|
// Send the message to all targets
|
|
71
|
-
const messagePromises = messageTargets.map(
|
|
72
|
-
t => sendMessage(states, t, command, message)
|
|
73
|
-
);
|
|
65
|
+
const messagePromises = messageTargets.map(t => sendMessage(states, t, command, message));
|
|
74
66
|
await Promise.all(messagePromises);
|
|
75
67
|
return void callback();
|
|
76
|
-
|
|
77
68
|
} catch (err) {
|
|
78
69
|
CLI.error.unknown(err.message);
|
|
79
70
|
return void callback(1);
|