@iobroker/js-controller-cli 4.0.23 → 4.1.0-alpha.0-20220823-bd606e5c
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/build/index.d.ts +87 -0
- package/{index.js → build/index.js} +8 -2
- package/build/lib/cli/cliCert.d.ts +16 -0
- package/build/lib/cli/cliCert.d.ts.map +1 -0
- package/{lib → build/lib}/cli/cliCert.js +6 -10
- package/build/lib/cli/cliCert.js.map +1 -0
- package/build/lib/cli/cliCommand.d.ts +41 -0
- package/build/lib/cli/cliCommand.d.ts.map +1 -0
- package/build/lib/cli/cliCommand.js +27 -0
- package/build/lib/cli/cliCommand.js.map +1 -0
- package/build/lib/cli/cliCompact.d.ts +26 -0
- package/build/lib/cli/cliCompact.d.ts.map +1 -0
- package/{lib → build/lib}/cli/cliCompact.js +24 -44
- package/build/lib/cli/cliCompact.js.map +1 -0
- package/build/lib/cli/cliDebug.d.ts +19 -0
- package/build/lib/cli/cliDebug.d.ts.map +1 -0
- package/{lib → build/lib}/cli/cliDebug.js +7 -14
- package/build/lib/cli/cliDebug.js.map +1 -0
- package/build/lib/cli/cliHost.d.ts +36 -0
- package/build/lib/cli/cliHost.d.ts.map +1 -0
- package/{lib → build/lib}/cli/cliHost.js +23 -48
- package/build/lib/cli/cliHost.js.map +1 -0
- package/build/lib/cli/cliLogs.d.ts +58 -0
- package/build/lib/cli/cliLogs.d.ts.map +1 -0
- package/{lib → build/lib}/cli/cliLogs.js +17 -21
- package/build/lib/cli/cliLogs.js.map +1 -0
- package/build/lib/cli/cliMessage.d.ts +10 -0
- package/build/lib/cli/cliMessage.d.ts.map +1 -0
- package/{lib → build/lib}/cli/cliMessage.js +6 -9
- package/build/lib/cli/cliMessage.js.map +1 -0
- package/build/lib/cli/cliObjects.d.ts +105 -0
- package/build/lib/cli/cliObjects.d.ts.map +1 -0
- package/{lib → build/lib}/cli/cliObjects.js +70 -111
- package/build/lib/cli/cliObjects.js.map +1 -0
- package/build/lib/cli/cliPlugin.d.ts +23 -0
- package/build/lib/cli/cliPlugin.d.ts.map +1 -0
- package/{lib → build/lib}/cli/cliPlugin.js +25 -51
- package/build/lib/cli/cliPlugin.js.map +1 -0
- package/build/lib/cli/cliProcess.d.ts +50 -0
- package/build/lib/cli/cliProcess.d.ts.map +1 -0
- package/{lib → build/lib}/cli/cliProcess.js +51 -63
- package/build/lib/cli/cliProcess.js.map +1 -0
- package/build/lib/cli/cliStates.d.ts +49 -0
- package/build/lib/cli/cliStates.d.ts.map +1 -0
- package/{lib → build/lib}/cli/cliStates.js +127 -122
- package/build/lib/cli/cliStates.js.map +1 -0
- package/build/lib/cli/cliTools.d.ts +64 -0
- package/build/lib/cli/cliTools.d.ts.map +1 -0
- package/{lib → build/lib}/cli/cliTools.js +37 -49
- package/build/lib/cli/cliTools.js.map +1 -0
- package/build/lib/cli/messages.d.ts +53 -0
- package/build/lib/cli/messages.d.ts.map +1 -0
- package/{lib → build/lib}/cli/messages.js +27 -66
- package/build/lib/cli/messages.js.map +1 -0
- package/build/lib/setup/setupBackup.d.ts +126 -0
- package/build/lib/setup/setupBackup.d.ts.map +1 -0
- package/build/lib/setup/setupBackup.js +1031 -0
- package/build/lib/setup/setupBackup.js.map +1 -0
- package/build/lib/setup/setupInstall.d.ts +23 -0
- package/build/lib/setup/setupInstall.d.ts.map +1 -0
- package/build/lib/setup/setupInstall.js +1620 -0
- package/build/lib/setup/setupInstall.js.map +1 -0
- package/build/lib/setup/setupList.d.ts +49 -0
- package/build/lib/setup/setupList.d.ts.map +1 -0
- package/build/lib/setup/setupList.js +722 -0
- package/build/lib/setup/setupList.js.map +1 -0
- package/build/lib/setup/setupPacketManager.d.ts +65 -0
- package/build/lib/setup/setupPacketManager.d.ts.map +1 -0
- package/build/lib/setup/setupPacketManager.js +216 -0
- package/build/lib/setup/setupPacketManager.js.map +1 -0
- package/build/lib/setup/setupUpload.d.ts +72 -0
- package/build/lib/setup/setupUpload.d.ts.map +1 -0
- package/build/lib/setup/setupUpload.js +784 -0
- package/build/lib/setup/setupUpload.js.map +1 -0
- package/package.json +18 -11
- package/lib/cli/cliCommand.js +0 -58
- package/lib/setup/setupList.js +0 -840
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enumObjects = exports.enumHosts = exports.enumInstances = exports.getInstanceName = exports.splitAdapterOrInstanceIdentifierWithVersion = exports.validateAdapterOrInstanceIdentifier = exports.validateAdapterIdentifier = exports.normalizeAdapterName = exports.getObjectFrom = exports.formatValue = void 0;
|
|
4
|
+
const js_controller_common_1 = require("@iobroker/js-controller-common");
|
|
4
5
|
/**
|
|
5
6
|
*
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
7
|
+
* @param val The value to format for output
|
|
8
|
+
* @param pretty Whether it should be pretty-printed
|
|
8
9
|
*/
|
|
9
|
-
function formatValue(val, pretty) {
|
|
10
|
+
function formatValue(val, pretty = false) {
|
|
10
11
|
// Only use JSON.stringify if we need it (for objects and arrays)
|
|
11
|
-
const needsStringify = tools.isObject(val) || tools.isArray(val);
|
|
12
|
+
const needsStringify = js_controller_common_1.tools.isObject(val) || js_controller_common_1.tools.isArray(val);
|
|
12
13
|
const output = !needsStringify ? val : pretty ? JSON.stringify(val, null, 2) : JSON.stringify(val);
|
|
13
14
|
return output;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
+
exports.formatValue = formatValue;
|
|
16
17
|
/** Returns the "from" property for objects changed by the CLI */
|
|
17
18
|
function getObjectFrom() {
|
|
18
|
-
return `system.host.${tools.getHostName()}.cli`;
|
|
19
|
+
return `system.host.${js_controller_common_1.tools.getHostName()}.cli`;
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
+
exports.getObjectFrom = getObjectFrom;
|
|
21
22
|
/**
|
|
22
23
|
* Removes <tools.appName> from the start of the adapter name if it is there
|
|
23
24
|
* E.g. iobroker.admin -> admin
|
|
24
|
-
* @param
|
|
25
|
+
* @param name The adapter name to normalize
|
|
25
26
|
*/
|
|
26
27
|
function normalizeAdapterName(name) {
|
|
27
28
|
if (typeof name === 'string') {
|
|
28
|
-
name = name.replace(new RegExp(`^${tools.appName}\\.`, 'i'), '');
|
|
29
|
+
name = name.replace(new RegExp(`^${js_controller_common_1.tools.appName}\\.`, 'i'), '');
|
|
29
30
|
}
|
|
30
31
|
return name;
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
exports.normalizeAdapterName = normalizeAdapterName;
|
|
33
34
|
/**
|
|
34
35
|
* Ensures that the given string is a valid adapter identifier (<adaptername>) WITHOUT instance number
|
|
35
|
-
* @param
|
|
36
|
+
* @param name The name which is supposed to be an adapter identifier
|
|
36
37
|
*/
|
|
37
38
|
function validateAdapterIdentifier(name) {
|
|
38
39
|
return /^[a-z0-9\-_]+$/.test(name);
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
+
exports.validateAdapterIdentifier = validateAdapterIdentifier;
|
|
41
42
|
/**
|
|
42
43
|
* Ensures that the given string contains a valid identifier for
|
|
43
44
|
* an adapter (without instance number) or instance (with instance number)
|
|
44
|
-
* @param
|
|
45
|
+
* @param name
|
|
45
46
|
*/
|
|
46
47
|
function validateAdapterOrInstanceIdentifier(name) {
|
|
47
48
|
return /^[a-z0-9\-_]+(\.\d+)?$/.test(name);
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
+
exports.validateAdapterOrInstanceIdentifier = validateAdapterOrInstanceIdentifier;
|
|
50
51
|
/**
|
|
51
52
|
* Ensures that the given string contains a valid identifier for
|
|
52
53
|
* an adapter (without instance number) or instance (with instance number)
|
|
53
|
-
* @param
|
|
54
|
-
* @return {{name: string, instance:string|null, version: string|null, nameWithVersion:string}|null}
|
|
54
|
+
* @param name
|
|
55
55
|
*/
|
|
56
56
|
function splitAdapterOrInstanceIdentifierWithVersion(name) {
|
|
57
57
|
const res = name.match(/^([a-z0-9\-_]+)\.?(\d+)?@?([a-z0-9\-_.]*)?$/);
|
|
@@ -65,53 +65,52 @@ function splitAdapterOrInstanceIdentifierWithVersion(name) {
|
|
|
65
65
|
nameWithVersion: `${res[1]}${res[3] ? '@' + res[3] : ''}`
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
exports.splitAdapterOrInstanceIdentifierWithVersion = splitAdapterOrInstanceIdentifierWithVersion;
|
|
69
69
|
/**
|
|
70
70
|
* Extracts the instance name from an object ID
|
|
71
|
-
* @param
|
|
71
|
+
* @param instanceObjID The ID of the instance object
|
|
72
72
|
*/
|
|
73
73
|
function getInstanceName(instanceObjID) {
|
|
74
74
|
return instanceObjID.replace(/^system\.adapter\./i, '');
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
exports.getInstanceName = getInstanceName;
|
|
77
77
|
/**
|
|
78
78
|
* Enumerates the instances of an adapter or all of them
|
|
79
|
-
* @param
|
|
80
|
-
* @param
|
|
81
|
-
* @returns
|
|
79
|
+
* @param objects The objects DB to use
|
|
80
|
+
* @param adapter (optional) The adapter whose instances should be enumerated
|
|
81
|
+
* @returns An array of instance objects
|
|
82
82
|
*/
|
|
83
83
|
async function enumInstances(objects, adapter) {
|
|
84
84
|
// if no adapter given all instances should be returned
|
|
85
85
|
const startkey = `system.adapter.${adapter ? `${adapter}.` : ''}`;
|
|
86
86
|
const data = await enumObjects(objects, 'instance', startkey);
|
|
87
87
|
// because of startkey logic not only receive objects with the dot at the end, so filter them!
|
|
88
|
-
return data.filter(it => it._id.startsWith(startkey));
|
|
88
|
+
return data.filter(it => it && it._id.startsWith(startkey));
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
exports.enumInstances = enumInstances;
|
|
91
91
|
/**
|
|
92
92
|
* Enumerates all known hosts
|
|
93
|
-
* @param
|
|
94
|
-
* @returns
|
|
93
|
+
* @param objects The objects DB to use
|
|
94
|
+
* @returns An array of host objects
|
|
95
95
|
*/
|
|
96
96
|
function enumHosts(objects) {
|
|
97
97
|
return enumObjects(objects, 'host', 'system.host.');
|
|
98
98
|
}
|
|
99
|
-
|
|
99
|
+
exports.enumHosts = enumHosts;
|
|
100
100
|
/**
|
|
101
101
|
* Enumerates all objects of a given type
|
|
102
|
-
* @param
|
|
103
|
-
* @param
|
|
104
|
-
* @param
|
|
105
|
-
* @returns {Promise<object[]>}
|
|
102
|
+
* @param objects The objects DB to use
|
|
103
|
+
* @param type The type of the objects to enumerate
|
|
104
|
+
* @param startkey The prefix of the objects
|
|
106
105
|
*/
|
|
107
106
|
function enumObjects(objects, type, startkey) {
|
|
108
107
|
return new Promise((resolve, reject) => {
|
|
109
|
-
const endkey = startkey
|
|
108
|
+
const endkey = `${startkey}\u9999`;
|
|
109
|
+
// @ts-expect-error #1917
|
|
110
110
|
objects.getObjectView('system', type, { startkey, endkey }, null, (err, res) => {
|
|
111
111
|
if (err) {
|
|
112
112
|
return reject(err);
|
|
113
113
|
}
|
|
114
|
-
|
|
115
114
|
let ret = [];
|
|
116
115
|
if (res && res.rows) {
|
|
117
116
|
ret = res.rows.map(row => row.value);
|
|
@@ -120,16 +119,5 @@ function enumObjects(objects, type, startkey) {
|
|
|
120
119
|
});
|
|
121
120
|
});
|
|
122
121
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
formatValue,
|
|
126
|
-
getObjectFrom,
|
|
127
|
-
normalizeAdapterName,
|
|
128
|
-
validateAdapterIdentifier,
|
|
129
|
-
validateAdapterOrInstanceIdentifier,
|
|
130
|
-
splitAdapterOrInstanceIdentifierWithVersion,
|
|
131
|
-
getInstanceName,
|
|
132
|
-
enumInstances,
|
|
133
|
-
enumHosts,
|
|
134
|
-
enumObjects
|
|
135
|
-
};
|
|
122
|
+
exports.enumObjects = enumObjects;
|
|
123
|
+
//# sourceMappingURL=cliTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cliTools.js","sourceRoot":"","sources":["../../../src/lib/cli/cliTools.ts"],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ACtB,IAAO,EACP,QAAgB;IAEhB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,MAAM,MAAM,GAAG,GAAG,QAAQ,QAAQ,CAAC;QACnC,yBAAyB;QACzB,OAAO,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YAC3E,IAAI,GAAG,EAAE;gBACL,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;aACtB;YAED,IAAI,GAAG,GAAgE,EAAE,CAAC;YAC1E,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE;gBACjB,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;aACxC;YACD,OAAO,CAAC,GAAG,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC;AApBD,kCAoBC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export const success: Readonly<{
|
|
2
|
+
objectUpdated: (objectID: any) => string;
|
|
3
|
+
objectDeleted: (objectID: any) => string;
|
|
4
|
+
stateUpdated: (stateID: string, value: any, ack: boolean | undefined) => string;
|
|
5
|
+
stateDeleted: (stateID: any) => string;
|
|
6
|
+
adapterStarted: (adapter: any) => string;
|
|
7
|
+
adapterStopped: (adapter: any) => string;
|
|
8
|
+
adapterRestarted: (adapter: any) => string;
|
|
9
|
+
systemStatus: (isRunning: any) => string;
|
|
10
|
+
controllerStatus: (isRunning: any) => string;
|
|
11
|
+
messageSent: (adapter: string, command: string, message: any) => string;
|
|
12
|
+
hostRenamed: (from: string, to: string) => string;
|
|
13
|
+
instanceHostChanged: (instance: string, from: string, to: string) => string;
|
|
14
|
+
hostDeleted: (hostname: any) => string;
|
|
15
|
+
pluginEnabledOrDisabled: (pluginName: any, host: any, instance: any, status: any) => string;
|
|
16
|
+
pluginStatus: (pluginName: any, host: any, instance: any, status: any) => string;
|
|
17
|
+
}>;
|
|
18
|
+
export const warn: Readonly<{
|
|
19
|
+
noInstancesFoundOnHost: (hostname: any) => string;
|
|
20
|
+
}>;
|
|
21
|
+
export const error: Readonly<{
|
|
22
|
+
stateNotFound: (stateID: string, error: string | null) => string;
|
|
23
|
+
stateNotBinary: (stateId: string) => string;
|
|
24
|
+
stateBinaryGetUnsupported: (stateId: string) => string;
|
|
25
|
+
stateBinarySetUnsupported: (stateId: string) => string;
|
|
26
|
+
objectNotFound: (objectID: string, error: string | null) => string;
|
|
27
|
+
cannotUpdateObject: (objectID: string, error: string | null) => string;
|
|
28
|
+
cannotDeleteObject: (objectID: string, error: string | null) => string;
|
|
29
|
+
cannotDeleteObjectFromEnums: (objectID: string, error: string | null) => string;
|
|
30
|
+
cannotChangeObject: (objectID: string, error: string | null) => string;
|
|
31
|
+
objectPropertyNotFound: (objectID: string, propPath: string) => string;
|
|
32
|
+
invalidPropertyOrValue: () => "The property path or value is not valid. Please make sure the value is valid JSON.";
|
|
33
|
+
invalidJSONValue: () => "The given value is not valid JSON.";
|
|
34
|
+
unknownCommand: (prefix: string, command: string) => string;
|
|
35
|
+
requiredArgumentMissing: (argName: string, exampleCommand: string | null) => string;
|
|
36
|
+
noInstancesFound: (adapter: any) => string;
|
|
37
|
+
invalidInstance: (instance: any) => string;
|
|
38
|
+
specifyInstance: (adapter: string, adapterInstances: Array<string> | null) => string;
|
|
39
|
+
adapterDirNotFound: (adapter: any) => string;
|
|
40
|
+
mainFileNotFound: (adapter: any) => string;
|
|
41
|
+
cannotLoadIoPackage: (adapter: any) => string;
|
|
42
|
+
wrongCommandPrefix: (wrongPrefix: string, command: string, correctPrefix: string | null) => string;
|
|
43
|
+
unknown: (err: any) => string;
|
|
44
|
+
cannotChangeRunningSystem: () => string;
|
|
45
|
+
noHostThisInMultihost: () => "Cannot use this command in multihost!";
|
|
46
|
+
hostAlreadyExists: (hostname: any) => string;
|
|
47
|
+
hostDoesNotExist: (hostname: any) => string;
|
|
48
|
+
dontRemoveCurrentHost: (hostname: any) => string;
|
|
49
|
+
pluginNotDefined: (pluginName: any, host: any, instance: any) => string;
|
|
50
|
+
cert: (certName: any) => string;
|
|
51
|
+
instanceAlreadyRunning: (instance: any) => string;
|
|
52
|
+
}>;
|
|
53
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/lib/cli/messages.js"],"names":[],"mappings":";;;4BAmE8B,MAAM,SAAyB,GAAG,OAAuB,OAAO,GAAG,SAAS;;;;;;;2BAS7E,MAAM,WAAyB,MAAM,WAAyB,GAAG;wBAEjE,MAAM,MAAsB,MAAM;oCAE1B,MAAM,QAA0B,MAAM,MAAsB,MAAM;;;;;;;;;6BA5ExE,MAAM,SAAyB,MAAM;8BAEpC,MAAM;yCACK,MAAM;yCAEN,MAAM;+BAEjB,MAAM,SAA0B,MAAM;mCAElC,MAAM,SAA0B,MAAM;mCAEtC,MAAM,SAA0B,MAAM;4CAE7B,MAAM,SAA0B,MAAM;mCAE/C,MAAM,SAA0B,MAAM;uCAElC,MAAM,YAA0B,MAAM;;;6BAK9C,MAAM,WAAwB,MAAM;uCAE3B,MAAM,kBAAyB,MAAM;;;+BAK7C,MAAM,oBAAyB,MAAM,MAAM,CAAC;;;;sCAS1D,MAAM,WACN,MAAM,iBACN,MAAM"}
|
|
@@ -1,102 +1,62 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
const { tools } = require('@iobroker/js-controller-common');
|
|
3
|
-
|
|
4
3
|
const errorMessages = Object.freeze({
|
|
5
|
-
stateNotFound: (/** @type {string} */ stateID, /** @type {string?} */ error) =>
|
|
6
|
-
`The state ${stateID} was not found!` + (error ? ` Reason: ${error}` : ''),
|
|
4
|
+
stateNotFound: (/** @type {string} */ stateID, /** @type {string?} */ error) => `The state ${stateID} was not found!` + (error ? ` Reason: ${error}` : ''),
|
|
7
5
|
stateNotBinary: (/** @type {string} */ stateId) => `State "${stateId}" is not binary.`,
|
|
8
|
-
stateBinaryGetUnsupported: (/** @type {string} */ stateId) =>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
cannotDeleteObject: (/** @type {string} */ objectID, /** @type {string?} */ error) =>
|
|
17
|
-
`The object ${objectID} cannot be deleted!` + (error ? ` Reason: ${error}` : ''),
|
|
18
|
-
cannotDeleteObjectFromEnums: (/** @type {string} */ objectID, /** @type {string?} */ error) =>
|
|
19
|
-
`The object ${objectID} could not be deleted from enums!` + (error ? ` Reason: ${error}` : ''),
|
|
20
|
-
cannotChangeObject: (/** @type {string} */ objectID, /** @type {string?} */ error) =>
|
|
21
|
-
`The object ${objectID} cannot be changed!` + (error ? ` Reason: ${error}` : ''),
|
|
22
|
-
objectPropertyNotFound: (/** @type {string} */ objectID, /** @type {string} */ propPath) =>
|
|
23
|
-
`The requested property "${propPath}" or one of its parents was not found in the object "${objectID}"!`,
|
|
6
|
+
stateBinaryGetUnsupported: (/** @type {string} */ stateId) => `State "${stateId}" is a binary state, please use getBinary.`,
|
|
7
|
+
stateBinarySetUnsupported: (/** @type {string} */ stateId) => `State "${stateId}" is a binary state and cannot be set via cli.`,
|
|
8
|
+
objectNotFound: (/** @type {string} */ objectID, /** @type {string?} */ error) => `The object ${objectID} was not found!` + (error ? ` Reason: ${error}` : ''),
|
|
9
|
+
cannotUpdateObject: (/** @type {string} */ objectID, /** @type {string?} */ error) => `The object ${objectID} could not be updated!` + (error ? ` Reason: ${error}` : ''),
|
|
10
|
+
cannotDeleteObject: (/** @type {string} */ objectID, /** @type {string?} */ error) => `The object ${objectID} cannot be deleted!` + (error ? ` Reason: ${error}` : ''),
|
|
11
|
+
cannotDeleteObjectFromEnums: (/** @type {string} */ objectID, /** @type {string?} */ error) => `The object ${objectID} could not be deleted from enums!` + (error ? ` Reason: ${error}` : ''),
|
|
12
|
+
cannotChangeObject: (/** @type {string} */ objectID, /** @type {string?} */ error) => `The object ${objectID} cannot be changed!` + (error ? ` Reason: ${error}` : ''),
|
|
13
|
+
objectPropertyNotFound: (/** @type {string} */ objectID, /** @type {string} */ propPath) => `The requested property "${propPath}" or one of its parents was not found in the object "${objectID}"!`,
|
|
24
14
|
invalidPropertyOrValue: () => `The property path or value is not valid. Please make sure the value is valid JSON.`,
|
|
25
15
|
invalidJSONValue: () => `The given value is not valid JSON.`,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
`Unknown command "${prefix} ${command}"!`,
|
|
29
|
-
requiredArgumentMissing: (/** @type {string} */ argName, /** @type {string?} */ exampleCommand) =>
|
|
30
|
-
`The required argument "${argName}" is missing!` + (exampleCommand ? ` Example: "${exampleCommand}"` : ''),
|
|
31
|
-
|
|
16
|
+
unknownCommand: (/** @type {string} */ prefix, /** @type {string} */ command) => `Unknown command "${prefix} ${command}"!`,
|
|
17
|
+
requiredArgumentMissing: (/** @type {string} */ argName, /** @type {string?} */ exampleCommand) => `The required argument "${argName}" is missing!` + (exampleCommand ? ` Example: "${exampleCommand}"` : ''),
|
|
32
18
|
noInstancesFound: adapter => `Cannot find any instances of "${adapter}"!`,
|
|
33
19
|
invalidInstance: instance => `The instance "${instance}" does not exist!`,
|
|
34
|
-
specifyInstance: (/** @type {string} */ adapter, /** @type {Array<string>?} */ adapterInstances) =>
|
|
35
|
-
`The adapter "${adapter}" has multiple instances! Please specify which one should be started: "${adapterInstances.join(
|
|
36
|
-
'", "'
|
|
37
|
-
)}".`,
|
|
20
|
+
specifyInstance: (/** @type {string} */ adapter, /** @type {Array<string>?} */ adapterInstances) => `The adapter "${adapter}" has multiple instances! Please specify which one should be started: "${adapterInstances.join('", "')}".`,
|
|
38
21
|
adapterDirNotFound: adapter => `Cannot find the installation dir for adapter "${adapter}"!`,
|
|
39
22
|
mainFileNotFound: adapter => `Cannot find the main file for adapter "${adapter}"!`,
|
|
40
23
|
cannotLoadIoPackage: adapter => `Cannot load the io-package.json file for adapter "${adapter}"!`,
|
|
41
|
-
|
|
42
24
|
wrongCommandPrefix: (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
? `Please use "${correctPrefix} ${command}" instead.`
|
|
49
|
-
: '',
|
|
25
|
+
/** @type {string} */ wrongPrefix,
|
|
26
|
+
/** @type {string} */ command,
|
|
27
|
+
/** @type {string?} */ correctPrefix) => `The command ${command} is not intended to be used with ${wrongPrefix}!` + correctPrefix
|
|
28
|
+
? `Please use "${correctPrefix} ${command}" instead.`
|
|
29
|
+
: '',
|
|
50
30
|
unknown: err => `An unknown error occurred: ${err}`,
|
|
51
|
-
|
|
52
31
|
cannotChangeRunningSystem: () => `Cannot execute changes on running system. Stop ${tools.appName} first.`,
|
|
53
32
|
noHostThisInMultihost: () => `Cannot use this command in multihost!`,
|
|
54
33
|
hostAlreadyExists: hostname => `A host with the name "${hostname}" already exists!`,
|
|
55
34
|
hostDoesNotExist: hostname => `The host "${hostname}" does not exist!`,
|
|
56
35
|
dontRemoveCurrentHost: hostname => `Cannot remove host "${hostname}" from itself!`,
|
|
57
|
-
|
|
58
|
-
pluginNotDefined: (pluginName, host, instance) =>
|
|
59
|
-
`The plugin "${pluginName}" does not exist for ${host ? `host "${host}"` : `instance "${instance}"`}!`,
|
|
60
|
-
|
|
36
|
+
pluginNotDefined: (pluginName, host, instance) => `The plugin "${pluginName}" does not exist for ${host ? `host "${host}"` : `instance "${instance}"`}!`,
|
|
61
37
|
cert: certName => `Certificate "${certName}" not found or error parsing certificate information.`,
|
|
62
38
|
instanceAlreadyRunning: instance => `The instance "${instance}" is already running, please stop instance first.`
|
|
63
39
|
});
|
|
64
|
-
|
|
65
40
|
const successMessages = Object.freeze({
|
|
66
41
|
objectUpdated: objectID => `The object "${objectID}" was updated successfully.`,
|
|
67
42
|
objectDeleted: objectID => `The object "${objectID}" was deleted.`,
|
|
68
|
-
stateUpdated: (/** @type {string} */ stateID, /** @type {any} */ value, /** @type {boolean | undefined} */ ack) =>
|
|
69
|
-
`The state "${stateID}" was set to "${value}"${ack === undefined ? '' : ` with flag ack=${ack}`}`,
|
|
43
|
+
stateUpdated: (/** @type {string} */ stateID, /** @type {any} */ value, /** @type {boolean | undefined} */ ack) => `The state "${stateID}" was set to "${value}"${ack === undefined ? '' : ` with flag ack=${ack}`}`,
|
|
70
44
|
stateDeleted: stateID => `The state "${stateID}" was deleted.`,
|
|
71
45
|
adapterStarted: adapter => `The adapter "${adapter}" was started.`,
|
|
72
46
|
adapterStopped: adapter => `The adapter "${adapter}" was stopped.`,
|
|
73
47
|
adapterRestarted: adapter => `The adapter "${adapter}" was restarted.`,
|
|
74
|
-
systemStatus: isRunning =>
|
|
75
|
-
isRunning ? `At least one ${tools.appName} host is running.` : `No ${tools.appName} host is running.`,
|
|
48
|
+
systemStatus: isRunning => isRunning ? `At least one ${tools.appName} host is running.` : `No ${tools.appName} host is running.`,
|
|
76
49
|
controllerStatus: isRunning => `${tools.appName} is ${isRunning ? '' : 'not '}running on this host.`,
|
|
77
|
-
messageSent: (/** @type {string} */ adapter, /** @type {string} */ command, /** @type {any} */ message) =>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
`Host "${from}" successfully renamed to "${to}".`,
|
|
81
|
-
instanceHostChanged: (/** @type {string} */ instance, /** @type {string} */ from, /** @type {string} */ to) =>
|
|
82
|
-
`The host for instance "${instance}" was changed from "${from}" to "${to}".`,
|
|
50
|
+
messageSent: (/** @type {string} */ adapter, /** @type {string} */ command, /** @type {any} */ message) => `The command "${command}" was sent to "${adapter}" with the message "${message}".`,
|
|
51
|
+
hostRenamed: (/** @type {string} */ from, /** @type {string} */ to) => `Host "${from}" successfully renamed to "${to}".`,
|
|
52
|
+
instanceHostChanged: (/** @type {string} */ instance, /** @type {string} */ from, /** @type {string} */ to) => `The host for instance "${instance}" was changed from "${from}" to "${to}".`,
|
|
83
53
|
hostDeleted: hostname => `The host "${hostname}" was deleted.`,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
`The plugin "${pluginName}" was successfully ${status ? 'enabled' : 'disabled'} for ${
|
|
87
|
-
host ? `host "${host}"` : `instance "${instance}"`
|
|
88
|
-
}.`,
|
|
89
|
-
pluginStatus: (pluginName, host, instance, status) =>
|
|
90
|
-
`The plugin "${pluginName}" is ${status ? 'enabled' : 'disabled'} for ${
|
|
91
|
-
host ? `host "${host}"` : `instance "${instance}"`
|
|
92
|
-
}.`
|
|
54
|
+
pluginEnabledOrDisabled: (pluginName, host, instance, status) => `The plugin "${pluginName}" was successfully ${status ? 'enabled' : 'disabled'} for ${host ? `host "${host}"` : `instance "${instance}"`}.`,
|
|
55
|
+
pluginStatus: (pluginName, host, instance, status) => `The plugin "${pluginName}" is ${status ? 'enabled' : 'disabled'} for ${host ? `host "${host}"` : `instance "${instance}"`}.`
|
|
93
56
|
});
|
|
94
|
-
|
|
95
57
|
const warnings = Object.freeze({
|
|
96
|
-
noInstancesFoundOnHost: hostname =>
|
|
97
|
-
hostname ? `No instances found for host "${hostname}"!` : `No instances found!`
|
|
58
|
+
noInstancesFoundOnHost: hostname => hostname ? `No instances found for host "${hostname}"!` : `No instances found!`
|
|
98
59
|
});
|
|
99
|
-
|
|
100
60
|
// Capsule success messages in console.log
|
|
101
61
|
/** Prints predefined success messages on the CLI */
|
|
102
62
|
module.exports.success = /** @type {typeof successMessages} */ ({});
|
|
@@ -114,3 +74,4 @@ module.exports.error = /** @type {typeof errorMessages} */ ({});
|
|
|
114
74
|
for (const method of Object.keys(errorMessages)) {
|
|
115
75
|
module.exports.error[method] = (...args) => console.error(errorMessages[method](...args));
|
|
116
76
|
}
|
|
77
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/lib/cli/messages.js"],"names":[],"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AA8B;AAC9B,MAAM,CAAC,OAAO,CAAC,IAAI,GAAG,8BAA8B,CAAC,CAAC,EAAE,CAAC,CAAC;AAC1D,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;IACxC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;CACrF;AACD,kCAAkC;AAClC,kDAAkD;AAClD,MAAM,CAAC,OAAO,CAAC,KAAK,GAAG,mCAAmC,CAAC,CAAC,EAAE,CAAC,CAAC;AAChE,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE;IAC7C,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;CAC7F"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backup
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2013-2022 bluefox <dogafox@gmail.com>
|
|
5
|
+
*
|
|
6
|
+
* MIT License
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
import type { Client as StatesRedisClient } from '@iobroker/db-states-redis';
|
|
10
|
+
import type { Client as ObjectsRedisClient } from '@iobroker/db-objects-redis';
|
|
11
|
+
export interface CLIBackupRestoreOptions {
|
|
12
|
+
dbMigration?: boolean;
|
|
13
|
+
states: StatesRedisClient;
|
|
14
|
+
objects: ObjectsRedisClient;
|
|
15
|
+
processExit: (exitCode?: number) => void;
|
|
16
|
+
cleanDatabase: (isDeleteDb: boolean) => any;
|
|
17
|
+
restartController: () => void;
|
|
18
|
+
}
|
|
19
|
+
export declare class BackupRestore {
|
|
20
|
+
private readonly objects;
|
|
21
|
+
private readonly states;
|
|
22
|
+
private readonly processExit;
|
|
23
|
+
private readonly restartController;
|
|
24
|
+
private readonly cleanDatabase;
|
|
25
|
+
private readonly dbMigration;
|
|
26
|
+
/** these adapters will be reinstalled during restore, while others will be installed after next controller start */
|
|
27
|
+
private readonly PRESERVE_ADAPTERS;
|
|
28
|
+
private readonly upload;
|
|
29
|
+
private configParts;
|
|
30
|
+
private readonly configDir;
|
|
31
|
+
constructor(options: CLIBackupRestoreOptions);
|
|
32
|
+
private _copyFile;
|
|
33
|
+
copyDir(id: string, srcPath: string, destPath: string): Promise<void>;
|
|
34
|
+
static getBackupDir(): string;
|
|
35
|
+
copyFileSync(source: string, target: string): void;
|
|
36
|
+
copyFolderRecursiveSync(source: string, target: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Pack and compress the backup
|
|
39
|
+
*
|
|
40
|
+
* @param name - backup name
|
|
41
|
+
*/
|
|
42
|
+
private _packBackup;
|
|
43
|
+
/**
|
|
44
|
+
* Creates backup and stores with given name
|
|
45
|
+
*
|
|
46
|
+
* @param name - name of the backup
|
|
47
|
+
* @param noConfig - do not store configs
|
|
48
|
+
*/
|
|
49
|
+
createBackup(name: string, noConfig?: boolean): Promise<string | void>;
|
|
50
|
+
/**
|
|
51
|
+
* Helper to restore raw states
|
|
52
|
+
*
|
|
53
|
+
* @param statesList - list of state ids
|
|
54
|
+
* @param stateObjects - list of state objects
|
|
55
|
+
*/
|
|
56
|
+
private _setStateHelper;
|
|
57
|
+
/**
|
|
58
|
+
* Sets all objects to the db and disables all adapters
|
|
59
|
+
*
|
|
60
|
+
* @param _objects - array of all objects to be set
|
|
61
|
+
*/
|
|
62
|
+
private _setObjHelper;
|
|
63
|
+
/**
|
|
64
|
+
* Creates all provided object if non existing
|
|
65
|
+
*
|
|
66
|
+
* @param objectList - list of objects to be created
|
|
67
|
+
*/
|
|
68
|
+
private _reloadAdapterObject;
|
|
69
|
+
private _reloadAdaptersObjects;
|
|
70
|
+
private _uploadUserFiles;
|
|
71
|
+
private _copyBackupedFiles;
|
|
72
|
+
/**
|
|
73
|
+
* Restore after controller has been stopped
|
|
74
|
+
*
|
|
75
|
+
* @param restartOnFinish - restart controller after restore
|
|
76
|
+
* @param force - skip the controller version check
|
|
77
|
+
* @param dontDeleteAdapters - skip adapter deletion, e.g. for setup custom db migration
|
|
78
|
+
*/
|
|
79
|
+
private _restoreAfterStop;
|
|
80
|
+
/**
|
|
81
|
+
* Removes all adapters
|
|
82
|
+
*/
|
|
83
|
+
private _removeAllAdapters;
|
|
84
|
+
/**
|
|
85
|
+
* Ensure that installed controller version matches version in backup
|
|
86
|
+
*
|
|
87
|
+
* @param controllerDir - directory of js-controller
|
|
88
|
+
* @param backupHostname - hostname in backup file
|
|
89
|
+
* @param backupObjects - the objects contained in the backup
|
|
90
|
+
* @param force - if force is true, only log
|
|
91
|
+
*/
|
|
92
|
+
private _ensureCompatibility;
|
|
93
|
+
/**
|
|
94
|
+
* Returns all backups as array
|
|
95
|
+
*/
|
|
96
|
+
listBackups(): string[];
|
|
97
|
+
/**
|
|
98
|
+
* Validates the backup.json and all json files inside the backup after (in temporary directory), here we only abort if backup.json is corrupted
|
|
99
|
+
*/
|
|
100
|
+
private _validateBackupAfterCreation;
|
|
101
|
+
/**
|
|
102
|
+
* Validates the given backup.json and all json files in the backup, calls processExit afterwards
|
|
103
|
+
* @param _name - index or name of the backup
|
|
104
|
+
*/
|
|
105
|
+
validateBackup(_name: string | number): Promise<void> | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* Checks a directory for json files and validates them, steps down recursive in subdirectories
|
|
108
|
+
* @param path - path to the directory
|
|
109
|
+
* @param verbose - if logging should be verbose
|
|
110
|
+
*/
|
|
111
|
+
private _checkDirectory;
|
|
112
|
+
/**
|
|
113
|
+
* Restores a backup
|
|
114
|
+
*
|
|
115
|
+
* @param _name - backup name or index
|
|
116
|
+
* @param force - if force, js-controller is allowed to have a different version
|
|
117
|
+
* @param dontDeleteAdapters - skip adapter deletion, e.g. for setup custom db migration
|
|
118
|
+
* @param callback
|
|
119
|
+
*/
|
|
120
|
+
restoreBackup(_name: string | number, force: boolean, dontDeleteAdapters: boolean, callback: (exitCode: number) => void): void;
|
|
121
|
+
/**
|
|
122
|
+
* This method checks if adapter of PRESERVE_ADAPTERS exist, and reinstalls them if this is the case
|
|
123
|
+
*/
|
|
124
|
+
private _restorePreservedAdapters;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=setupBackup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupBackup.d.ts","sourceRoot":"","sources":["../../../src/lib/setup/setupBackup.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,OAAO,KAAK,EAAE,MAAM,IAAI,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,KAAK,EAAE,MAAM,IAAI,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAQ/E,MAAM,WAAW,uBAAuB;IACpC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,EAAE,kBAAkB,CAAC;IAC5B,WAAW,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,aAAa,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,GAAG,CAAC;IAC5C,iBAAiB,EAAE,MAAM,IAAI,CAAC;CACjC;AAQD,qBAAa,aAAa;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAC3C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAyC;IACrE,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA+C;IACjF,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA2C;IACzE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAU;I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