@iobroker/js-controller-cli 7.2.3 → 8.0.0-alpha.2-20260923-99da17fcc
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/cjs/index.js +3 -3
- package/build/cjs/lib/_Types.d.ts +8 -1
- package/build/cjs/lib/cli/cliCert.d.ts +7 -4
- package/build/cjs/lib/cli/cliCert.js +10 -6
- package/build/cjs/lib/cli/cliCert.js.map +2 -2
- package/build/cjs/lib/cli/cliCommand.d.ts +63 -15
- package/build/cjs/lib/cli/cliCommand.js +8 -1
- package/build/cjs/lib/cli/cliCommand.js.map +2 -2
- package/build/cjs/lib/cli/cliCompact.d.ts +5 -2
- package/build/cjs/lib/cli/cliCompact.js +9 -2
- package/build/cjs/lib/cli/cliCompact.js.map +2 -2
- package/build/cjs/lib/cli/cliDebug.d.ts +5 -2
- package/build/cjs/lib/cli/cliDebug.js +8 -1
- package/build/cjs/lib/cli/cliDebug.js.map +2 -2
- package/build/cjs/lib/cli/cliHost.d.ts +13 -10
- package/build/cjs/lib/cli/cliHost.js +13 -5
- package/build/cjs/lib/cli/cliHost.js.map +2 -2
- package/build/cjs/lib/cli/cliLogs.d.ts +9 -3
- package/build/cjs/lib/cli/cliLogs.js +12 -1
- package/build/cjs/lib/cli/cliLogs.js.map +2 -2
- package/build/cjs/lib/cli/cliMessage.d.ts +2 -1
- package/build/cjs/lib/cli/cliMessage.js +5 -0
- package/build/cjs/lib/cli/cliMessage.js.map +2 -2
- package/build/cjs/lib/cli/cliObjects.d.ts +21 -18
- package/build/cjs/lib/cli/cliObjects.js +51 -33
- package/build/cjs/lib/cli/cliObjects.js.map +2 -2
- package/build/cjs/lib/cli/cliPlugin.d.ts +3 -3
- package/build/cjs/lib/cli/cliPlugin.js +6 -0
- package/build/cjs/lib/cli/cliPlugin.js.map +2 -2
- package/build/cjs/lib/cli/cliProcess.d.ts +17 -7
- package/build/cjs/lib/cli/cliProcess.js +77 -24
- package/build/cjs/lib/cli/cliProcess.js.map +3 -3
- package/build/cjs/lib/cli/cliStates.d.ts +7 -4
- package/build/cjs/lib/cli/cliStates.js +14 -6
- package/build/cjs/lib/cli/cliStates.js.map +2 -2
- package/build/cjs/lib/cli/cliTools.js +11 -0
- package/build/cjs/lib/cli/cliTools.js.map +1 -1
- package/build/cjs/lib/cli/messages.js +47 -46
- package/build/cjs/lib/cli/messages.js.map +1 -1
- package/build/cjs/lib/progressBar.d.ts +59 -0
- package/build/cjs/lib/progressBar.js +115 -0
- package/build/cjs/lib/progressBar.js.map +7 -0
- package/build/cjs/lib/setup/customError.d.ts +4 -0
- package/build/cjs/lib/setup/customError.js +7 -0
- package/build/cjs/lib/setup/customError.js.map +2 -2
- package/build/cjs/lib/setup/dbConnection.js +69 -64
- package/build/cjs/lib/setup/dbConnection.js.map +3 -3
- package/build/cjs/lib/setup/formatters.d.ts +4 -4
- package/build/cjs/lib/setup/formatters.js +5 -0
- package/build/cjs/lib/setup/formatters.js.map +2 -2
- package/build/cjs/lib/setup/multihostClient.js +6 -2
- package/build/cjs/lib/setup/multihostClient.js.map +1 -1
- package/build/cjs/lib/setup/pluginInfos.d.ts +5 -0
- package/build/cjs/lib/setup/pluginInfos.js +2 -0
- package/build/cjs/lib/setup/pluginInfos.js.map +2 -2
- package/build/cjs/lib/setup/setupBackup.d.ts +53 -0
- package/build/cjs/lib/setup/setupBackup.js +125 -14
- package/build/cjs/lib/setup/setupBackup.js.map +3 -3
- package/build/cjs/lib/setup/setupInstall.d.ts +66 -15
- package/build/cjs/lib/setup/setupInstall.js +282 -28
- package/build/cjs/lib/setup/setupInstall.js.map +2 -2
- package/build/cjs/lib/setup/setupLicense.d.ts +13 -0
- package/build/cjs/lib/setup/setupLicense.js +33 -2
- package/build/cjs/lib/setup/setupLicense.js.map +2 -2
- package/build/cjs/lib/setup/setupList.d.ts +55 -1
- package/build/cjs/lib/setup/setupList.js +78 -24
- package/build/cjs/lib/setup/setupList.js.map +3 -3
- package/build/cjs/lib/setup/setupMultihost.d.ts +7 -0
- package/build/cjs/lib/setup/setupMultihost.js +78 -11
- package/build/cjs/lib/setup/setupMultihost.js.map +3 -3
- package/build/cjs/lib/setup/setupPacketManager.d.ts +10 -0
- package/build/cjs/lib/setup/setupPacketManager.js +16 -6
- package/build/cjs/lib/setup/setupPacketManager.js.map +2 -2
- package/build/cjs/lib/setup/setupRepo.d.ts +19 -0
- package/build/cjs/lib/setup/setupRepo.js +141 -13
- package/build/cjs/lib/setup/setupRepo.js.map +2 -2
- package/build/cjs/lib/setup/setupSetup.d.ts +34 -0
- package/build/cjs/lib/setup/setupSetup.js +209 -35
- package/build/cjs/lib/setup/setupSetup.js.map +3 -3
- package/build/cjs/lib/setup/setupUpgrade.d.ts +13 -2
- package/build/cjs/lib/setup/setupUpgrade.js +72 -12
- package/build/cjs/lib/setup/setupUpgrade.js.map +2 -2
- package/build/cjs/lib/setup/setupUpload.d.ts +77 -1
- package/build/cjs/lib/setup/setupUpload.js +152 -9
- package/build/cjs/lib/setup/setupUpload.js.map +2 -2
- package/build/cjs/lib/setup/setupUsers.d.ts +44 -14
- package/build/cjs/lib/setup/setupUsers.js +330 -17
- package/build/cjs/lib/setup/setupUsers.js.map +2 -2
- package/build/cjs/lib/setup/setupVendor.d.ts +14 -1
- package/build/cjs/lib/setup/setupVendor.js +40 -8
- package/build/cjs/lib/setup/setupVendor.js.map +2 -2
- package/build/cjs/lib/setup/setupVisDebug.d.ts +16 -2
- package/build/cjs/lib/setup/setupVisDebug.js +41 -17
- package/build/cjs/lib/setup/setupVisDebug.js.map +3 -3
- package/build/cjs/lib/setup/utils.d.ts +1 -1
- package/build/cjs/lib/setup/utils.js +13 -9
- package/build/cjs/lib/setup/utils.js.map +3 -3
- package/build/cjs/lib/setup.d.ts +1 -1
- package/build/cjs/lib/setup.js +858 -1758
- package/build/cjs/lib/setup.js.map +3 -3
- package/build/esm/lib/_Types.d.ts +8 -1
- package/build/esm/lib/_Types.d.ts.map +1 -1
- package/build/esm/lib/cli/cliCert.d.ts +7 -4
- package/build/esm/lib/cli/cliCert.d.ts.map +1 -1
- package/build/esm/lib/cli/cliCert.js +6 -6
- package/build/esm/lib/cli/cliCert.js.map +1 -1
- package/build/esm/lib/cli/cliCommand.d.ts +63 -15
- package/build/esm/lib/cli/cliCommand.d.ts.map +1 -1
- package/build/esm/lib/cli/cliCommand.js +4 -1
- package/build/esm/lib/cli/cliCommand.js.map +1 -1
- package/build/esm/lib/cli/cliCompact.d.ts +5 -2
- package/build/esm/lib/cli/cliCompact.d.ts.map +1 -1
- package/build/esm/lib/cli/cliCompact.js +5 -2
- package/build/esm/lib/cli/cliCompact.js.map +1 -1
- package/build/esm/lib/cli/cliDebug.d.ts +5 -2
- package/build/esm/lib/cli/cliDebug.d.ts.map +1 -1
- package/build/esm/lib/cli/cliDebug.js +4 -1
- package/build/esm/lib/cli/cliDebug.js.map +1 -1
- package/build/esm/lib/cli/cliHost.d.ts +13 -10
- package/build/esm/lib/cli/cliHost.d.ts.map +1 -1
- package/build/esm/lib/cli/cliHost.js +8 -5
- package/build/esm/lib/cli/cliHost.js.map +1 -1
- package/build/esm/lib/cli/cliLogs.d.ts +9 -3
- package/build/esm/lib/cli/cliLogs.d.ts.map +1 -1
- package/build/esm/lib/cli/cliLogs.js +8 -1
- package/build/esm/lib/cli/cliLogs.js.map +1 -1
- package/build/esm/lib/cli/cliMessage.d.ts +2 -1
- package/build/esm/lib/cli/cliMessage.d.ts.map +1 -1
- package/build/esm/lib/cli/cliMessage.js +1 -0
- package/build/esm/lib/cli/cliMessage.js.map +1 -1
- package/build/esm/lib/cli/cliObjects.d.ts +21 -18
- package/build/esm/lib/cli/cliObjects.d.ts.map +1 -1
- package/build/esm/lib/cli/cliObjects.js +44 -38
- package/build/esm/lib/cli/cliObjects.js.map +1 -1
- package/build/esm/lib/cli/cliPlugin.d.ts +3 -3
- package/build/esm/lib/cli/cliPlugin.d.ts.map +1 -1
- package/build/esm/lib/cli/cliPlugin.js +1 -1
- package/build/esm/lib/cli/cliPlugin.js.map +1 -1
- package/build/esm/lib/cli/cliProcess.d.ts +17 -7
- package/build/esm/lib/cli/cliProcess.d.ts.map +1 -1
- package/build/esm/lib/cli/cliProcess.js +73 -12
- package/build/esm/lib/cli/cliProcess.js.map +1 -1
- package/build/esm/lib/cli/cliStates.d.ts +7 -4
- package/build/esm/lib/cli/cliStates.d.ts.map +1 -1
- package/build/esm/lib/cli/cliStates.js +6 -2
- package/build/esm/lib/cli/cliStates.js.map +1 -1
- package/build/esm/lib/progressBar.d.ts +59 -0
- package/build/esm/lib/progressBar.d.ts.map +1 -0
- package/build/esm/lib/progressBar.js +104 -0
- package/build/esm/lib/progressBar.js.map +1 -0
- package/build/esm/lib/setup/customError.d.ts +4 -0
- package/build/esm/lib/setup/customError.d.ts.map +1 -1
- package/build/esm/lib/setup/customError.js +3 -0
- package/build/esm/lib/setup/customError.js.map +1 -1
- package/build/esm/lib/setup/dbConnection.d.ts.map +1 -1
- package/build/esm/lib/setup/dbConnection.js +10 -13
- package/build/esm/lib/setup/dbConnection.js.map +1 -1
- package/build/esm/lib/setup/formatters.d.ts +4 -4
- package/build/esm/lib/setup/formatters.js +4 -4
- package/build/esm/lib/setup/pluginInfos.d.ts +5 -0
- package/build/esm/lib/setup/pluginInfos.d.ts.map +1 -1
- package/build/esm/lib/setup/pluginInfos.js +5 -0
- package/build/esm/lib/setup/pluginInfos.js.map +1 -1
- package/build/esm/lib/setup/setupBackup.d.ts +53 -0
- package/build/esm/lib/setup/setupBackup.d.ts.map +1 -1
- package/build/esm/lib/setup/setupBackup.js +132 -13
- package/build/esm/lib/setup/setupBackup.js.map +1 -1
- package/build/esm/lib/setup/setupInstall.d.ts +66 -15
- package/build/esm/lib/setup/setupInstall.d.ts.map +1 -1
- package/build/esm/lib/setup/setupInstall.js +309 -23
- package/build/esm/lib/setup/setupInstall.js.map +1 -1
- package/build/esm/lib/setup/setupLicense.d.ts +13 -0
- package/build/esm/lib/setup/setupLicense.d.ts.map +1 -1
- package/build/esm/lib/setup/setupLicense.js +31 -1
- package/build/esm/lib/setup/setupLicense.js.map +1 -1
- package/build/esm/lib/setup/setupList.d.ts +55 -1
- package/build/esm/lib/setup/setupList.d.ts.map +1 -1
- package/build/esm/lib/setup/setupList.js +61 -8
- package/build/esm/lib/setup/setupList.js.map +1 -1
- package/build/esm/lib/setup/setupMultihost.d.ts +7 -0
- package/build/esm/lib/setup/setupMultihost.d.ts.map +1 -1
- package/build/esm/lib/setup/setupMultihost.js +85 -6
- package/build/esm/lib/setup/setupMultihost.js.map +1 -1
- package/build/esm/lib/setup/setupPacketManager.d.ts +10 -0
- package/build/esm/lib/setup/setupPacketManager.d.ts.map +1 -1
- package/build/esm/lib/setup/setupPacketManager.js +9 -0
- package/build/esm/lib/setup/setupPacketManager.js.map +1 -1
- package/build/esm/lib/setup/setupRepo.d.ts +19 -0
- package/build/esm/lib/setup/setupRepo.d.ts.map +1 -1
- package/build/esm/lib/setup/setupRepo.js +164 -14
- package/build/esm/lib/setup/setupRepo.js.map +1 -1
- package/build/esm/lib/setup/setupSetup.d.ts +34 -0
- package/build/esm/lib/setup/setupSetup.d.ts.map +1 -1
- package/build/esm/lib/setup/setupSetup.js +218 -21
- package/build/esm/lib/setup/setupSetup.js.map +1 -1
- package/build/esm/lib/setup/setupUpgrade.d.ts +13 -2
- package/build/esm/lib/setup/setupUpgrade.d.ts.map +1 -1
- package/build/esm/lib/setup/setupUpgrade.js +70 -6
- package/build/esm/lib/setup/setupUpgrade.js.map +1 -1
- package/build/esm/lib/setup/setupUpload.d.ts +77 -1
- package/build/esm/lib/setup/setupUpload.d.ts.map +1 -1
- package/build/esm/lib/setup/setupUpload.js +164 -7
- package/build/esm/lib/setup/setupUpload.js.map +1 -1
- package/build/esm/lib/setup/setupUsers.d.ts +44 -14
- package/build/esm/lib/setup/setupUsers.d.ts.map +1 -1
- package/build/esm/lib/setup/setupUsers.js +346 -14
- package/build/esm/lib/setup/setupUsers.js.map +1 -1
- package/build/esm/lib/setup/setupVendor.d.ts +14 -1
- package/build/esm/lib/setup/setupVendor.d.ts.map +1 -1
- package/build/esm/lib/setup/setupVendor.js +33 -2
- package/build/esm/lib/setup/setupVendor.js.map +1 -1
- package/build/esm/lib/setup/setupVisDebug.d.ts +16 -2
- package/build/esm/lib/setup/setupVisDebug.d.ts.map +1 -1
- package/build/esm/lib/setup/setupVisDebug.js +39 -14
- package/build/esm/lib/setup/setupVisDebug.js.map +1 -1
- package/build/esm/lib/setup/utils.d.ts +1 -1
- package/build/esm/lib/setup/utils.d.ts.map +1 -1
- package/build/esm/lib/setup/utils.js +2 -4
- package/build/esm/lib/setup/utils.js.map +1 -1
- package/build/esm/lib/setup.d.ts +1 -1
- package/build/esm/lib/setup.d.ts.map +1 -1
- package/build/esm/lib/setup.js +959 -1910
- package/build/esm/lib/setup.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +14 -14
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import type { Client as ObjectsRedisClient } from '@iobroker/db-objects-redis';
|
|
2
|
+
import type { ProcessCommandOptions } from '../../lib/cli/cliCommand.js';
|
|
3
|
+
/** Options for the license command */
|
|
2
4
|
export interface CLILicenseOptions {
|
|
5
|
+
/** The objects database client */
|
|
3
6
|
objects: ObjectsRedisClient;
|
|
4
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* CLI command to read and apply ioBroker licenses
|
|
10
|
+
*/
|
|
5
11
|
export declare class License {
|
|
6
12
|
private readonly objects;
|
|
13
|
+
/**
|
|
14
|
+
* @param options The objects database client
|
|
15
|
+
*/
|
|
7
16
|
constructor(options: CLILicenseOptions);
|
|
8
17
|
/**
|
|
9
18
|
* Read info from '/etc/iob_vendor.json' and executes instructions stored there
|
|
@@ -12,4 +21,8 @@ export declare class License {
|
|
|
12
21
|
*/
|
|
13
22
|
setLicense(file: string): Promise<void>;
|
|
14
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* @param options Process command options
|
|
26
|
+
*/
|
|
27
|
+
export declare function processCommandLicense(options: ProcessCommandOptions): void;
|
|
15
28
|
//# sourceMappingURL=setupLicense.d.ts.map
|
|
@@ -5,6 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
9
|
var __export = (target, all) => {
|
|
9
10
|
for (var name in all)
|
|
10
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -28,14 +29,22 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
30
|
var setupLicense_exports = {};
|
|
30
31
|
__export(setupLicense_exports, {
|
|
31
|
-
License: () => License
|
|
32
|
+
License: () => License,
|
|
33
|
+
processCommandLicense: () => processCommandLicense
|
|
32
34
|
});
|
|
33
35
|
module.exports = __toCommonJS(setupLicense_exports);
|
|
34
36
|
var import_js_controller_common = require("@iobroker/js-controller-common");
|
|
35
37
|
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
36
38
|
var import_jsonwebtoken = __toESM(require("jsonwebtoken"), 1);
|
|
39
|
+
var import_dbConnection = require("../../lib/setup/dbConnection.js");
|
|
37
40
|
class License {
|
|
41
|
+
static {
|
|
42
|
+
__name(this, "License");
|
|
43
|
+
}
|
|
38
44
|
objects;
|
|
45
|
+
/**
|
|
46
|
+
* @param options The objects database client
|
|
47
|
+
*/
|
|
39
48
|
constructor(options) {
|
|
40
49
|
this.objects = options.objects;
|
|
41
50
|
}
|
|
@@ -104,8 +113,30 @@ class License {
|
|
|
104
113
|
}
|
|
105
114
|
}
|
|
106
115
|
}
|
|
116
|
+
function processCommandLicense(options) {
|
|
117
|
+
const { args, params, callback } = options;
|
|
118
|
+
const file = args[0];
|
|
119
|
+
if (!file) {
|
|
120
|
+
console.warn(`Please specify the path to the license file or place license text directly!
|
|
121
|
+
${import_js_controller_common.tools.appName.toLowerCase()} license <license.file or license.text>`);
|
|
122
|
+
return void callback(import_js_controller_common.EXIT_CODES.INVALID_ARGUMENTS);
|
|
123
|
+
}
|
|
124
|
+
(0, import_dbConnection.dbConnect)(params, async ({ objects }) => {
|
|
125
|
+
const license = new License({ objects });
|
|
126
|
+
try {
|
|
127
|
+
await license.setLicense(file);
|
|
128
|
+
console.log(`License updated.`);
|
|
129
|
+
return void callback();
|
|
130
|
+
} catch (err) {
|
|
131
|
+
console.error(`Cannot update license: ${err.message}`);
|
|
132
|
+
return void callback(import_js_controller_common.EXIT_CODES.CANNOT_UPDATE_LICENSE);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
__name(processCommandLicense, "processCommandLicense");
|
|
107
137
|
// Annotate the CommonJS export names for ESM import in node:
|
|
108
138
|
0 && (module.exports = {
|
|
109
|
-
License
|
|
139
|
+
License,
|
|
140
|
+
processCommandLicense
|
|
110
141
|
});
|
|
111
142
|
//# sourceMappingURL=setupLicense.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/setup/setupLicense.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Client as ObjectsRedisClient } from '@iobroker/db-objects-redis';\nimport { tools } from '@iobroker/js-controller-common';\nimport fs from 'fs-extra';\nimport jwt from 'jsonwebtoken';\n\nexport interface CLILicenseOptions {\n objects: ObjectsRedisClient;\n}\n\nexport class License {\n private readonly objects: ObjectsRedisClient;\n\n constructor(options: CLILicenseOptions) {\n this.objects = options.objects;\n }\n\n /**\n * Read info from '/etc/iob_vendor.json' and executes instructions stored there\n *\n * @param file path of license file\n */\n async setLicense(file: string): Promise<void> {\n if (fs.existsSync(file)) {\n file = fs.readFileSync(file, 'utf8');\n }\n // try to encode license\n const license = jwt.decode(file);\n if (!license) {\n throw new Error('License cannot be decoded');\n }\n if (!tools.isObject(license) || !license.name) {\n throw new Error('Name not found in the license');\n }\n const adapter = license.name.split('.')[1];\n if (!adapter) {\n throw new Error(`Invalid license name ${license.name}`);\n }\n\n // read all instances of this adapter\n const arr = await this.objects.getObjectListAsync(\n {\n startkey: `system.adapter.${adapter}.`,\n endkey: `system.adapter.${adapter}.\\u9999`,\n },\n { checked: true },\n );\n\n let updated = 0;\n\n if (arr.rows.length) {\n for (let g = 0; g < arr.rows.length; g++) {\n const obj = arr.rows[g].value;\n if (obj && obj.type === 'instance') {\n obj.native = obj.native || {};\n obj.native.license = file;\n updated++;\n try {\n await this.objects.setObjectAsync(obj._id, obj);\n console.log(`Instance \"${obj._id}\" updated`);\n } catch (err) {\n console.error(`Cannot update \"${obj._id}\": ${err}`);\n }\n }\n }\n }\n\n if (!updated) {\n console.warn(`no instances of ${adapter} found`);\n if (arr.rows.length) {\n for (let g = 0; g < arr.rows.length; g++) {\n const obj = arr.rows[g].value;\n if (obj && obj.type === 'adapter') {\n obj.native = obj.native || {};\n obj.native.license = file;\n updated++;\n try {\n await this.objects.setObjectAsync(obj._id, obj);\n console.log(`Adapter \"${obj._id}\" updated`);\n } catch (err) {\n console.error(`Cannot update \"${obj._id}\": ${err}`);\n }\n }\n }\n }\n }\n\n if (!updated) {\n console.error(`no installations of ${adapter} found`);\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { Client as ObjectsRedisClient } from '@iobroker/db-objects-redis';\nimport { tools, EXIT_CODES } from '@iobroker/js-controller-common';\nimport fs from 'fs-extra';\nimport jwt from 'jsonwebtoken';\nimport type { ProcessCommandOptions } from '@/lib/cli/cliCommand.js';\nimport { dbConnect } from '@/lib/setup/dbConnection.js';\n\n/** Options for the license command */\nexport interface CLILicenseOptions {\n /** The objects database client */\n objects: ObjectsRedisClient;\n}\n\n/**\n * CLI command to read and apply ioBroker licenses\n */\nexport class License {\n private readonly objects: ObjectsRedisClient;\n\n /**\n * @param options The objects database client\n */\n constructor(options: CLILicenseOptions) {\n this.objects = options.objects;\n }\n\n /**\n * Read info from '/etc/iob_vendor.json' and executes instructions stored there\n *\n * @param file path of license file\n */\n async setLicense(file: string): Promise<void> {\n if (fs.existsSync(file)) {\n file = fs.readFileSync(file, 'utf8');\n }\n // try to encode license\n const license = jwt.decode(file);\n if (!license) {\n throw new Error('License cannot be decoded');\n }\n if (!tools.isObject(license) || !license.name) {\n throw new Error('Name not found in the license');\n }\n const adapter = license.name.split('.')[1];\n if (!adapter) {\n throw new Error(`Invalid license name ${license.name}`);\n }\n\n // read all instances of this adapter\n const arr = await this.objects.getObjectListAsync(\n {\n startkey: `system.adapter.${adapter}.`,\n endkey: `system.adapter.${adapter}.\\u9999`,\n },\n { checked: true },\n );\n\n let updated = 0;\n\n if (arr.rows.length) {\n for (let g = 0; g < arr.rows.length; g++) {\n const obj = arr.rows[g].value;\n if (obj && obj.type === 'instance') {\n obj.native = obj.native || {};\n obj.native.license = file;\n updated++;\n try {\n await this.objects.setObjectAsync(obj._id, obj);\n console.log(`Instance \"${obj._id}\" updated`);\n } catch (err) {\n console.error(`Cannot update \"${obj._id}\": ${err}`);\n }\n }\n }\n }\n\n if (!updated) {\n console.warn(`no instances of ${adapter} found`);\n if (arr.rows.length) {\n for (let g = 0; g < arr.rows.length; g++) {\n const obj = arr.rows[g].value;\n if (obj && obj.type === 'adapter') {\n obj.native = obj.native || {};\n obj.native.license = file;\n updated++;\n try {\n await this.objects.setObjectAsync(obj._id, obj);\n console.log(`Adapter \"${obj._id}\" updated`);\n } catch (err) {\n console.error(`Cannot update \"${obj._id}\": ${err}`);\n }\n }\n }\n }\n }\n\n if (!updated) {\n console.error(`no installations of ${adapter} found`);\n }\n }\n}\n\n/**\n * @param options Process command options\n */\nexport function processCommandLicense(options: ProcessCommandOptions): void {\n const { args, params, callback } = options;\n\n const file = args[0];\n if (!file) {\n console.warn(\n `Please specify the path to the license file or place license text directly!\\n${tools.appName.toLowerCase()} license <license.file or license.text>`,\n );\n return void callback(EXIT_CODES.INVALID_ARGUMENTS);\n }\n dbConnect(params, async ({ objects }) => {\n const license = new License({ objects });\n try {\n await license.setLicense(file);\n console.log(`License updated.`);\n return void callback();\n } catch (err) {\n console.error(`Cannot update license: ${err.message}`);\n return void callback(EXIT_CODES.CANNOT_UPDATE_LICENSE);\n }\n });\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": ["fs", "jwt"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* List different objects for CLI
|
|
3
3
|
*
|
|
4
|
-
* Copyright 2013-
|
|
4
|
+
* Copyright 2013-2026 bluefox <dogafox@gmail.com>
|
|
5
5
|
*
|
|
6
6
|
* MIT License
|
|
7
7
|
*
|
|
@@ -27,21 +27,75 @@ interface CLIListOptions {
|
|
|
27
27
|
processExit: (exitCode?: number) => void;
|
|
28
28
|
}
|
|
29
29
|
export type ListType = 'objects' | 'o' | 'states' | 's' | 'adapters' | 'a' | 'instances' | 'i' | 'users' | 'u' | 'groups' | 'g' | 'hosts' | 'h' | 'enums' | 'e' | 'files' | 'f';
|
|
30
|
+
/**
|
|
31
|
+
* CLI command to list adapters, instances, objects and files
|
|
32
|
+
*/
|
|
30
33
|
export declare class List {
|
|
31
34
|
private config;
|
|
32
35
|
private objects;
|
|
33
36
|
private states;
|
|
34
37
|
private readonly processExit;
|
|
38
|
+
/**
|
|
39
|
+
* @param options The objects/states clients, config and process-exit callback
|
|
40
|
+
*/
|
|
35
41
|
constructor(options: CLIListOptions);
|
|
36
42
|
private static _perm2str;
|
|
43
|
+
/**
|
|
44
|
+
* Print the table header for a file listing
|
|
45
|
+
*
|
|
46
|
+
* @param adapter Optional adapter name printed above the header
|
|
47
|
+
*/
|
|
37
48
|
showFileHeader(adapter?: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* Print a single file as a table row
|
|
51
|
+
*
|
|
52
|
+
* @param adapter The adapter the file belongs to
|
|
53
|
+
* @param path The directory path of the file
|
|
54
|
+
* @param file The file entry to print
|
|
55
|
+
*/
|
|
38
56
|
showFile(adapter: string, path: string, file: ioBroker.ReadDirResult): void;
|
|
57
|
+
/**
|
|
58
|
+
* Print the table header for an object listing
|
|
59
|
+
*/
|
|
39
60
|
showObjectHeader(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Print a single object as a table row
|
|
63
|
+
*
|
|
64
|
+
* @param obj The object to print
|
|
65
|
+
*/
|
|
40
66
|
showObject(obj: ioBroker.AnyObject): void;
|
|
67
|
+
/**
|
|
68
|
+
* Recursively list the files in a directory of an adapter
|
|
69
|
+
*
|
|
70
|
+
* @param adapter The adapter the files belong to
|
|
71
|
+
* @param path The directory path to list
|
|
72
|
+
* @param allFiles Accumulator of files collected so far, or the callback
|
|
73
|
+
* @param callback Called with all collected files
|
|
74
|
+
*/
|
|
41
75
|
listDirectory(adapter: string, path: string | null | undefined, allFiles?: File[] | ((allFiles: File[]) => void), callback?: (allFiles: File[]) => void): void;
|
|
76
|
+
/**
|
|
77
|
+
* Comparator that sorts two file entries by their full path
|
|
78
|
+
*
|
|
79
|
+
* @param a The first file entry
|
|
80
|
+
* @param b The second file entry
|
|
81
|
+
*/
|
|
42
82
|
sortFiles(a: File, b: File): number;
|
|
83
|
+
/**
|
|
84
|
+
* List the files of the given adapters
|
|
85
|
+
*
|
|
86
|
+
* @param adapters The adapters whose files should be listed
|
|
87
|
+
* @param filter Optional name filter, or the callback
|
|
88
|
+
* @param callback Called once all files have been listed
|
|
89
|
+
*/
|
|
43
90
|
listAdaptersFiles(adapters: string[], filter?: null | string, callback?: () => void): void | Promise<void>;
|
|
44
91
|
private _readOnlineState;
|
|
92
|
+
/**
|
|
93
|
+
* List items of the given type matching the filter
|
|
94
|
+
*
|
|
95
|
+
* @param type The kind of items to list (e.g. adapters, instances, objects)
|
|
96
|
+
* @param filter A filter applied to the listed items
|
|
97
|
+
* @param flags Additional flags controlling the output
|
|
98
|
+
*/
|
|
45
99
|
list(type: ListType, filter: string, flags: FlagObject): void;
|
|
46
100
|
}
|
|
47
101
|
export {};
|
|
@@ -5,6 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
9
|
var __export = (target, all) => {
|
|
9
10
|
for (var name in all)
|
|
10
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -31,14 +32,19 @@ __export(setupList_exports, {
|
|
|
31
32
|
List: () => List
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(setupList_exports);
|
|
34
|
-
var import_js_controller_common = require("@iobroker/js-controller-common");
|
|
35
35
|
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
36
|
-
var
|
|
36
|
+
var import_js_controller_common = require("@iobroker/js-controller-common");
|
|
37
37
|
class List {
|
|
38
|
+
static {
|
|
39
|
+
__name(this, "List");
|
|
40
|
+
}
|
|
38
41
|
config;
|
|
39
42
|
objects;
|
|
40
43
|
states;
|
|
41
44
|
processExit;
|
|
45
|
+
/**
|
|
46
|
+
* @param options The objects/states clients, config and process-exit callback
|
|
47
|
+
*/
|
|
42
48
|
constructor(options) {
|
|
43
49
|
options = options || {};
|
|
44
50
|
if (!options.states) {
|
|
@@ -50,7 +56,7 @@ class List {
|
|
|
50
56
|
if (!options.processExit) {
|
|
51
57
|
throw new Error("Invalid arguments: processExit is missing");
|
|
52
58
|
}
|
|
53
|
-
this.config = import_fs_extra.default.readJSONSync(
|
|
59
|
+
this.config = import_fs_extra.default.readJSONSync(import_js_controller_common.tools.getConfigFileName());
|
|
54
60
|
this.objects = options.objects;
|
|
55
61
|
this.states = options.states;
|
|
56
62
|
this.processExit = options.processExit;
|
|
@@ -68,6 +74,11 @@ class List {
|
|
|
68
74
|
result += perm & 1 ? "x" : "-";
|
|
69
75
|
return result;
|
|
70
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Print the table header for a file listing
|
|
79
|
+
*
|
|
80
|
+
* @param adapter Optional adapter name printed above the header
|
|
81
|
+
*/
|
|
71
82
|
showFileHeader(adapter) {
|
|
72
83
|
if (adapter) {
|
|
73
84
|
console.log(`
|
|
@@ -76,6 +87,13 @@ class List {
|
|
|
76
87
|
console.log(" Modified at |Permission| User | Group | Size | Name");
|
|
77
88
|
console.log("----------------+----------+--------------+--------------+------+---------");
|
|
78
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Print a single file as a table row
|
|
92
|
+
*
|
|
93
|
+
* @param adapter The adapter the file belongs to
|
|
94
|
+
* @param path The directory path of the file
|
|
95
|
+
* @param file The file entry to print
|
|
96
|
+
*/
|
|
79
97
|
showFile(adapter, path, file) {
|
|
80
98
|
let text = "";
|
|
81
99
|
let time = "";
|
|
@@ -106,10 +124,18 @@ class List {
|
|
|
106
124
|
console.log(text);
|
|
107
125
|
}
|
|
108
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Print the table header for an object listing
|
|
129
|
+
*/
|
|
109
130
|
showObjectHeader() {
|
|
110
131
|
console.log("ObjectAC | StateAC | User | Group | ID");
|
|
111
132
|
console.log("---------+---------+--------------+--------------+--------------");
|
|
112
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Print a single object as a table row
|
|
136
|
+
*
|
|
137
|
+
* @param obj The object to print
|
|
138
|
+
*/
|
|
113
139
|
showObject(obj) {
|
|
114
140
|
let text = "";
|
|
115
141
|
if (obj.acl) {
|
|
@@ -126,6 +152,14 @@ class List {
|
|
|
126
152
|
text += ` ${obj._id}`;
|
|
127
153
|
console.log(text);
|
|
128
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Recursively list the files in a directory of an adapter
|
|
157
|
+
*
|
|
158
|
+
* @param adapter The adapter the files belong to
|
|
159
|
+
* @param path The directory path to list
|
|
160
|
+
* @param allFiles Accumulator of files collected so far, or the callback
|
|
161
|
+
* @param callback Called with all collected files
|
|
162
|
+
*/
|
|
129
163
|
listDirectory(adapter, path, allFiles, callback) {
|
|
130
164
|
if (typeof path === "function") {
|
|
131
165
|
callback = path;
|
|
@@ -186,6 +220,12 @@ class List {
|
|
|
186
220
|
}
|
|
187
221
|
});
|
|
188
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Comparator that sorts two file entries by their full path
|
|
225
|
+
*
|
|
226
|
+
* @param a The first file entry
|
|
227
|
+
* @param b The second file entry
|
|
228
|
+
*/
|
|
189
229
|
sortFiles(a, b) {
|
|
190
230
|
let a1 = a.path + a.file.file;
|
|
191
231
|
if (a1[0] !== "/") {
|
|
@@ -197,6 +237,13 @@ class List {
|
|
|
197
237
|
}
|
|
198
238
|
return a1.localeCompare(b1);
|
|
199
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* List the files of the given adapters
|
|
242
|
+
*
|
|
243
|
+
* @param adapters The adapters whose files should be listed
|
|
244
|
+
* @param filter Optional name filter, or the callback
|
|
245
|
+
* @param callback Called once all files have been listed
|
|
246
|
+
*/
|
|
200
247
|
listAdaptersFiles(adapters, filter, callback) {
|
|
201
248
|
if (typeof filter === "function") {
|
|
202
249
|
callback = filter;
|
|
@@ -214,21 +261,21 @@ class List {
|
|
|
214
261
|
files.sort(this.sortFiles);
|
|
215
262
|
this.showFileHeader(adapter);
|
|
216
263
|
files.filter((f) => !filter || `${f.path}/${f.file.file}`.startsWith(filter)).forEach((f) => this.showFile(f.adapter, f.path, f.file));
|
|
217
|
-
this.listAdaptersFiles(adapters, filter, callback);
|
|
264
|
+
return this.listAdaptersFiles(adapters, filter, callback);
|
|
218
265
|
});
|
|
219
266
|
} else {
|
|
220
|
-
return
|
|
267
|
+
return import_js_controller_common.tools.maybeCallback(callback);
|
|
221
268
|
}
|
|
222
269
|
}
|
|
223
270
|
_readOnlineState(lines, flags, cb, _result) {
|
|
224
271
|
const result = _result || [];
|
|
225
|
-
if (!lines
|
|
272
|
+
if (!lines?.length) {
|
|
226
273
|
cb(result);
|
|
227
274
|
} else {
|
|
228
275
|
const task = lines.shift();
|
|
229
276
|
const id = `${task.id}.alive`;
|
|
230
|
-
this.states.getState(id, (
|
|
231
|
-
if (state
|
|
277
|
+
this.states.getState(id, (_err, state) => {
|
|
278
|
+
if (state?.val) {
|
|
232
279
|
result.push(`+ ${task.value}`);
|
|
233
280
|
} else if (!flags.alive) {
|
|
234
281
|
result.push(` ${task.value}`);
|
|
@@ -237,6 +284,13 @@ class List {
|
|
|
237
284
|
});
|
|
238
285
|
}
|
|
239
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* List items of the given type matching the filter
|
|
289
|
+
*
|
|
290
|
+
* @param type The kind of items to list (e.g. adapters, instances, objects)
|
|
291
|
+
* @param filter A filter applied to the listed items
|
|
292
|
+
* @param flags Additional flags controlling the output
|
|
293
|
+
*/
|
|
240
294
|
list(type, filter, flags) {
|
|
241
295
|
this.objects.getObject("system.config", (err, systemConf) => {
|
|
242
296
|
const lang = systemConf?.common?.language || "en";
|
|
@@ -248,10 +302,10 @@ class List {
|
|
|
248
302
|
this.processExit();
|
|
249
303
|
return;
|
|
250
304
|
}
|
|
251
|
-
const reg = filter ? new RegExp(
|
|
305
|
+
const reg = filter ? new RegExp(import_js_controller_common.tools.pattern2RegEx(filter)) : null;
|
|
252
306
|
for (const obj of objs.rows) {
|
|
253
307
|
let name = obj.value?.common?.name;
|
|
254
|
-
if (
|
|
308
|
+
if (import_js_controller_common.tools.isObject(name)) {
|
|
255
309
|
name = name[lang] || name.en;
|
|
256
310
|
}
|
|
257
311
|
if (!reg || reg.test(obj.value._id) || name && reg.test(name)) {
|
|
@@ -301,7 +355,7 @@ class List {
|
|
|
301
355
|
this.processExit();
|
|
302
356
|
return;
|
|
303
357
|
}
|
|
304
|
-
const reg = filter ? new RegExp(
|
|
358
|
+
const reg = filter ? new RegExp(import_js_controller_common.tools.pattern2RegEx(`system.adapter.${filter}`)) : null;
|
|
305
359
|
const adapterList = [];
|
|
306
360
|
for (const obj of objs.rows) {
|
|
307
361
|
if (obj.value.type !== "adapter") {
|
|
@@ -310,7 +364,7 @@ class List {
|
|
|
310
364
|
if (!reg || reg.test(obj.value._id) || obj.value.common && reg.test(obj.value.common.name)) {
|
|
311
365
|
const id = obj.value._id;
|
|
312
366
|
let name = obj.value.common.name;
|
|
313
|
-
if (
|
|
367
|
+
if (import_js_controller_common.tools.isObject(name)) {
|
|
314
368
|
name = name[lang] || name.en;
|
|
315
369
|
}
|
|
316
370
|
adapterList.push({
|
|
@@ -332,7 +386,7 @@ class List {
|
|
|
332
386
|
this.processExit();
|
|
333
387
|
return;
|
|
334
388
|
}
|
|
335
|
-
const reg = filter ? new RegExp(
|
|
389
|
+
const reg = filter ? new RegExp(import_js_controller_common.tools.pattern2RegEx(`system.adapter.${filter}`)) : null;
|
|
336
390
|
objs.rows.sort((a, b) => {
|
|
337
391
|
if (a.id > b.id) {
|
|
338
392
|
return 1;
|
|
@@ -347,7 +401,7 @@ class List {
|
|
|
347
401
|
continue;
|
|
348
402
|
}
|
|
349
403
|
let name = row.value.common?.name;
|
|
350
|
-
if (
|
|
404
|
+
if (import_js_controller_common.tools.isObject(name)) {
|
|
351
405
|
name = name[lang] || name.en;
|
|
352
406
|
}
|
|
353
407
|
if (!reg || reg.test(row.value._id) || name && reg.test(name)) {
|
|
@@ -411,17 +465,17 @@ class List {
|
|
|
411
465
|
this.processExit();
|
|
412
466
|
return;
|
|
413
467
|
}
|
|
414
|
-
const reg = filter ? new RegExp(
|
|
468
|
+
const reg = filter ? new RegExp(import_js_controller_common.tools.pattern2RegEx(`system.user.${filter}`)) : null;
|
|
415
469
|
console.log(" ID | Name | Active | Groups");
|
|
416
470
|
console.log("---------------------------------------+-------------+----------+--------------");
|
|
417
471
|
for (const obj of objs.rows) {
|
|
418
472
|
if (obj.value.type !== "user") {
|
|
419
473
|
continue;
|
|
420
474
|
}
|
|
421
|
-
if (!reg || reg.test(obj.value._id) || obj.value.common && reg.test(
|
|
475
|
+
if (!reg || reg.test(obj.value._id) || obj.value.common && reg.test(import_js_controller_common.tools.isObject(obj.value.common.name) ? obj.value.common.name[lang] || obj.value.common.name.en : obj.value.common.name)) {
|
|
422
476
|
const id = obj.value._id;
|
|
423
477
|
let name = obj.value.common.name;
|
|
424
|
-
if (
|
|
478
|
+
if (import_js_controller_common.tools.isObject(name)) {
|
|
425
479
|
name = name[lang] || name.en;
|
|
426
480
|
}
|
|
427
481
|
const text = `${id.padEnd(39)}| ${name.padEnd(11)} | ${obj.value.common.enabled ? " enabled" : "disabled"} |`;
|
|
@@ -447,7 +501,7 @@ class List {
|
|
|
447
501
|
this.processExit();
|
|
448
502
|
return;
|
|
449
503
|
}
|
|
450
|
-
const reg = filter ? new RegExp(
|
|
504
|
+
const reg = filter ? new RegExp(import_js_controller_common.tools.pattern2RegEx(`system.group.${filter}`)) : null;
|
|
451
505
|
console.log("");
|
|
452
506
|
console.log(" system.group | object | state | file | user | others | users");
|
|
453
507
|
console.log(" | l r w d | l r w d | l r w c d | w c d | |");
|
|
@@ -456,7 +510,7 @@ class List {
|
|
|
456
510
|
if (obj.value.type !== "group") {
|
|
457
511
|
continue;
|
|
458
512
|
}
|
|
459
|
-
if (!reg || reg.test(obj.value._id) || obj.value.common && reg.test(
|
|
513
|
+
if (!reg || reg.test(obj.value._id) || obj.value.common && reg.test(import_js_controller_common.tools.isObject(obj.value.common.name) ? obj.value.common.name[lang] || obj.value.common.name.en : obj.value.common.name)) {
|
|
460
514
|
const id = obj.value._id.substring(13);
|
|
461
515
|
if (id === "administrator") {
|
|
462
516
|
obj.value.common.acl = {
|
|
@@ -577,7 +631,7 @@ class List {
|
|
|
577
631
|
this.processExit();
|
|
578
632
|
return;
|
|
579
633
|
}
|
|
580
|
-
const reg = filter ? new RegExp(
|
|
634
|
+
const reg = filter ? new RegExp(import_js_controller_common.tools.pattern2RegEx(`system.host.${filter}`)) : null;
|
|
581
635
|
for (const obj of objs.rows) {
|
|
582
636
|
if (obj.value.type !== "host") {
|
|
583
637
|
continue;
|
|
@@ -585,7 +639,7 @@ class List {
|
|
|
585
639
|
if (!reg || reg.test(obj.value._id) || obj.value.common && reg.test(obj.value.common.name)) {
|
|
586
640
|
const id = obj.value._id.substring(12);
|
|
587
641
|
let name = obj.value.common.name;
|
|
588
|
-
if (
|
|
642
|
+
if (import_js_controller_common.tools.isObject(name)) {
|
|
589
643
|
name = name[lang] || name.en;
|
|
590
644
|
}
|
|
591
645
|
const hostname = obj.value.common.hostname;
|
|
@@ -620,13 +674,13 @@ class List {
|
|
|
620
674
|
this.processExit();
|
|
621
675
|
return;
|
|
622
676
|
}
|
|
623
|
-
const reg = filter ? new RegExp(
|
|
677
|
+
const reg = filter ? new RegExp(import_js_controller_common.tools.pattern2RegEx(`enum.${filter}`)) : null;
|
|
624
678
|
for (const obj of objs.rows) {
|
|
625
679
|
if (obj.value.type !== "enum") {
|
|
626
680
|
continue;
|
|
627
681
|
}
|
|
628
682
|
let name = obj.value.common?.name;
|
|
629
|
-
if (
|
|
683
|
+
if (import_js_controller_common.tools.isObject(name)) {
|
|
630
684
|
name = name[lang] || name.en;
|
|
631
685
|
}
|
|
632
686
|
if (!reg || reg.test(obj.value._id) || name && reg.test(name)) {
|
|
@@ -658,7 +712,7 @@ class List {
|
|
|
658
712
|
if (names) {
|
|
659
713
|
names.shift();
|
|
660
714
|
}
|
|
661
|
-
this.listAdaptersFiles(adapters, names ? names.join("/") : null, () => this.processExit());
|
|
715
|
+
return this.listAdaptersFiles(adapters, names ? names.join("/") : null, () => this.processExit());
|
|
662
716
|
});
|
|
663
717
|
break;
|
|
664
718
|
}
|