@iobroker/js-controller-cli 7.2.2 → 7.2.3-alpha.1-20260621-61726ea22
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/lib/_Types.d.ts +7 -0
- package/build/cjs/lib/cli/cliCert.d.ts +5 -2
- package/build/cjs/lib/cli/cliCert.js +5 -2
- package/build/cjs/lib/cli/cliCert.js.map +2 -2
- package/build/cjs/lib/cli/cliCommand.d.ts +32 -1
- package/build/cjs/lib/cli/cliCommand.js +4 -1
- package/build/cjs/lib/cli/cliCommand.js.map +2 -2
- package/build/cjs/lib/cli/cliCompact.d.ts +4 -1
- package/build/cjs/lib/cli/cliCompact.js +4 -1
- package/build/cjs/lib/cli/cliCompact.js.map +2 -2
- package/build/cjs/lib/cli/cliDebug.d.ts +4 -1
- package/build/cjs/lib/cli/cliDebug.js +4 -1
- package/build/cjs/lib/cli/cliDebug.js.map +2 -2
- package/build/cjs/lib/cli/cliHost.d.ts +8 -5
- package/build/cjs/lib/cli/cliHost.js +8 -5
- package/build/cjs/lib/cli/cliHost.js.map +2 -2
- package/build/cjs/lib/cli/cliLogs.d.ts +4 -1
- package/build/cjs/lib/cli/cliLogs.js +4 -1
- package/build/cjs/lib/cli/cliLogs.js.map +2 -2
- package/build/cjs/lib/cli/cliMessage.d.ts +1 -0
- package/build/cjs/lib/cli/cliMessage.js.map +2 -2
- package/build/cjs/lib/cli/cliObjects.d.ts +12 -9
- package/build/cjs/lib/cli/cliObjects.js +12 -9
- package/build/cjs/lib/cli/cliObjects.js.map +2 -2
- package/build/cjs/lib/cli/cliPlugin.js.map +1 -1
- package/build/cjs/lib/cli/cliProcess.d.ts +4 -0
- package/build/cjs/lib/cli/cliProcess.js +3 -0
- package/build/cjs/lib/cli/cliProcess.js.map +2 -2
- package/build/cjs/lib/cli/cliStates.d.ts +3 -0
- package/build/cjs/lib/cli/cliStates.js +3 -0
- package/build/cjs/lib/cli/cliStates.js.map +2 -2
- package/build/cjs/lib/setup/customError.d.ts +4 -0
- package/build/cjs/lib/setup/customError.js +3 -0
- package/build/cjs/lib/setup/customError.js.map +2 -2
- package/build/cjs/lib/setup/formatters.d.ts +4 -4
- package/build/cjs/lib/setup/formatters.js.map +1 -1
- package/build/cjs/lib/setup/pluginInfos.d.ts +5 -0
- package/build/cjs/lib/setup/pluginInfos.js.map +2 -2
- package/build/cjs/lib/setup/setupBackup.d.ts +34 -0
- package/build/cjs/lib/setup/setupBackup.js +22 -0
- package/build/cjs/lib/setup/setupBackup.js.map +2 -2
- package/build/cjs/lib/setup/setupInstall.d.ts +37 -14
- package/build/cjs/lib/setup/setupInstall.js +28 -14
- package/build/cjs/lib/setup/setupInstall.js.map +2 -2
- package/build/cjs/lib/setup/setupLicense.d.ts +8 -0
- package/build/cjs/lib/setup/setupLicense.js +3 -0
- package/build/cjs/lib/setup/setupLicense.js.map +2 -2
- package/build/cjs/lib/setup/setupList.d.ts +54 -0
- package/build/cjs/lib/setup/setupList.js +51 -0
- package/build/cjs/lib/setup/setupList.js.map +2 -2
- package/build/cjs/lib/setup/setupPacketManager.d.ts +10 -0
- package/build/cjs/lib/setup/setupPacketManager.js +6 -0
- package/build/cjs/lib/setup/setupPacketManager.js.map +2 -2
- package/build/cjs/lib/setup/setupRepo.d.ts +6 -0
- package/build/cjs/lib/setup/setupRepo.js +3 -0
- package/build/cjs/lib/setup/setupRepo.js.map +2 -2
- package/build/cjs/lib/setup/setupSetup.d.ts +27 -0
- package/build/cjs/lib/setup/setupSetup.js +18 -0
- package/build/cjs/lib/setup/setupSetup.js.map +2 -2
- package/build/cjs/lib/setup/setupUpgrade.d.ts +6 -0
- package/build/cjs/lib/setup/setupUpgrade.js +3 -0
- package/build/cjs/lib/setup/setupUpgrade.js.map +2 -2
- package/build/cjs/lib/setup/setupUpload.d.ts +71 -0
- package/build/cjs/lib/setup/setupUpload.js +65 -1
- package/build/cjs/lib/setup/setupUpload.js.map +2 -2
- package/build/cjs/lib/setup/setupUsers.d.ts +23 -14
- package/build/cjs/lib/setup/setupUsers.js +17 -14
- package/build/cjs/lib/setup/setupUsers.js.map +2 -2
- package/build/cjs/lib/setup/setupVendor.d.ts +9 -1
- package/build/cjs/lib/setup/setupVendor.js +4 -1
- package/build/cjs/lib/setup/setupVendor.js.map +2 -2
- package/build/cjs/lib/setup/setupVisDebug.d.ts +9 -0
- package/build/cjs/lib/setup/setupVisDebug.js +3 -0
- package/build/cjs/lib/setup/setupVisDebug.js.map +2 -2
- package/build/esm/lib/_Types.d.ts +7 -0
- package/build/esm/lib/_Types.d.ts.map +1 -1
- package/build/esm/lib/cli/cliCert.d.ts +5 -2
- package/build/esm/lib/cli/cliCert.d.ts.map +1 -1
- package/build/esm/lib/cli/cliCert.js +5 -2
- package/build/esm/lib/cli/cliCert.js.map +1 -1
- package/build/esm/lib/cli/cliCommand.d.ts +32 -1
- 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 +4 -1
- package/build/esm/lib/cli/cliCompact.d.ts.map +1 -1
- package/build/esm/lib/cli/cliCompact.js +4 -1
- package/build/esm/lib/cli/cliCompact.js.map +1 -1
- package/build/esm/lib/cli/cliDebug.d.ts +4 -1
- 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 +8 -5
- 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 +4 -1
- package/build/esm/lib/cli/cliLogs.d.ts.map +1 -1
- package/build/esm/lib/cli/cliLogs.js +4 -1
- package/build/esm/lib/cli/cliLogs.js.map +1 -1
- package/build/esm/lib/cli/cliMessage.d.ts +1 -0
- 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 +12 -9
- package/build/esm/lib/cli/cliObjects.d.ts.map +1 -1
- package/build/esm/lib/cli/cliObjects.js +17 -14
- package/build/esm/lib/cli/cliObjects.js.map +1 -1
- package/build/esm/lib/cli/cliPlugin.js +1 -1
- package/build/esm/lib/cli/cliProcess.d.ts +4 -0
- package/build/esm/lib/cli/cliProcess.d.ts.map +1 -1
- package/build/esm/lib/cli/cliProcess.js +5 -1
- package/build/esm/lib/cli/cliProcess.js.map +1 -1
- package/build/esm/lib/cli/cliStates.d.ts +3 -0
- package/build/esm/lib/cli/cliStates.d.ts.map +1 -1
- package/build/esm/lib/cli/cliStates.js +3 -0
- package/build/esm/lib/cli/cliStates.js.map +1 -1
- 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/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 +34 -0
- package/build/esm/lib/setup/setupBackup.d.ts.map +1 -1
- package/build/esm/lib/setup/setupBackup.js +25 -0
- package/build/esm/lib/setup/setupBackup.js.map +1 -1
- package/build/esm/lib/setup/setupInstall.d.ts +37 -14
- package/build/esm/lib/setup/setupInstall.d.ts.map +1 -1
- package/build/esm/lib/setup/setupInstall.js +31 -14
- package/build/esm/lib/setup/setupInstall.js.map +1 -1
- package/build/esm/lib/setup/setupLicense.d.ts +8 -0
- package/build/esm/lib/setup/setupLicense.d.ts.map +1 -1
- package/build/esm/lib/setup/setupLicense.js +6 -0
- package/build/esm/lib/setup/setupLicense.js.map +1 -1
- package/build/esm/lib/setup/setupList.d.ts +54 -0
- package/build/esm/lib/setup/setupList.d.ts.map +1 -1
- package/build/esm/lib/setup/setupList.js +54 -0
- package/build/esm/lib/setup/setupList.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 +6 -0
- package/build/esm/lib/setup/setupRepo.d.ts.map +1 -1
- package/build/esm/lib/setup/setupRepo.js +6 -0
- package/build/esm/lib/setup/setupRepo.js.map +1 -1
- package/build/esm/lib/setup/setupSetup.d.ts +27 -0
- package/build/esm/lib/setup/setupSetup.d.ts.map +1 -1
- package/build/esm/lib/setup/setupSetup.js +21 -0
- package/build/esm/lib/setup/setupSetup.js.map +1 -1
- package/build/esm/lib/setup/setupUpgrade.d.ts +6 -0
- package/build/esm/lib/setup/setupUpgrade.d.ts.map +1 -1
- package/build/esm/lib/setup/setupUpgrade.js +6 -0
- package/build/esm/lib/setup/setupUpgrade.js.map +1 -1
- package/build/esm/lib/setup/setupUpload.d.ts +71 -0
- package/build/esm/lib/setup/setupUpload.d.ts.map +1 -1
- package/build/esm/lib/setup/setupUpload.js +68 -1
- package/build/esm/lib/setup/setupUpload.js.map +1 -1
- package/build/esm/lib/setup/setupUsers.d.ts +23 -14
- package/build/esm/lib/setup/setupUsers.d.ts.map +1 -1
- package/build/esm/lib/setup/setupUsers.js +20 -14
- package/build/esm/lib/setup/setupUsers.js.map +1 -1
- package/build/esm/lib/setup/setupVendor.d.ts +9 -1
- package/build/esm/lib/setup/setupVendor.d.ts.map +1 -1
- package/build/esm/lib/setup/setupVendor.js +7 -1
- package/build/esm/lib/setup/setupVendor.js.map +1 -1
- package/build/esm/lib/setup/setupVisDebug.d.ts +9 -0
- package/build/esm/lib/setup/setupVisDebug.d.ts.map +1 -1
- package/build/esm/lib/setup/setupVisDebug.js +6 -0
- package/build/esm/lib/setup/setupVisDebug.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -4,10 +4,15 @@ export type ProcessExitCallback = (exitCode: number) => void;
|
|
|
4
4
|
export type CleanDatabaseHandler = (isDeleteDb: boolean) => any;
|
|
5
5
|
export type DbConnectCallback = (params: DbConnectAsyncReturn) => void;
|
|
6
6
|
export type DbConnect = (onlyCheckOrParams?: boolean | Record<string, any>, paramsOrCb?: Record<string, any> | DbConnectCallback, callback?: DbConnectCallback) => void;
|
|
7
|
+
/** Result returned once the database connection has been established */
|
|
7
8
|
export interface DbConnectAsyncReturn {
|
|
9
|
+
/** The connected objects database client */
|
|
8
10
|
objects: ObjectsRedisClient;
|
|
11
|
+
/** The connected states database client */
|
|
9
12
|
states: StatesRedisClient;
|
|
13
|
+
/** Whether the controller is offline (no running host) */
|
|
10
14
|
isOffline?: boolean;
|
|
15
|
+
/** Type of the objects database backend */
|
|
11
16
|
objectsDBType: string;
|
|
12
17
|
/** The iobroker.json config file */
|
|
13
18
|
config: ioBroker.IoBrokerJson;
|
|
@@ -22,7 +27,9 @@ interface IoPackageCommon extends ioBroker.AdapterCommon {
|
|
|
22
27
|
};
|
|
23
28
|
};
|
|
24
29
|
}
|
|
30
|
+
/** An adapter object as stored in io-package.json */
|
|
25
31
|
export interface IoPackage extends ioBroker.AdapterObject {
|
|
32
|
+
/** The common section including the plugins configuration */
|
|
26
33
|
common: IoPackageCommon;
|
|
27
34
|
}
|
|
28
35
|
export {};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { CLICommand, type CLICommandOptions } from './cliCommand.js';
|
|
2
2
|
/** Command ioBroker cert ... */
|
|
3
3
|
export declare class CLICert extends CLICommand {
|
|
4
|
+
/**
|
|
5
|
+
* @param options The command options including context and parameters
|
|
6
|
+
*/
|
|
4
7
|
constructor(options: CLICommandOptions);
|
|
5
8
|
/**
|
|
6
9
|
* Executes a command
|
|
7
10
|
*
|
|
8
|
-
* @param args
|
|
11
|
+
* @param args The command arguments (the first is the sub-command)
|
|
9
12
|
*/
|
|
10
13
|
execute(args: any[]): void | Promise<void>;
|
|
11
14
|
/**
|
|
@@ -15,7 +18,7 @@ export declare class CLICert extends CLICommand {
|
|
|
15
18
|
/**
|
|
16
19
|
* View the certificates on CLI
|
|
17
20
|
*
|
|
18
|
-
* @param _args
|
|
21
|
+
* @param _args The command arguments (the second is the certificate name)
|
|
19
22
|
*/
|
|
20
23
|
view(_args: any[]): void;
|
|
21
24
|
}
|
|
@@ -36,13 +36,16 @@ var import_cliObjects = require("./cliObjects.js");
|
|
|
36
36
|
var messages = __toESM(require("./messages.js"), 1);
|
|
37
37
|
var import_js_controller_common = require("@iobroker/js-controller-common");
|
|
38
38
|
class CLICert extends import_cliCommand.CLICommand {
|
|
39
|
+
/**
|
|
40
|
+
* @param options The command options including context and parameters
|
|
41
|
+
*/
|
|
39
42
|
constructor(options) {
|
|
40
43
|
super(options);
|
|
41
44
|
}
|
|
42
45
|
/**
|
|
43
46
|
* Executes a command
|
|
44
47
|
*
|
|
45
|
-
* @param args
|
|
48
|
+
* @param args The command arguments (the first is the sub-command)
|
|
46
49
|
*/
|
|
47
50
|
execute(args) {
|
|
48
51
|
const { callback, showHelp } = this.options;
|
|
@@ -82,7 +85,7 @@ class CLICert extends import_cliCommand.CLICommand {
|
|
|
82
85
|
/**
|
|
83
86
|
* View the certificates on CLI
|
|
84
87
|
*
|
|
85
|
-
* @param _args
|
|
88
|
+
* @param _args The command arguments (the second is the certificate name)
|
|
86
89
|
*/
|
|
87
90
|
view(_args) {
|
|
88
91
|
let certName = _args[1];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/cli/cliCert.ts"],
|
|
4
|
-
"sourcesContent": ["import { CLICommand, type CLICommandOptions } from './cliCommand.js';\nimport { CLIObjects } from './cliObjects.js';\nimport * as messages from './messages.js';\nimport { tools, EXIT_CODES } from '@iobroker/js-controller-common';\n\n/** Command ioBroker cert ... */\nexport class CLICert extends CLICommand {\n constructor(options: CLICommandOptions) {\n super(options);\n }\n\n /**\n * Executes a command\n *\n * @param args\n */\n execute(args: any[]): void | Promise<void> {\n const { callback, showHelp } = this.options;\n const command = args[0];\n\n switch (command) {\n case 'renew':\n case 'create':\n return this.create();\n case 'view':\n return this.view(args);\n default:\n messages.error.unknownCommand('cert', command);\n showHelp();\n return void callback(3);\n }\n }\n\n /**\n * Create new private certificate\n */\n async create(): Promise<void> {\n const id = 'system.certificates';\n const certPropPath = 'native.certificates';\n\n const certificates = tools.generateDefaultCertificates();\n if (certificates) {\n console.log(JSON.stringify(certificates, null, 2));\n for (const [certName, cert] of Object.entries(certificates)) {\n // use the command `iobroker object set ...` to update the certificate\n console.log(`Update certificate ${certName}`);\n\n const objectsCommandArgs = ['set', id, `${certPropPath}.${certName}=${cert as string}`];\n await new Promise(resolve => {\n const objectsCommand = new CLIObjects({ ...this.options, callback: resolve });\n objectsCommand.execute(objectsCommandArgs);\n });\n }\n }\n\n this.options.callback(EXIT_CODES.NO_ERROR);\n }\n\n /**\n * View the certificates on CLI\n *\n * @param _args\n */\n view(_args: any[]): void {\n let certName = _args[1];\n if (certName === undefined) {\n certName = 'defaultPublic';\n }\n const { callback, dbConnect } = this.options;\n dbConnect(params => {\n const { objects } = params;\n\n objects.getObject('system.certificates', (err, certs) => {\n if (!err && certs?.native?.certificates?.[certName]) {\n const certInfo = tools.getCertificateInfo(certs.native.certificates[certName]);\n if (certInfo) {\n console.log(JSON.stringify(certInfo, null, 2));\n return void callback(EXIT_CODES.NO_ERROR);\n }\n messages.error.cert(certName);\n return void callback(3);\n }\n messages.error.cert(certName);\n return void callback(3);\n });\n });\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAAA,wBAAmD;AACnD,wBAA2B;AAC3B,eAA0B;AAC1B,kCAAkC;AAG5B,MAAO,gBAAgB,6BAAU
|
|
4
|
+
"sourcesContent": ["import { CLICommand, type CLICommandOptions } from './cliCommand.js';\nimport { CLIObjects } from './cliObjects.js';\nimport * as messages from './messages.js';\nimport { tools, EXIT_CODES } from '@iobroker/js-controller-common';\n\n/** Command ioBroker cert ... */\nexport class CLICert extends CLICommand {\n /**\n * @param options The command options including context and parameters\n */\n constructor(options: CLICommandOptions) {\n super(options);\n }\n\n /**\n * Executes a command\n *\n * @param args The command arguments (the first is the sub-command)\n */\n execute(args: any[]): void | Promise<void> {\n const { callback, showHelp } = this.options;\n const command = args[0];\n\n switch (command) {\n case 'renew':\n case 'create':\n return this.create();\n case 'view':\n return this.view(args);\n default:\n messages.error.unknownCommand('cert', command);\n showHelp();\n return void callback(3);\n }\n }\n\n /**\n * Create new private certificate\n */\n async create(): Promise<void> {\n const id = 'system.certificates';\n const certPropPath = 'native.certificates';\n\n const certificates = tools.generateDefaultCertificates();\n if (certificates) {\n console.log(JSON.stringify(certificates, null, 2));\n for (const [certName, cert] of Object.entries(certificates)) {\n // use the command `iobroker object set ...` to update the certificate\n console.log(`Update certificate ${certName}`);\n\n const objectsCommandArgs = ['set', id, `${certPropPath}.${certName}=${cert as string}`];\n await new Promise(resolve => {\n const objectsCommand = new CLIObjects({ ...this.options, callback: resolve });\n objectsCommand.execute(objectsCommandArgs);\n });\n }\n }\n\n this.options.callback(EXIT_CODES.NO_ERROR);\n }\n\n /**\n * View the certificates on CLI\n *\n * @param _args The command arguments (the second is the certificate name)\n */\n view(_args: any[]): void {\n let certName = _args[1];\n if (certName === undefined) {\n certName = 'defaultPublic';\n }\n const { callback, dbConnect } = this.options;\n dbConnect(params => {\n const { objects } = params;\n\n objects.getObject('system.certificates', (err, certs) => {\n if (!err && certs?.native?.certificates?.[certName]) {\n const certInfo = tools.getCertificateInfo(certs.native.certificates[certName]);\n if (certInfo) {\n console.log(JSON.stringify(certInfo, null, 2));\n return void callback(EXIT_CODES.NO_ERROR);\n }\n messages.error.cert(certName);\n return void callback(3);\n }\n messages.error.cert(certName);\n return void callback(3);\n });\n });\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAAA,wBAAmD;AACnD,wBAA2B;AAC3B,eAA0B;AAC1B,kCAAkC;AAG5B,MAAO,gBAAgB,6BAAU;;;;EAInC,YAAY,SAA0B;AAClC,UAAM,OAAO;EACjB;;;;;;EAOA,QAAQ,MAAW;AACf,UAAM,EAAE,UAAU,SAAQ,IAAK,KAAK;AACpC,UAAM,UAAU,KAAK,CAAC;AAEtB,YAAQ,SAAS;MACb,KAAK;MACL,KAAK;AACD,eAAO,KAAK,OAAM;MACtB,KAAK;AACD,eAAO,KAAK,KAAK,IAAI;MACzB;AACI,iBAAS,MAAM,eAAe,QAAQ,OAAO;AAC7C,iBAAQ;AACR,eAAO,KAAK,SAAS,CAAC;IAC9B;EACJ;;;;EAKA,MAAM,SAAM;AACR,UAAM,KAAK;AACX,UAAM,eAAe;AAErB,UAAM,eAAe,kCAAM,4BAA2B;AACtD,QAAI,cAAc;AACd,cAAQ,IAAI,KAAK,UAAU,cAAc,MAAM,CAAC,CAAC;AACjD,iBAAW,CAAC,UAAU,IAAI,KAAK,OAAO,QAAQ,YAAY,GAAG;AAEzD,gBAAQ,IAAI,sBAAsB,QAAQ,EAAE;AAE5C,cAAM,qBAAqB,CAAC,OAAO,IAAI,GAAG,YAAY,IAAI,QAAQ,IAAI,IAAc,EAAE;AACtF,cAAM,IAAI,QAAQ,aAAU;AACxB,gBAAM,iBAAiB,IAAI,6BAAW,EAAE,GAAG,KAAK,SAAS,UAAU,QAAO,CAAE;AAC5E,yBAAe,QAAQ,kBAAkB;QAC7C,CAAC;MACL;IACJ;AAEA,SAAK,QAAQ,SAAS,uCAAW,QAAQ;EAC7C;;;;;;EAOA,KAAK,OAAY;AACb,QAAI,WAAW,MAAM,CAAC;AACtB,QAAI,aAAa,QAAW;AACxB,iBAAW;IACf;AACA,UAAM,EAAE,UAAU,UAAS,IAAK,KAAK;AACrC,cAAU,YAAS;AACf,YAAM,EAAE,QAAO,IAAK;AAEpB,cAAQ,UAAU,uBAAuB,CAAC,KAAK,UAAS;AACpD,YAAI,CAAC,OAAO,OAAO,QAAQ,eAAe,QAAQ,GAAG;AACjD,gBAAM,WAAW,kCAAM,mBAAmB,MAAM,OAAO,aAAa,QAAQ,CAAC;AAC7E,cAAI,UAAU;AACV,oBAAQ,IAAI,KAAK,UAAU,UAAU,MAAM,CAAC,CAAC;AAC7C,mBAAO,KAAK,SAAS,uCAAW,QAAQ;UAC5C;AACA,mBAAS,MAAM,KAAK,QAAQ;AAC5B,iBAAO,KAAK,SAAS,CAAC;QAC1B;AACA,iBAAS,MAAM,KAAK,QAAQ;AAC5B,eAAO,KAAK,SAAS,CAAC;MAC1B,CAAC;IACL,CAAC;EACL;;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,46 +1,77 @@
|
|
|
1
1
|
import type { DbConnectCallback } from '../_Types.js';
|
|
2
|
+
/** Context provided to every CLI command */
|
|
2
3
|
export interface CLICommandContext {
|
|
3
4
|
/** Invoke this before doing anything in the database */
|
|
4
5
|
dbConnect: (callback: DbConnectCallback) => void;
|
|
6
|
+
/** Finish the command with the given exit code */
|
|
5
7
|
callback: (code?: number) => void;
|
|
8
|
+
/** Show the command help */
|
|
6
9
|
showHelp: (yargs?: any) => void;
|
|
7
10
|
}
|
|
11
|
+
/** Parameters (CLI flags) that may be passed to a command */
|
|
8
12
|
export interface CLICommandParams {
|
|
13
|
+
/** Text encoding to use for output */
|
|
9
14
|
encoding?: BufferEncoding;
|
|
15
|
+
/** Pretty-print the output */
|
|
10
16
|
pretty?: boolean;
|
|
17
|
+
/** Force the operation even if it would normally be refused */
|
|
11
18
|
force?: boolean;
|
|
19
|
+
/** Password to use */
|
|
12
20
|
password?: any;
|
|
21
|
+
/** Restrict the operation to the given group */
|
|
13
22
|
ingroup?: any;
|
|
23
|
+
/** Short alias for the version flag */
|
|
14
24
|
v?: any;
|
|
25
|
+
/** Show the version */
|
|
15
26
|
version?: any;
|
|
27
|
+
/** Timeout in milliseconds */
|
|
16
28
|
timeout?: any;
|
|
29
|
+
/** Only include enabled instances */
|
|
17
30
|
enabled?: any;
|
|
31
|
+
/** Only include disabled instances */
|
|
18
32
|
disabled?: any;
|
|
33
|
+
/** Port to use */
|
|
19
34
|
port?: any;
|
|
35
|
+
/** Use SSL */
|
|
20
36
|
ssl?: any;
|
|
37
|
+
/** IP address to bind to */
|
|
21
38
|
ip?: any;
|
|
39
|
+
/** Only include updatable adapters */
|
|
22
40
|
updatable?: any;
|
|
41
|
+
/** Host to operate on */
|
|
23
42
|
host?: any;
|
|
43
|
+
/** Certificate to use */
|
|
24
44
|
cert?: any;
|
|
45
|
+
/** Working directory */
|
|
25
46
|
cwd?: string;
|
|
47
|
+
/** File system path */
|
|
26
48
|
path?: string;
|
|
49
|
+
/** Module name */
|
|
27
50
|
module?: string;
|
|
51
|
+
/** Wait for the operation to complete */
|
|
28
52
|
wait?: boolean;
|
|
53
|
+
/** Automatically answer yes to confirmation prompts */
|
|
29
54
|
yes?: boolean;
|
|
55
|
+
/** Short alias for force */
|
|
30
56
|
f?: boolean;
|
|
57
|
+
/** Short alias for yes */
|
|
31
58
|
y?: boolean;
|
|
59
|
+
/** Apply the operation to all matching items */
|
|
32
60
|
all?: boolean;
|
|
33
61
|
}
|
|
34
62
|
export type CLICommandOptions = CLICommandContext & CLICommandParams;
|
|
35
63
|
/** The base class for any CLI command */
|
|
36
64
|
export declare class CLICommand<TCommandOptions extends CLICommandOptions = CLICommandOptions> {
|
|
37
65
|
protected readonly options: TCommandOptions;
|
|
66
|
+
/**
|
|
67
|
+
* @param options The command options including the context (callback, dbConnect) and parameters
|
|
68
|
+
*/
|
|
38
69
|
constructor(options: TCommandOptions);
|
|
39
70
|
/**
|
|
40
71
|
* Ensures that an argument was passed in the options.
|
|
41
72
|
* Throws otherwise
|
|
42
73
|
*
|
|
43
|
-
* @param arg
|
|
74
|
+
* @param arg The name of the option that is required
|
|
44
75
|
*/
|
|
45
76
|
requireOption(arg: keyof CLICommandOptions): void;
|
|
46
77
|
}
|
|
@@ -23,6 +23,9 @@ __export(cliCommand_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(cliCommand_exports);
|
|
24
24
|
class CLICommand {
|
|
25
25
|
options;
|
|
26
|
+
/**
|
|
27
|
+
* @param options The command options including the context (callback, dbConnect) and parameters
|
|
28
|
+
*/
|
|
26
29
|
constructor(options) {
|
|
27
30
|
if (options === null || options === void 0) {
|
|
28
31
|
throw new Error(`No options given`);
|
|
@@ -35,7 +38,7 @@ class CLICommand {
|
|
|
35
38
|
* Ensures that an argument was passed in the options.
|
|
36
39
|
* Throws otherwise
|
|
37
40
|
*
|
|
38
|
-
* @param arg
|
|
41
|
+
* @param arg The name of the option that is required
|
|
39
42
|
*/
|
|
40
43
|
requireOption(arg) {
|
|
41
44
|
if (this.options[arg] === void 0) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/cli/cliCommand.ts"],
|
|
4
|
-
"sourcesContent": ["import type { DbConnectCallback } from '../_Types.js';\n\nexport interface CLICommandContext {\n /** Invoke this before doing anything in the database */\n dbConnect: (callback: DbConnectCallback) => void;\n callback: (code?: number) => void;\n showHelp: (yargs?: any) => void;\n}\n\nexport interface CLICommandParams {\n encoding?: BufferEncoding;\n pretty?: boolean;\n force?: boolean;\n password?: any;\n ingroup?: any;\n v?: any;\n version?: any;\n timeout?: any;\n enabled?: any;\n disabled?: any;\n port?: any;\n ssl?: any;\n ip?: any;\n updatable?: any;\n host?: any;\n cert?: any;\n cwd?: string;\n path?: string;\n module?: string;\n wait?: boolean;\n yes?: boolean;\n f?: boolean;\n y?: boolean;\n all?: boolean;\n}\n\nexport type CLICommandOptions = CLICommandContext & CLICommandParams;\n\n/** The base class for any CLI command */\nexport class CLICommand<TCommandOptions extends CLICommandOptions = CLICommandOptions> {\n protected readonly options: TCommandOptions;\n\n constructor(options: TCommandOptions) {\n if (options === null || options === undefined) {\n throw new Error(`No options given`);\n }\n\n this.options = options;\n // Always require the callback and a wrapper for DB actions\n this.requireOption('callback');\n this.requireOption('dbConnect');\n }\n\n /**\n * Ensures that an argument was passed in the options.\n * Throws otherwise\n *\n * @param arg\n */\n requireOption(arg: keyof CLICommandOptions): void {\n if (this.options[arg] === undefined) {\n throw new Error(`Invalid arguments: ${arg} is missing`);\n }\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;
|
|
4
|
+
"sourcesContent": ["import type { DbConnectCallback } from '../_Types.js';\n\n/** Context provided to every CLI command */\nexport interface CLICommandContext {\n /** Invoke this before doing anything in the database */\n dbConnect: (callback: DbConnectCallback) => void;\n /** Finish the command with the given exit code */\n callback: (code?: number) => void;\n /** Show the command help */\n showHelp: (yargs?: any) => void;\n}\n\n/** Parameters (CLI flags) that may be passed to a command */\nexport interface CLICommandParams {\n /** Text encoding to use for output */\n encoding?: BufferEncoding;\n /** Pretty-print the output */\n pretty?: boolean;\n /** Force the operation even if it would normally be refused */\n force?: boolean;\n /** Password to use */\n password?: any;\n /** Restrict the operation to the given group */\n ingroup?: any;\n /** Short alias for the version flag */\n v?: any;\n /** Show the version */\n version?: any;\n /** Timeout in milliseconds */\n timeout?: any;\n /** Only include enabled instances */\n enabled?: any;\n /** Only include disabled instances */\n disabled?: any;\n /** Port to use */\n port?: any;\n /** Use SSL */\n ssl?: any;\n /** IP address to bind to */\n ip?: any;\n /** Only include updatable adapters */\n updatable?: any;\n /** Host to operate on */\n host?: any;\n /** Certificate to use */\n cert?: any;\n /** Working directory */\n cwd?: string;\n /** File system path */\n path?: string;\n /** Module name */\n module?: string;\n /** Wait for the operation to complete */\n wait?: boolean;\n /** Automatically answer yes to confirmation prompts */\n yes?: boolean;\n /** Short alias for force */\n f?: boolean;\n /** Short alias for yes */\n y?: boolean;\n /** Apply the operation to all matching items */\n all?: boolean;\n}\n\nexport type CLICommandOptions = CLICommandContext & CLICommandParams;\n\n/** The base class for any CLI command */\nexport class CLICommand<TCommandOptions extends CLICommandOptions = CLICommandOptions> {\n protected readonly options: TCommandOptions;\n\n /**\n * @param options The command options including the context (callback, dbConnect) and parameters\n */\n constructor(options: TCommandOptions) {\n if (options === null || options === undefined) {\n throw new Error(`No options given`);\n }\n\n this.options = options;\n // Always require the callback and a wrapper for DB actions\n this.requireOption('callback');\n this.requireOption('dbConnect');\n }\n\n /**\n * Ensures that an argument was passed in the options.\n * Throws otherwise\n *\n * @param arg The name of the option that is required\n */\n requireOption(arg: keyof CLICommandOptions): void {\n if (this.options[arg] === undefined) {\n throw new Error(`Invalid arguments: ${arg} is missing`);\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAkEA;;;;;AACM,MAAO,WAAU;EACA;;;;EAKnB,YAAY,SAAwB;AAChC,QAAI,YAAY,QAAQ,YAAY,QAAW;AAC3C,YAAM,IAAI,MAAM,kBAAkB;IACtC;AAEA,SAAK,UAAU;AAEf,SAAK,cAAc,UAAU;AAC7B,SAAK,cAAc,WAAW;EAClC;;;;;;;EAQA,cAAc,KAA4B;AACtC,QAAI,KAAK,QAAQ,GAAG,MAAM,QAAW;AACjC,YAAM,IAAI,MAAM,sBAAsB,GAAG,aAAa;IAC1D;EACJ;;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,11 +2,14 @@ import { CLICommand, type CLICommandOptions } from './cliCommand.js';
|
|
|
2
2
|
/** Command ioBroker compact ... */
|
|
3
3
|
export declare class CLICompact extends CLICommand {
|
|
4
4
|
private readonly config;
|
|
5
|
+
/**
|
|
6
|
+
* @param options The command options including context and parameters
|
|
7
|
+
*/
|
|
5
8
|
constructor(options: CLICommandOptions);
|
|
6
9
|
/**
|
|
7
10
|
* Executes a command
|
|
8
11
|
*
|
|
9
|
-
* @param args
|
|
12
|
+
* @param args The command arguments (the first is the sub-command)
|
|
10
13
|
*/
|
|
11
14
|
execute(args: any[]): void;
|
|
12
15
|
/**
|
|
@@ -37,13 +37,16 @@ var import_js_controller_common = require("@iobroker/js-controller-common");
|
|
|
37
37
|
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
38
38
|
class CLICompact extends import_cliCommand.CLICommand {
|
|
39
39
|
config = import_fs_extra.default.readJSONSync(import_js_controller_common.tools.getConfigFileName());
|
|
40
|
+
/**
|
|
41
|
+
* @param options The command options including context and parameters
|
|
42
|
+
*/
|
|
40
43
|
constructor(options) {
|
|
41
44
|
super(options);
|
|
42
45
|
}
|
|
43
46
|
/**
|
|
44
47
|
* Executes a command
|
|
45
48
|
*
|
|
46
|
-
* @param args
|
|
49
|
+
* @param args The command arguments (the first is the sub-command)
|
|
47
50
|
*/
|
|
48
51
|
execute(args) {
|
|
49
52
|
const { callback, showHelp } = this.options;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/cli/cliCompact.ts"],
|
|
4
|
-
"sourcesContent": ["import * as CLI from './messages.js';\nimport { CLICommand, type CLICommandOptions } from './cliCommand.js';\nimport { tools } from '@iobroker/js-controller-common';\nimport fs from 'fs-extra';\n\n/** Command ioBroker compact ... */\nexport class CLICompact extends CLICommand {\n private readonly config: ioBroker.IoBrokerJson = fs.readJSONSync(tools.getConfigFileName());\n\n constructor(options: CLICommandOptions) {\n super(options);\n }\n /**\n * Executes a command\n *\n * @param args\n */\n execute(args: any[]): void {\n const { callback, showHelp } = this.options;\n const command = args[0];\n switch (command) {\n case 'status':\n return this.statusCompactModeHost();\n case 'enable':\n case 'on':\n return this.setCompactModeHost(true);\n case 'disable':\n case 'off':\n return this.setCompactModeHost(false);\n default:\n if (command && command.includes('.')) {\n if (args[1]) {\n switch (args[1]) {\n case 'status':\n return this.statusCompactModeInstance(command);\n case 'enable':\n case 'on':\n return this.setCompactModeInstance(command, true, args[2]);\n case 'disable':\n case 'off':\n return this.setCompactModeInstance(command, false);\n case 'group':\n return this.setCompactModeInstance(command, undefined, args[2]);\n }\n }\n }\n\n CLI.error.unknownCommand('compact', command);\n showHelp();\n return void callback(3);\n }\n }\n\n /**\n * Output status of compact mode for host\n */\n statusCompactModeHost(): void {\n const { callback } = this.options;\n\n const compactMode = !!this.config?.system?.compact;\n console.log(`Compact mode for this host is currently ${compactMode ? 'enabled' : 'disabled'}`);\n\n return void callback();\n }\n\n /**\n * Set compact mode for this host\n *\n * @param targetState enable or disable compact mode for host\n */\n setCompactModeHost(targetState: boolean): void {\n const { callback, dbConnect } = this.options;\n\n dbConnect(params => {\n const { isOffline } = params;\n\n const currentState = !!this.config?.system?.compact;\n\n if (targetState === currentState) {\n console.log(`Compact mode for this host is already ${currentState ? 'enabled' : 'disabled'}`);\n return void callback();\n }\n\n this.config.system = this.config.system || {};\n this.config.system.compact = targetState;\n const configFileName = tools.getConfigFileName();\n fs.writeFileSync(configFileName, JSON.stringify(this.config, null, 4), 'utf8');\n\n console.log();\n console.log(`Compact mode for this host is now ${targetState ? 'enabled' : 'disabled'}`);\n\n if (!isOffline) {\n console.log();\n console.log('Please restart ioBroker for this change to take effect!');\n }\n return void callback();\n });\n }\n\n /**\n * Output the compact mode status for a defined adapter instance\n *\n * @param instance instance to output status for\n */\n statusCompactModeInstance(instance: `${string}.${number}`): void {\n const { callback, dbConnect } = this.options;\n\n dbConnect(params => {\n const { objects } = params;\n\n if (!this.config.system?.compact) {\n console.log('Compact mode is disabled for this host. All compact mode settings will have no effect!');\n console.log();\n }\n objects.getObject(`system.adapter.${instance}`, (err, obj) => {\n if (!err && obj) {\n if (!obj.common.compact) {\n console.log(\n 'This adapter does not support compact mode. The below settings will have no effect!',\n );\n console.log();\n } else {\n console.log(`Adapter supports compact mode: ${!!obj.common.compact}`);\n }\n console.log(`Compact mode enabled for instance: ${!!obj.common.runAsCompactMode}`);\n console.log(\n `Compact group: ${\n obj.common.compactGroup !== undefined ? obj.common.compactGroup : 1\n }`,\n );\n return void callback();\n }\n CLI.error.invalidInstance(instance);\n return void callback(24);\n });\n });\n }\n\n /**\n * Put given instance in compact mode group\n *\n * @param instance instance to put in group\n * @param targetState if compact mode should be enabled for instance, if undefined `instance.common.runAsCompact` will not be updated\n * @param groupId the compact group id, if not given, it will be put in controller group\n */\n setCompactModeInstance(instance: `${string}.${number}`, targetState?: boolean, groupId?: string | number): void {\n const { callback, dbConnect } = this.options;\n\n dbConnect(async params => {\n const { objects } = params;\n\n if (!this.config.system?.compact) {\n console.log('Compact mode is disabled on this host. This setting will have no effect!');\n console.log();\n }\n\n let obj: ioBroker.InstanceObject | undefined | null;\n try {\n obj = await objects.getObject(`system.adapter.${instance}`);\n } catch {\n // ignore\n }\n\n if (!obj) {\n CLI.error.invalidInstance(instance);\n return void callback(24);\n }\n\n if (!obj.common.compact) {\n console.log('This adapter does not support compact mode. The below settings will have no effect!');\n console.log();\n } else {\n console.log(`Adapter supports compact mode : ${!!obj.common.compact}`);\n }\n let newRunAsCompactMode;\n if (targetState !== undefined && targetState !== !!obj.common.runAsCompactMode) {\n newRunAsCompactMode = targetState;\n }\n let newCompactGroup;\n if (obj.common.compactGroup === undefined) {\n obj.common.compactGroup = 1;\n newCompactGroup = obj.common.compactGroup;\n }\n if (groupId !== undefined) {\n groupId = typeof groupId === 'string' ? parseInt(groupId, 10) : groupId;\n if (groupId !== obj.common.compactGroup) {\n newCompactGroup = groupId;\n }\n }\n console.log(\n `Compact mode enabled for instance: ${\n newRunAsCompactMode !== undefined ? `--> ${newRunAsCompactMode}` : !!obj.common.runAsCompactMode\n }`,\n );\n console.log(\n `Compact group: ${\n newCompactGroup !== undefined && obj.common.compactGroup !== newCompactGroup\n ? `--> ${newCompactGroup}`\n : obj.common.compactGroup\n }`,\n );\n if (newRunAsCompactMode !== undefined || newCompactGroup !== undefined) {\n if (newCompactGroup !== undefined) {\n obj.common.compactGroup = newCompactGroup;\n }\n if (newRunAsCompactMode !== undefined) {\n obj.common.runAsCompactMode = newRunAsCompactMode;\n }\n\n obj.from = `system.host.${tools.getHostName()}.cli`;\n obj.ts = new Date().getTime();\n objects.setObject(`system.adapter.${instance}`, obj, err => {\n if (err) {\n console.log(err);\n }\n console.log(`Instance settings for \"${instance}\" are changed.`);\n callback();\n });\n } else {\n console.log('No settings changed.');\n return void callback();\n }\n });\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAAA,UAAqB;AACrB,wBAAmD;AACnD,kCAAsB;AACtB,sBAAe;AAGT,MAAO,mBAAmB,6BAAU;EACrB,SAAgC,gBAAAA,QAAG,aAAa,kCAAM,kBAAiB,CAAE
|
|
4
|
+
"sourcesContent": ["import * as CLI from './messages.js';\nimport { CLICommand, type CLICommandOptions } from './cliCommand.js';\nimport { tools } from '@iobroker/js-controller-common';\nimport fs from 'fs-extra';\n\n/** Command ioBroker compact ... */\nexport class CLICompact extends CLICommand {\n private readonly config: ioBroker.IoBrokerJson = fs.readJSONSync(tools.getConfigFileName());\n\n /**\n * @param options The command options including context and parameters\n */\n constructor(options: CLICommandOptions) {\n super(options);\n }\n /**\n * Executes a command\n *\n * @param args The command arguments (the first is the sub-command)\n */\n execute(args: any[]): void {\n const { callback, showHelp } = this.options;\n const command = args[0];\n switch (command) {\n case 'status':\n return this.statusCompactModeHost();\n case 'enable':\n case 'on':\n return this.setCompactModeHost(true);\n case 'disable':\n case 'off':\n return this.setCompactModeHost(false);\n default:\n if (command && command.includes('.')) {\n if (args[1]) {\n switch (args[1]) {\n case 'status':\n return this.statusCompactModeInstance(command);\n case 'enable':\n case 'on':\n return this.setCompactModeInstance(command, true, args[2]);\n case 'disable':\n case 'off':\n return this.setCompactModeInstance(command, false);\n case 'group':\n return this.setCompactModeInstance(command, undefined, args[2]);\n }\n }\n }\n\n CLI.error.unknownCommand('compact', command);\n showHelp();\n return void callback(3);\n }\n }\n\n /**\n * Output status of compact mode for host\n */\n statusCompactModeHost(): void {\n const { callback } = this.options;\n\n const compactMode = !!this.config?.system?.compact;\n console.log(`Compact mode for this host is currently ${compactMode ? 'enabled' : 'disabled'}`);\n\n return void callback();\n }\n\n /**\n * Set compact mode for this host\n *\n * @param targetState enable or disable compact mode for host\n */\n setCompactModeHost(targetState: boolean): void {\n const { callback, dbConnect } = this.options;\n\n dbConnect(params => {\n const { isOffline } = params;\n\n const currentState = !!this.config?.system?.compact;\n\n if (targetState === currentState) {\n console.log(`Compact mode for this host is already ${currentState ? 'enabled' : 'disabled'}`);\n return void callback();\n }\n\n this.config.system = this.config.system || {};\n this.config.system.compact = targetState;\n const configFileName = tools.getConfigFileName();\n fs.writeFileSync(configFileName, JSON.stringify(this.config, null, 4), 'utf8');\n\n console.log();\n console.log(`Compact mode for this host is now ${targetState ? 'enabled' : 'disabled'}`);\n\n if (!isOffline) {\n console.log();\n console.log('Please restart ioBroker for this change to take effect!');\n }\n return void callback();\n });\n }\n\n /**\n * Output the compact mode status for a defined adapter instance\n *\n * @param instance instance to output status for\n */\n statusCompactModeInstance(instance: `${string}.${number}`): void {\n const { callback, dbConnect } = this.options;\n\n dbConnect(params => {\n const { objects } = params;\n\n if (!this.config.system?.compact) {\n console.log('Compact mode is disabled for this host. All compact mode settings will have no effect!');\n console.log();\n }\n objects.getObject(`system.adapter.${instance}`, (err, obj) => {\n if (!err && obj) {\n if (!obj.common.compact) {\n console.log(\n 'This adapter does not support compact mode. The below settings will have no effect!',\n );\n console.log();\n } else {\n console.log(`Adapter supports compact mode: ${!!obj.common.compact}`);\n }\n console.log(`Compact mode enabled for instance: ${!!obj.common.runAsCompactMode}`);\n console.log(\n `Compact group: ${\n obj.common.compactGroup !== undefined ? obj.common.compactGroup : 1\n }`,\n );\n return void callback();\n }\n CLI.error.invalidInstance(instance);\n return void callback(24);\n });\n });\n }\n\n /**\n * Put given instance in compact mode group\n *\n * @param instance instance to put in group\n * @param targetState if compact mode should be enabled for instance, if undefined `instance.common.runAsCompact` will not be updated\n * @param groupId the compact group id, if not given, it will be put in controller group\n */\n setCompactModeInstance(instance: `${string}.${number}`, targetState?: boolean, groupId?: string | number): void {\n const { callback, dbConnect } = this.options;\n\n dbConnect(async params => {\n const { objects } = params;\n\n if (!this.config.system?.compact) {\n console.log('Compact mode is disabled on this host. This setting will have no effect!');\n console.log();\n }\n\n let obj: ioBroker.InstanceObject | undefined | null;\n try {\n obj = await objects.getObject(`system.adapter.${instance}`);\n } catch {\n // ignore\n }\n\n if (!obj) {\n CLI.error.invalidInstance(instance);\n return void callback(24);\n }\n\n if (!obj.common.compact) {\n console.log('This adapter does not support compact mode. The below settings will have no effect!');\n console.log();\n } else {\n console.log(`Adapter supports compact mode : ${!!obj.common.compact}`);\n }\n let newRunAsCompactMode;\n if (targetState !== undefined && targetState !== !!obj.common.runAsCompactMode) {\n newRunAsCompactMode = targetState;\n }\n let newCompactGroup;\n if (obj.common.compactGroup === undefined) {\n obj.common.compactGroup = 1;\n newCompactGroup = obj.common.compactGroup;\n }\n if (groupId !== undefined) {\n groupId = typeof groupId === 'string' ? parseInt(groupId, 10) : groupId;\n if (groupId !== obj.common.compactGroup) {\n newCompactGroup = groupId;\n }\n }\n console.log(\n `Compact mode enabled for instance: ${\n newRunAsCompactMode !== undefined ? `--> ${newRunAsCompactMode}` : !!obj.common.runAsCompactMode\n }`,\n );\n console.log(\n `Compact group: ${\n newCompactGroup !== undefined && obj.common.compactGroup !== newCompactGroup\n ? `--> ${newCompactGroup}`\n : obj.common.compactGroup\n }`,\n );\n if (newRunAsCompactMode !== undefined || newCompactGroup !== undefined) {\n if (newCompactGroup !== undefined) {\n obj.common.compactGroup = newCompactGroup;\n }\n if (newRunAsCompactMode !== undefined) {\n obj.common.runAsCompactMode = newRunAsCompactMode;\n }\n\n obj.from = `system.host.${tools.getHostName()}.cli`;\n obj.ts = new Date().getTime();\n objects.setObject(`system.adapter.${instance}`, obj, err => {\n if (err) {\n console.log(err);\n }\n console.log(`Instance settings for \"${instance}\" are changed.`);\n callback();\n });\n } else {\n console.log('No settings changed.');\n return void callback();\n }\n });\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAAA,UAAqB;AACrB,wBAAmD;AACnD,kCAAsB;AACtB,sBAAe;AAGT,MAAO,mBAAmB,6BAAU;EACrB,SAAgC,gBAAAA,QAAG,aAAa,kCAAM,kBAAiB,CAAE;;;;EAK1F,YAAY,SAA0B;AAClC,UAAM,OAAO;EACjB;;;;;;EAMA,QAAQ,MAAW;AACf,UAAM,EAAE,UAAU,SAAQ,IAAK,KAAK;AACpC,UAAM,UAAU,KAAK,CAAC;AACtB,YAAQ,SAAS;MACb,KAAK;AACD,eAAO,KAAK,sBAAqB;MACrC,KAAK;MACL,KAAK;AACD,eAAO,KAAK,mBAAmB,IAAI;MACvC,KAAK;MACL,KAAK;AACD,eAAO,KAAK,mBAAmB,KAAK;MACxC;AACI,YAAI,WAAW,QAAQ,SAAS,GAAG,GAAG;AAClC,cAAI,KAAK,CAAC,GAAG;AACT,oBAAQ,KAAK,CAAC,GAAG;cACb,KAAK;AACD,uBAAO,KAAK,0BAA0B,OAAO;cACjD,KAAK;cACL,KAAK;AACD,uBAAO,KAAK,uBAAuB,SAAS,MAAM,KAAK,CAAC,CAAC;cAC7D,KAAK;cACL,KAAK;AACD,uBAAO,KAAK,uBAAuB,SAAS,KAAK;cACrD,KAAK;AACD,uBAAO,KAAK,uBAAuB,SAAS,QAAW,KAAK,CAAC,CAAC;YACtE;UACJ;QACJ;AAEA,YAAI,MAAM,eAAe,WAAW,OAAO;AAC3C,iBAAQ;AACR,eAAO,KAAK,SAAS,CAAC;IAC9B;EACJ;;;;EAKA,wBAAqB;AACjB,UAAM,EAAE,SAAQ,IAAK,KAAK;AA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AO,cAAc;AACrC,4BAAkB;QACtB;MACJ;AACA,cAAQ,IACJ,sCACI,wBAAwB,SAAY,OAAO,mBAAmB,KAAK,CAAC,CAAC,IAAI,OAAO,gBACpF,EAAE;AAEN,cAAQ,IACJ,sCACI,oBAAoB,UAAa,IAAI,OAAO,iBAAiB,kBACvD,OAAO,eAAe,KACtB,IAAI,OAAO,YACrB,EAAE;AAEN,UAAI,wBAAwB,UAAa,oBAAoB,QAAW;AACpE,YAAI,oBAAoB,QAAW;AAC/B,cAAI,OAAO,eAAe;QAC9B;AACA,YAAI,wBAAwB,QAAW;AACnC,cAAI,OAAO,mBAAmB;QAClC;AAEA,YAAI,OAAO,eAAe,kCAAM,YAAW,CAAE;AAC7C,YAAI,MAAK,oBAAI,KAAI,GAAG,QAAO;AAC3B,gBAAQ,UAAU,kBAAkB,QAAQ,IAAI,KAAK,SAAM;AACvD,cAAI,KAAK;AACL,oBAAQ,IAAI,GAAG;UACnB;AACA,kBAAQ,IAAI,0BAA0B,QAAQ,gBAAgB;AAC9D,mBAAQ;QACZ,CAAC;MACL,OAAO;AACH,gBAAQ,IAAI,sBAAsB;AAClC,eAAO,KAAK,SAAQ;MACxB;IACJ,CAAC;EACL;;",
|
|
6
6
|
"names": ["fs"]
|
|
7
7
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { CLICommand, type CLICommandOptions } from './cliCommand.js';
|
|
2
2
|
/** Command ioBroker debug ... */
|
|
3
3
|
export declare class CLIDebug extends CLICommand {
|
|
4
|
+
/**
|
|
5
|
+
* @param options The command options including context and parameters
|
|
6
|
+
*/
|
|
4
7
|
constructor(options: CLICommandOptions);
|
|
5
8
|
/**
|
|
6
9
|
* Checks if the adapter instance is running
|
|
@@ -12,7 +15,7 @@ export declare class CLIDebug extends CLICommand {
|
|
|
12
15
|
/**
|
|
13
16
|
* Executes a command
|
|
14
17
|
*
|
|
15
|
-
* @param args
|
|
18
|
+
* @param args The command arguments (the first is the adapter name)
|
|
16
19
|
*/
|
|
17
20
|
execute(args: any[]): Promise<void>;
|
|
18
21
|
}
|
|
@@ -37,6 +37,9 @@ var CLITools = __toESM(require("./cliTools.js"), 1);
|
|
|
37
37
|
var import_js_controller_common = require("@iobroker/js-controller-common");
|
|
38
38
|
var import_node_child_process = require("node:child_process");
|
|
39
39
|
class CLIDebug extends import_cliCommand.CLICommand {
|
|
40
|
+
/**
|
|
41
|
+
* @param options The command options including context and parameters
|
|
42
|
+
*/
|
|
40
43
|
constructor(options) {
|
|
41
44
|
super(options);
|
|
42
45
|
}
|
|
@@ -65,7 +68,7 @@ class CLIDebug extends import_cliCommand.CLICommand {
|
|
|
65
68
|
/**
|
|
66
69
|
* Executes a command
|
|
67
70
|
*
|
|
68
|
-
* @param args
|
|
71
|
+
* @param args The command arguments (the first is the adapter name)
|
|
69
72
|
*/
|
|
70
73
|
async execute(args) {
|
|
71
74
|
const { callback, ...params } = this.options;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/cli/cliDebug.ts"],
|
|
4
|
-
"sourcesContent": ["import * as CLI from './messages.js';\nimport { CLICommand, type CLICommandOptions } from './cliCommand.js';\nimport * as CLITools from './cliTools.js';\nimport { tools, EXIT_CODES } from '@iobroker/js-controller-common';\nimport { fork } from 'node:child_process';\n\n/** Command ioBroker debug ... */\nexport class CLIDebug extends CLICommand {\n constructor(options: CLICommandOptions) {\n super(options);\n }\n\n /**\n * Checks if the adapter instance is running\n *\n * @param adapter adapter name\n * @param instance instance id\n */\n private _isInstanceRunning(adapter: string, instance: string): Promise<boolean> {\n const { dbConnect } = this.options;\n return new Promise(resolve => {\n dbConnect(async ({ states }) => {\n try {\n const state = await states.getStateAsync(`system.adapter.${adapter}.${instance}.alive`);\n if (state?.val) {\n resolve(true);\n return;\n }\n } catch {\n // ignore\n }\n resolve(false);\n });\n });\n }\n\n /**\n * Executes a command\n *\n * @param args\n */\n async execute(args: any[]): Promise<void> {\n const { callback, ...params } = this.options;\n const adapter = args[0];\n if (!adapter) {\n CLI.error.requiredArgumentMissing('adaptername', 'debug <adaptername>');\n return void callback(34);\n }\n\n const { name, instance } = CLITools.splitAdapterOrInstanceIdentifierWithVersion(adapter)!;\n\n if (await this._isInstanceRunning(name, instance || '0')) {\n CLI.error.instanceAlreadyRunning(`${name}.${instance || '0'}`);\n return void callback(EXIT_CODES.ADAPTER_ALREADY_RUNNING);\n }\n\n const adapterDir = tools.getAdapterDir(adapter);\n if (!adapterDir) {\n CLI.error.adapterDirNotFound(adapter);\n return void callback(34);\n }\n\n let mainFile;\n try {\n mainFile = await tools.resolveAdapterMainFile(adapter);\n } catch {\n CLI.error.mainFileNotFound(adapter);\n return callback(1);\n }\n\n // Start the adapter with force and console logs\n const adapterArgs = [instance || '0', '--debug'];\n // Tell node to attach a debugger\n const nodeArgs = [\n ...tools.getDefaultNodeArgs(mainFile),\n // --inspect[-brk][=[ip]:[port]]\n `--inspect${params.wait ? '-brk' : ''}${!!params.ip || !!params.port ? '=' : ''}${params.ip || ''}${\n !!params.ip && !!params.port ? ':' : ''\n }${params.port || ''}`,\n ];\n // And wait until the sub process has finished\n const cp = fork(mainFile, adapterArgs, {\n cwd: adapterDir,\n execArgv: nodeArgs,\n });\n cp.on('exit', code => callback(code || 0));\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAAA,UAAqB;AACrB,wBAAmD;AACnD,eAA0B;AAC1B,kCAAkC;AAClC,gCAAqB;AAGf,MAAO,iBAAiB,6BAAU
|
|
4
|
+
"sourcesContent": ["import * as CLI from './messages.js';\nimport { CLICommand, type CLICommandOptions } from './cliCommand.js';\nimport * as CLITools from './cliTools.js';\nimport { tools, EXIT_CODES } from '@iobroker/js-controller-common';\nimport { fork } from 'node:child_process';\n\n/** Command ioBroker debug ... */\nexport class CLIDebug extends CLICommand {\n /**\n * @param options The command options including context and parameters\n */\n constructor(options: CLICommandOptions) {\n super(options);\n }\n\n /**\n * Checks if the adapter instance is running\n *\n * @param adapter adapter name\n * @param instance instance id\n */\n private _isInstanceRunning(adapter: string, instance: string): Promise<boolean> {\n const { dbConnect } = this.options;\n return new Promise(resolve => {\n dbConnect(async ({ states }) => {\n try {\n const state = await states.getStateAsync(`system.adapter.${adapter}.${instance}.alive`);\n if (state?.val) {\n resolve(true);\n return;\n }\n } catch {\n // ignore\n }\n resolve(false);\n });\n });\n }\n\n /**\n * Executes a command\n *\n * @param args The command arguments (the first is the adapter name)\n */\n async execute(args: any[]): Promise<void> {\n const { callback, ...params } = this.options;\n const adapter = args[0];\n if (!adapter) {\n CLI.error.requiredArgumentMissing('adaptername', 'debug <adaptername>');\n return void callback(34);\n }\n\n const { name, instance } = CLITools.splitAdapterOrInstanceIdentifierWithVersion(adapter)!;\n\n if (await this._isInstanceRunning(name, instance || '0')) {\n CLI.error.instanceAlreadyRunning(`${name}.${instance || '0'}`);\n return void callback(EXIT_CODES.ADAPTER_ALREADY_RUNNING);\n }\n\n const adapterDir = tools.getAdapterDir(adapter);\n if (!adapterDir) {\n CLI.error.adapterDirNotFound(adapter);\n return void callback(34);\n }\n\n let mainFile;\n try {\n mainFile = await tools.resolveAdapterMainFile(adapter);\n } catch {\n CLI.error.mainFileNotFound(adapter);\n return callback(1);\n }\n\n // Start the adapter with force and console logs\n const adapterArgs = [instance || '0', '--debug'];\n // Tell node to attach a debugger\n const nodeArgs = [\n ...tools.getDefaultNodeArgs(mainFile),\n // --inspect[-brk][=[ip]:[port]]\n `--inspect${params.wait ? '-brk' : ''}${!!params.ip || !!params.port ? '=' : ''}${params.ip || ''}${\n !!params.ip && !!params.port ? ':' : ''\n }${params.port || ''}`,\n ];\n // And wait until the sub process has finished\n const cp = fork(mainFile, adapterArgs, {\n cwd: adapterDir,\n execArgv: nodeArgs,\n });\n cp.on('exit', code => callback(code || 0));\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;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cAAc,CAAC,YAAY,KAAK,SAAS;AAE/C,UAAM,WAAW;MACb,GAAG,kCAAM,mBAAmB,QAAQ;;MAEpC,YAAY,OAAO,OAAO,SAAS,EAAE,GAAG,CAAC,CAAC,OAAO,MAAM,CAAC,CAAC,OAAO,OAAO,MAAM,EAAE,GAAG,OAAO,MAAM,EAAE,GAC7F,CAAC,CAAC,OAAO,MAAM,CAAC,CAAC,OAAO,OAAO,MAAM,EACzC,GAAG,OAAO,QAAQ,EAAE;;AAGxB,UAAM,SAAK,gCAAK,UAAU,aAAa;MACnC,KAAK;MACL,UAAU;KACb;AACD,OAAG,GAAG,QAAQ,UAAQ,SAAS,QAAQ,CAAC,CAAC;EAC7C;;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,35 +1,38 @@
|
|
|
1
1
|
import { CLICommand, type CLICommandOptions } from './cliCommand.js';
|
|
2
2
|
/** Command iobroker host ... */
|
|
3
3
|
export declare class CLIHost extends CLICommand {
|
|
4
|
+
/**
|
|
5
|
+
* @param options The command options including context and parameters
|
|
6
|
+
*/
|
|
4
7
|
constructor(options: CLICommandOptions);
|
|
5
8
|
/**
|
|
6
9
|
* Executes a command
|
|
7
10
|
*
|
|
8
|
-
* @param args
|
|
11
|
+
* @param args The command arguments (the first is the sub-command)
|
|
9
12
|
*/
|
|
10
13
|
execute(args: any[]): void;
|
|
11
14
|
/**
|
|
12
15
|
* When in single-host mode, changes the hostname of the host and all instances to the current one
|
|
13
16
|
*
|
|
14
|
-
* @param _args
|
|
17
|
+
* @param _args The command arguments (unused)
|
|
15
18
|
*/
|
|
16
19
|
self(_args: any[]): void;
|
|
17
20
|
/**
|
|
18
21
|
* Changes the current host's hostname to the given one
|
|
19
22
|
*
|
|
20
|
-
* @param args
|
|
23
|
+
* @param args The command arguments (the second is the new hostname)
|
|
21
24
|
*/
|
|
22
25
|
set(args: any[]): void;
|
|
23
26
|
/**
|
|
24
27
|
* Removes the host with the given name
|
|
25
28
|
*
|
|
26
|
-
* @param args
|
|
29
|
+
* @param args The command arguments (the second is the hostname to remove)
|
|
27
30
|
*/
|
|
28
31
|
remove(args: any[]): void;
|
|
29
32
|
/**
|
|
30
33
|
* Renames the host with the given name to the current one (opposite of `set()`)
|
|
31
34
|
*
|
|
32
|
-
* @param args
|
|
35
|
+
* @param args The command arguments (the second is the old hostname)
|
|
33
36
|
*/
|
|
34
37
|
rename(args: any[]): void;
|
|
35
38
|
/**
|
|
@@ -38,13 +38,16 @@ var import_js_controller_common = require("@iobroker/js-controller-common");
|
|
|
38
38
|
var import_node_os = __toESM(require("node:os"), 1);
|
|
39
39
|
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
40
40
|
class CLIHost extends import_cliCommand.CLICommand {
|
|
41
|
+
/**
|
|
42
|
+
* @param options The command options including context and parameters
|
|
43
|
+
*/
|
|
41
44
|
constructor(options) {
|
|
42
45
|
super(options);
|
|
43
46
|
}
|
|
44
47
|
/**
|
|
45
48
|
* Executes a command
|
|
46
49
|
*
|
|
47
|
-
* @param args
|
|
50
|
+
* @param args The command arguments (the first is the sub-command)
|
|
48
51
|
*/
|
|
49
52
|
execute(args) {
|
|
50
53
|
const command = args[0];
|
|
@@ -63,7 +66,7 @@ class CLIHost extends import_cliCommand.CLICommand {
|
|
|
63
66
|
/**
|
|
64
67
|
* When in single-host mode, changes the hostname of the host and all instances to the current one
|
|
65
68
|
*
|
|
66
|
-
* @param _args
|
|
69
|
+
* @param _args The command arguments (unused)
|
|
67
70
|
*/
|
|
68
71
|
self(_args) {
|
|
69
72
|
this.renameHost(void 0, import_node_os.default.hostname());
|
|
@@ -71,7 +74,7 @@ class CLIHost extends import_cliCommand.CLICommand {
|
|
|
71
74
|
/**
|
|
72
75
|
* Changes the current host's hostname to the given one
|
|
73
76
|
*
|
|
74
|
-
* @param args
|
|
77
|
+
* @param args The command arguments (the second is the new hostname)
|
|
75
78
|
*/
|
|
76
79
|
set(args) {
|
|
77
80
|
const { callback } = this.options;
|
|
@@ -85,7 +88,7 @@ class CLIHost extends import_cliCommand.CLICommand {
|
|
|
85
88
|
/**
|
|
86
89
|
* Removes the host with the given name
|
|
87
90
|
*
|
|
88
|
-
* @param args
|
|
91
|
+
* @param args The command arguments (the second is the hostname to remove)
|
|
89
92
|
*/
|
|
90
93
|
remove(args) {
|
|
91
94
|
const { callback, dbConnect } = this.options;
|
|
@@ -143,7 +146,7 @@ class CLIHost extends import_cliCommand.CLICommand {
|
|
|
143
146
|
/**
|
|
144
147
|
* Renames the host with the given name to the current one (opposite of `set()`)
|
|
145
148
|
*
|
|
146
|
-
* @param args
|
|
149
|
+
* @param args The command arguments (the second is the old hostname)
|
|
147
150
|
*/
|
|
148
151
|
rename(args) {
|
|
149
152
|
const { callback } = this.options;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/cli/cliHost.ts"],
|
|
4
|
-
"sourcesContent": ["import * as CLI from './messages.js';\nimport { CLICommand, type CLICommandOptions } from './cliCommand.js';\nimport { enumHosts, enumObjects, getObjectFrom, enumInstances } from './cliTools.js';\nimport { tools, EXIT_CODES } from '@iobroker/js-controller-common';\nimport type { Client as ObjectsClient } from '@iobroker/db-objects-redis';\nimport os from 'node:os';\nimport fs from 'fs-extra';\n\n/** Command iobroker host ... */\nexport class CLIHost extends CLICommand {\n constructor(options: CLICommandOptions) {\n super(options);\n }\n\n /**\n * Executes a command\n *\n * @param args\n */\n execute(args: any[]): void {\n const command = args[0];\n\n switch (command) {\n case 'this':\n case 'self':\n return this.self(args);\n case 'set':\n return this.set(args);\n case 'remove':\n return this.remove(args);\n default:\n return this.rename(args);\n }\n }\n\n /**\n * When in single-host mode, changes the hostname of the host and all instances to the current one\n *\n * @param _args\n */\n self(_args: any[]): void {\n this.renameHost(undefined, os.hostname());\n }\n\n /**\n * Changes the current host's hostname to the given one\n *\n * @param args\n */\n set(args: any[]): void {\n const { callback } = this.options;\n\n const newHostname: string = args[1];\n if (!newHostname) {\n CLI.error.requiredArgumentMissing('newHostname', 'host set newHostname');\n return void callback(34);\n }\n\n this.renameHost(tools.getHostName(), newHostname);\n }\n\n /**\n * Removes the host with the given name\n *\n * @param args\n */\n remove(args: any[]): void {\n const { callback, dbConnect } = this.options;\n\n const hostname: string = args[1];\n if (!hostname) {\n CLI.error.requiredArgumentMissing('hostname', 'host remove hostname');\n return void callback(34);\n }\n\n const newHostname = tools.getHostName();\n\n if (hostname === newHostname) {\n // avoid object deletion when target host is same host\n CLI.error.dontRemoveCurrentHost(hostname);\n return void callback(35);\n }\n\n dbConnect(async params => {\n const { objects, isOffline } = params;\n\n try {\n if (!isOffline) {\n CLI.error.cannotChangeRunningSystem();\n return void callback(EXIT_CODES.CONTROLLER_RUNNING);\n }\n\n // Find the requested host object\n const hosts = await enumHosts(objects);\n const hostToDelete = hosts.find(host => host?.common.hostname === hostname);\n if (!hostToDelete) {\n CLI.error.hostDoesNotExist(hostname);\n return void callback(30);\n }\n\n // Delete it\n try {\n await objects.delObjectAsync(hostToDelete._id);\n } catch (err) {\n CLI.error.cannotDeleteObject(hostToDelete._id, err.message);\n return void callback(30);\n }\n\n // Also delete its states\n const hostStates = await enumObjects(objects, 'state', `system.host.${hostname}.`);\n for (const state of hostStates) {\n // Therefore delete the old one because we will recreate it under a new name\n try {\n await objects.delObjectAsync(state._id);\n CLI.success.stateDeleted(state._id);\n } catch (err) {\n CLI.error.cannotDeleteObject(state._id, err.message);\n }\n }\n\n // Move all instances from the deleted host to the current one\n const instances = await enumInstances(objects);\n const instancesToRename = instances.filter(i => i?.common.host === hostname);\n for (const instance of instancesToRename) {\n await changeInstanceHost(objects, instance, newHostname);\n }\n\n // Notify the user that we are done\n CLI.success.hostDeleted(hostname);\n return void callback(EXIT_CODES.NO_ERROR);\n } catch (err) {\n CLI.error.unknown(err.message);\n return void callback(1);\n }\n });\n }\n\n /**\n * Renames the host with the given name to the current one (opposite of `set()`)\n *\n * @param args\n */\n rename(args: any[]): void {\n const { callback } = this.options;\n\n const oldHostname: string = args[0];\n\n if (!oldHostname) {\n CLI.error.requiredArgumentMissing('oldHostname', 'host oldHostname');\n return void callback(34);\n }\n\n this.renameHost(oldHostname, os.hostname());\n }\n\n /**\n * Renames the host with the hostname `oldHostname` to the hostname `newHostname`\n *\n * @param oldHostname The hostname to rename from or `undefined` to rename all hosts (single-host mode only!)\n * @param newHostname The hostname to rename to\n */\n renameHost(oldHostname: string | undefined, newHostname: string): void {\n const { callback, dbConnect, showHelp } = this.options;\n dbConnect(async params => {\n const { isOffline, objects } = params;\n\n try {\n if (!isOffline) {\n CLI.error.cannotChangeRunningSystem();\n return void callback(EXIT_CODES.CONTROLLER_RUNNING);\n }\n\n const hosts = await enumHosts(objects);\n if (hosts.length > 1 && oldHostname === undefined) {\n // iobroker host this/self in multihost is not allowed\n CLI.error.noHostThisInMultihost();\n showHelp();\n return void callback(30);\n }\n\n // Does another host with the target name exist?\n const hostExists = !!hosts.find(obj => obj?.common.hostname === newHostname);\n if (hostExists) {\n // This prevents migration of instances if host already exists, but we need it to prevent\n // multiple hosts with same name. Thus we only allow if no instances are on the host\n // Note: this is only a heuristic, if problems occur we need a `force` flag\n const instances = await enumInstances(objects);\n const hasExistingInstances = !!instances.find(instance => instance?.common.host === newHostname);\n\n if (hasExistingInstances) {\n CLI.error.hostAlreadyExists(newHostname);\n return void callback(EXIT_CODES.INSTANCE_ALREADY_EXISTS);\n }\n }\n\n // Remember the new hostname in the system settings\n const configFileName = tools.getConfigFileName();\n const configData = fs.readJSONSync(configFileName);\n if (configData.system && configData.system.hostname !== newHostname) {\n configData.system.hostname = newHostname;\n fs.writeFileSync(configFileName, JSON.stringify(configData, null, 2), 'utf8');\n }\n\n // Rename the host(s)\n for (const host of hosts) {\n // Remember the current hostname of this object because we need it later\n const prevHostname = host.common.hostname;\n\n // Rename only the hostname we're supposed to rename!\n if (oldHostname && prevHostname !== oldHostname) {\n continue;\n }\n\n // Rename the host object\n // Therefore delete the old one because we will recreate it under a new name\n try {\n await objects.delObjectAsync(host._id);\n } catch (err) {\n CLI.error.cannotDeleteObject(host._id, err.message);\n continue;\n }\n\n // Now update the object\n Object.assign(host, {\n _id: `system.host.${newHostname}`,\n from: getObjectFrom(),\n ts: Date.now(),\n });\n Object.assign(host.common, {\n name: host._id,\n hostname: newHostname,\n address: [],\n cmd: '',\n native: { process: {}, os: {}, hardware: {} },\n });\n // And save it\n try {\n await objects.setObjectAsync(host._id, host);\n } catch (err) {\n CLI.error.cannotChangeObject(host._id, err.message);\n continue;\n }\n\n // Rename its states\n const hostStateObjects = await enumObjects(objects, 'state', `system.host.${prevHostname}.`);\n const hostFolders = await enumObjects(objects, 'folder', `system.host.${prevHostname}.`);\n for (const object of [...hostStateObjects, ...hostFolders]) {\n // Therefore delete the old one because we will recreate it under a new name\n try {\n await objects.delObjectAsync(object._id);\n } catch (err) {\n CLI.error.cannotDeleteObject(object._id, err.message);\n continue;\n }\n\n // Now update the object\n Object.assign(object, {\n _id: object._id.replace(`system.host.${prevHostname}`, `system.host.${newHostname}`),\n from: getObjectFrom(),\n ts: Date.now(),\n });\n\n // And save it\n try {\n await objects.setObjectAsync(object._id, object);\n } catch (err) {\n CLI.error.cannotChangeObject(object._id, err.message);\n }\n }\n\n CLI.success.hostRenamed(prevHostname, newHostname);\n }\n\n // Also rename all instances\n const instances = await enumInstances(objects);\n const instancesToRename =\n oldHostname === undefined ? instances : instances.filter(i => i.common.host === oldHostname);\n if (instancesToRename.length > 0) {\n for (const instance of instancesToRename) {\n // Update each instance object\n await changeInstanceHost(objects, instance, newHostname);\n }\n } else {\n CLI.warn.noInstancesFoundOnHost(oldHostname);\n }\n return void callback(EXIT_CODES.NO_ERROR);\n } catch (err) {\n CLI.error.unknown(err.message);\n return void callback(1);\n }\n });\n }\n}\n\n/**\n * Changes the host an instance is running on\n *\n * @param objects The objects DB to use\n * @param instance The instance object\n * @param newHostname The new hostname the instance should be running on\n */\nasync function changeInstanceHost(\n objects: ObjectsClient,\n instance: ioBroker.InstanceObject,\n newHostname: string,\n): Promise<void> {\n const oldInstanceHost = instance.common.host;\n instance.from = getObjectFrom();\n instance.ts = Date.now();\n instance.common.host = newHostname;\n // and save it\n try {\n await objects.setObjectAsync(instance._id, instance);\n CLI.success.instanceHostChanged(instance._id, oldInstanceHost, newHostname);\n } catch (e) {\n CLI.error.cannotChangeObject(instance._id, e.message);\n // resolve anyways, we don't want to cause errors\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAAA,UAAqB;AACrB,wBAAmD;AACnD,sBAAqE;AACrE,kCAAkC;AAElC,qBAAe;AACf,sBAAe;AAGT,MAAO,gBAAgB,6BAAU
|
|
4
|
+
"sourcesContent": ["import * as CLI from './messages.js';\nimport { CLICommand, type CLICommandOptions } from './cliCommand.js';\nimport { enumHosts, enumObjects, getObjectFrom, enumInstances } from './cliTools.js';\nimport { tools, EXIT_CODES } from '@iobroker/js-controller-common';\nimport type { Client as ObjectsClient } from '@iobroker/db-objects-redis';\nimport os from 'node:os';\nimport fs from 'fs-extra';\n\n/** Command iobroker host ... */\nexport class CLIHost extends CLICommand {\n /**\n * @param options The command options including context and parameters\n */\n constructor(options: CLICommandOptions) {\n super(options);\n }\n\n /**\n * Executes a command\n *\n * @param args The command arguments (the first is the sub-command)\n */\n execute(args: any[]): void {\n const command = args[0];\n\n switch (command) {\n case 'this':\n case 'self':\n return this.self(args);\n case 'set':\n return this.set(args);\n case 'remove':\n return this.remove(args);\n default:\n return this.rename(args);\n }\n }\n\n /**\n * When in single-host mode, changes the hostname of the host and all instances to the current one\n *\n * @param _args The command arguments (unused)\n */\n self(_args: any[]): void {\n this.renameHost(undefined, os.hostname());\n }\n\n /**\n * Changes the current host's hostname to the given one\n *\n * @param args The command arguments (the second is the new hostname)\n */\n set(args: any[]): void {\n const { callback } = this.options;\n\n const newHostname: string = args[1];\n if (!newHostname) {\n CLI.error.requiredArgumentMissing('newHostname', 'host set newHostname');\n return void callback(34);\n }\n\n this.renameHost(tools.getHostName(), newHostname);\n }\n\n /**\n * Removes the host with the given name\n *\n * @param args The command arguments (the second is the hostname to remove)\n */\n remove(args: any[]): void {\n const { callback, dbConnect } = this.options;\n\n const hostname: string = args[1];\n if (!hostname) {\n CLI.error.requiredArgumentMissing('hostname', 'host remove hostname');\n return void callback(34);\n }\n\n const newHostname = tools.getHostName();\n\n if (hostname === newHostname) {\n // avoid object deletion when target host is same host\n CLI.error.dontRemoveCurrentHost(hostname);\n return void callback(35);\n }\n\n dbConnect(async params => {\n const { objects, isOffline } = params;\n\n try {\n if (!isOffline) {\n CLI.error.cannotChangeRunningSystem();\n return void callback(EXIT_CODES.CONTROLLER_RUNNING);\n }\n\n // Find the requested host object\n const hosts = await enumHosts(objects);\n const hostToDelete = hosts.find(host => host?.common.hostname === hostname);\n if (!hostToDelete) {\n CLI.error.hostDoesNotExist(hostname);\n return void callback(30);\n }\n\n // Delete it\n try {\n await objects.delObjectAsync(hostToDelete._id);\n } catch (err) {\n CLI.error.cannotDeleteObject(hostToDelete._id, err.message);\n return void callback(30);\n }\n\n // Also delete its states\n const hostStates = await enumObjects(objects, 'state', `system.host.${hostname}.`);\n for (const state of hostStates) {\n // Therefore delete the old one because we will recreate it under a new name\n try {\n await objects.delObjectAsync(state._id);\n CLI.success.stateDeleted(state._id);\n } catch (err) {\n CLI.error.cannotDeleteObject(state._id, err.message);\n }\n }\n\n // Move all instances from the deleted host to the current one\n const instances = await enumInstances(objects);\n const instancesToRename = instances.filter(i => i?.common.host === hostname);\n for (const instance of instancesToRename) {\n await changeInstanceHost(objects, instance, newHostname);\n }\n\n // Notify the user that we are done\n CLI.success.hostDeleted(hostname);\n return void callback(EXIT_CODES.NO_ERROR);\n } catch (err) {\n CLI.error.unknown(err.message);\n return void callback(1);\n }\n });\n }\n\n /**\n * Renames the host with the given name to the current one (opposite of `set()`)\n *\n * @param args The command arguments (the second is the old hostname)\n */\n rename(args: any[]): void {\n const { callback } = this.options;\n\n const oldHostname: string = args[0];\n\n if (!oldHostname) {\n CLI.error.requiredArgumentMissing('oldHostname', 'host oldHostname');\n return void callback(34);\n }\n\n this.renameHost(oldHostname, os.hostname());\n }\n\n /**\n * Renames the host with the hostname `oldHostname` to the hostname `newHostname`\n *\n * @param oldHostname The hostname to rename from or `undefined` to rename all hosts (single-host mode only!)\n * @param newHostname The hostname to rename to\n */\n renameHost(oldHostname: string | undefined, newHostname: string): void {\n const { callback, dbConnect, showHelp } = this.options;\n dbConnect(async params => {\n const { isOffline, objects } = params;\n\n try {\n if (!isOffline) {\n CLI.error.cannotChangeRunningSystem();\n return void callback(EXIT_CODES.CONTROLLER_RUNNING);\n }\n\n const hosts = await enumHosts(objects);\n if (hosts.length > 1 && oldHostname === undefined) {\n // iobroker host this/self in multihost is not allowed\n CLI.error.noHostThisInMultihost();\n showHelp();\n return void callback(30);\n }\n\n // Does another host with the target name exist?\n const hostExists = !!hosts.find(obj => obj?.common.hostname === newHostname);\n if (hostExists) {\n // This prevents migration of instances if host already exists, but we need it to prevent\n // multiple hosts with same name. Thus we only allow if no instances are on the host\n // Note: this is only a heuristic, if problems occur we need a `force` flag\n const instances = await enumInstances(objects);\n const hasExistingInstances = !!instances.find(instance => instance?.common.host === newHostname);\n\n if (hasExistingInstances) {\n CLI.error.hostAlreadyExists(newHostname);\n return void callback(EXIT_CODES.INSTANCE_ALREADY_EXISTS);\n }\n }\n\n // Remember the new hostname in the system settings\n const configFileName = tools.getConfigFileName();\n const configData = fs.readJSONSync(configFileName);\n if (configData.system && configData.system.hostname !== newHostname) {\n configData.system.hostname = newHostname;\n fs.writeFileSync(configFileName, JSON.stringify(configData, null, 2), 'utf8');\n }\n\n // Rename the host(s)\n for (const host of hosts) {\n // Remember the current hostname of this object because we need it later\n const prevHostname = host.common.hostname;\n\n // Rename only the hostname we're supposed to rename!\n if (oldHostname && prevHostname !== oldHostname) {\n continue;\n }\n\n // Rename the host object\n // Therefore delete the old one because we will recreate it under a new name\n try {\n await objects.delObjectAsync(host._id);\n } catch (err) {\n CLI.error.cannotDeleteObject(host._id, err.message);\n continue;\n }\n\n // Now update the object\n Object.assign(host, {\n _id: `system.host.${newHostname}`,\n from: getObjectFrom(),\n ts: Date.now(),\n });\n Object.assign(host.common, {\n name: host._id,\n hostname: newHostname,\n address: [],\n cmd: '',\n native: { process: {}, os: {}, hardware: {} },\n });\n // And save it\n try {\n await objects.setObjectAsync(host._id, host);\n } catch (err) {\n CLI.error.cannotChangeObject(host._id, err.message);\n continue;\n }\n\n // Rename its states\n const hostStateObjects = await enumObjects(objects, 'state', `system.host.${prevHostname}.`);\n const hostFolders = await enumObjects(objects, 'folder', `system.host.${prevHostname}.`);\n for (const object of [...hostStateObjects, ...hostFolders]) {\n // Therefore delete the old one because we will recreate it under a new name\n try {\n await objects.delObjectAsync(object._id);\n } catch (err) {\n CLI.error.cannotDeleteObject(object._id, err.message);\n continue;\n }\n\n // Now update the object\n Object.assign(object, {\n _id: object._id.replace(`system.host.${prevHostname}`, `system.host.${newHostname}`),\n from: getObjectFrom(),\n ts: Date.now(),\n });\n\n // And save it\n try {\n await objects.setObjectAsync(object._id, object);\n } catch (err) {\n CLI.error.cannotChangeObject(object._id, err.message);\n }\n }\n\n CLI.success.hostRenamed(prevHostname, newHostname);\n }\n\n // Also rename all instances\n const instances = await enumInstances(objects);\n const instancesToRename =\n oldHostname === undefined ? instances : instances.filter(i => i.common.host === oldHostname);\n if (instancesToRename.length > 0) {\n for (const instance of instancesToRename) {\n // Update each instance object\n await changeInstanceHost(objects, instance, newHostname);\n }\n } else {\n CLI.warn.noInstancesFoundOnHost(oldHostname);\n }\n return void callback(EXIT_CODES.NO_ERROR);\n } catch (err) {\n CLI.error.unknown(err.message);\n return void callback(1);\n }\n });\n }\n}\n\n/**\n * Changes the host an instance is running on\n *\n * @param objects The objects DB to use\n * @param instance The instance object\n * @param newHostname The new hostname the instance should be running on\n */\nasync function changeInstanceHost(\n objects: ObjectsClient,\n instance: ioBroker.InstanceObject,\n newHostname: string,\n): Promise<void> {\n const oldInstanceHost = instance.common.host;\n instance.from = getObjectFrom();\n instance.ts = Date.now();\n instance.common.host = newHostname;\n // and save it\n try {\n await objects.setObjectAsync(instance._id, instance);\n CLI.success.instanceHostChanged(instance._id, oldInstanceHost, newHostname);\n } catch (e) {\n CLI.error.cannotChangeObject(instance._id, e.message);\n // resolve anyways, we don't want to cause errors\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAAA,UAAqB;AACrB,wBAAmD;AACnD,sBAAqE;AACrE,kCAAkC;AAElC,qBAAe;AACf,sBAAe;AAGT,MAAO,gBAAgB,6BAAU;;;;EAInC,YAAY,SAA0B;AAClC,UAAM,OAAO;EACjB;;;;;;EAOA,QAAQ,MAAW;AACf,UAAM,UAAU,KAAK,CAAC;AAEtB,YAAQ,SAAS;MACb,KAAK;MACL,KAAK;AACD,eAAO,KAAK,KAAK,IAAI;MACzB,KAAK;AACD,eAAO,KAAK,IAAI,IAAI;MACxB,KAAK;AACD,eAAO,KAAK,OAAO,IAAI;MAC3B;AACI,eAAO,KAAK,OAAO,IAAI;IAC/B;EACJ;;;;;;EAOA,KAAK,OAAY;AACb,SAAK,WAAW,QAAW,eAAAA,QAAG,SAAQ,CAAE;EAC5C;;;;;;EAOA,IAAI,MAAW;AACX,UAAM,EAAE,SAAQ,IAAK,KAAK;AAE1B,UAAM,cAAsB,KAAK,CAAC;AAClC,QAAI,CAAC,aAAa;AACd,UAAI,MAAM,wBAAwB,eAAe,sBAAsB;AACvE,aAAO,KAAK,SAAS,EAAE;IAC3B;AAEA,SAAK,WAAW,kCAAM,YAAW,GAAI,WAAW;EACpD;;;;;;EAOA,OAAO,MAAW;AACd,UAAM,EAAE,UAAU,UAAS,IAAK,KAAK;AAErC,UAAM,WAAmB,KAAK,CAAC;AAC/B,QAAI,CAAC,UAAU;AACX,UAAI,MAAM,wBAAwB,YAAY,sBAAsB;AACpE,aAAO,KA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,kBAAI,MAAM,mBAAmB,OAAO,KAAK,IAAI,OAAO;YACxD;UACJ;AAEA,cAAI,QAAQ,YAAY,cAAc,WAAW;QACrD;AAGA,cAAM,YAAY,UAAM,+BAAc,OAAO;AAC7C,cAAM,oBACF,gBAAgB,SAAY,YAAY,UAAU,OAAO,OAAK,EAAE,OAAO,SAAS,WAAW;AAC/F,YAAI,kBAAkB,SAAS,GAAG;AAC9B,qBAAW,YAAY,mBAAmB;AAEtC,kBAAM,mBAAmB,SAAS,UAAU,WAAW;UAC3D;QACJ,OAAO;AACH,cAAI,KAAK,uBAAuB,WAAW;QAC/C;AACA,eAAO,KAAK,SAAS,uCAAW,QAAQ;MAC5C,SAAS,KAAK;AACV,YAAI,MAAM,QAAQ,IAAI,OAAO;AAC7B,eAAO,KAAK,SAAS,CAAC;MAC1B;IACJ,CAAC;EACL;;AAUJ,eAAe,mBACX,SACA,UACA,aAAmB;AAEnB,QAAM,kBAAkB,SAAS,OAAO;AACxC,WAAS,WAAO,+BAAa;AAC7B,WAAS,KAAK,KAAK,IAAG;AACtB,WAAS,OAAO,OAAO;AAEvB,MAAI;AACA,UAAM,QAAQ,eAAe,SAAS,KAAK,QAAQ;AACnD,QAAI,QAAQ,oBAAoB,SAAS,KAAK,iBAAiB,WAAW;EAC9E,SAAS,GAAG;AACR,QAAI,MAAM,mBAAmB,SAAS,KAAK,EAAE,OAAO;EAExD;AACJ;",
|
|
6
6
|
"names": ["os", "instances", "fs"]
|
|
7
7
|
}
|
|
@@ -9,11 +9,14 @@ interface CLILogsOptions {
|
|
|
9
9
|
export declare class CLILogs extends CLICommand {
|
|
10
10
|
private readonly fileSizes;
|
|
11
11
|
private isReady;
|
|
12
|
+
/**
|
|
13
|
+
* @param options The command options including context and parameters
|
|
14
|
+
*/
|
|
12
15
|
constructor(options: CLICommandOptions);
|
|
13
16
|
/**
|
|
14
17
|
* Executes a command
|
|
15
18
|
*
|
|
16
|
-
* @param args
|
|
19
|
+
* @param args The command arguments (the first is the sub-command)
|
|
17
20
|
* @param params additional parsed CLI parameters
|
|
18
21
|
*/
|
|
19
22
|
execute(args: any[], params: Record<string, any>): void;
|
|
@@ -44,13 +44,16 @@ const { getConfigFileName } = import_js_controller_common.tools;
|
|
|
44
44
|
class CLILogs extends import_cliCommand.CLICommand {
|
|
45
45
|
fileSizes = /* @__PURE__ */ new Map();
|
|
46
46
|
isReady = false;
|
|
47
|
+
/**
|
|
48
|
+
* @param options The command options including context and parameters
|
|
49
|
+
*/
|
|
47
50
|
constructor(options) {
|
|
48
51
|
super(options);
|
|
49
52
|
}
|
|
50
53
|
/**
|
|
51
54
|
* Executes a command
|
|
52
55
|
*
|
|
53
|
-
* @param args
|
|
56
|
+
* @param args The command arguments (the first is the sub-command)
|
|
54
57
|
* @param params additional parsed CLI parameters
|
|
55
58
|
*/
|
|
56
59
|
execute(args, params) {
|