@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/cli/cliLogs.ts", "../../../../../../node_modules/@alcalzone/esm2cjs/shims/import.meta.url/shim.js"],
|
|
4
|
-
"sourcesContent": ["import { CLICommand, type CLICommandOptions } from './cliCommand.js';\nimport { tools, logger as toolsLogger } from '@iobroker/js-controller-common';\nimport chokidar from 'chokidar';\nimport fs from 'fs-extra';\nimport os from 'node:os';\nimport es from 'event-stream';\nimport { createRequire } from 'node:module';\n// eslint-disable-next-line unicorn/prefer-module\nconst require = createRequire(import.meta.url || `file://${__filename}`);\n\nconst { getConfigFileName } = tools;\n\ninterface CLILogsOptions {\n /** Whether to show today's full log */\n complete?: boolean;\n /** An optional RegExp to filter by */\n regex?: RegExp;\n}\n\n/** Command ioBroker state ... */\nexport class CLILogs extends CLICommand {\n private readonly fileSizes = new Map<string, number>();\n private isReady = false;\n\n constructor(options: CLICommandOptions) {\n super(options);\n }\n\n /**\n * Executes a command\n *\n * @param args\n * @param params additional parsed CLI parameters\n */\n execute(args: any[], params: Record<string, any>): void {\n const adapterName = args[0];\n const watch = params.watch || params.w;\n const count = params.lines || 1_000;\n\n const options: CLILogsOptions = {\n complete: this.options.all,\n };\n\n const config = fs.readJSONSync(require.resolve(getConfigFileName()));\n const logger = toolsLogger(config.log);\n // @ts-expect-error todo adjust logger type\n let fileName = logger.getFileName();\n if (fileName) {\n let lines = fs.readFileSync(fileName).toString('utf-8').split('\\n');\n lines = lines.filter(line => line);\n if (lines.length > count) {\n lines.splice(0, lines.length - count);\n }\n let regex: RegExp;\n if (adapterName) {\n //2019-03-02 13:26:54.698 - debug: iot.0 [ALEXA] Created ALEXA device: Bad.Hauptlicht.Aktor.STATE [\"turnOn\",\"turnOff\"]\n regex = new RegExp(`: ${adapterName}\\\\.`);\n options.regex = regex;\n }\n lines.forEach(line => {\n if (regex && !regex.test(line)) {\n return;\n }\n console.log(line);\n });\n\n if (watch) {\n fileName = fileName.replace(/\\\\/g, '/');\n const parts = fileName.split('/');\n parts.pop();\n chokidar\n .watch(`${parts.join('/')}/iobroker*`, {\n awaitWriteFinish: { stabilityThreshold: 500 },\n followSymlinks: false,\n })\n .on('all', this.watchHandler.bind(this, options))\n .on('ready', () => (this.isReady = true));\n }\n } else {\n console.log('No log file found');\n }\n }\n\n /**\n * Called by chokidar when watched files change\n *\n * @param options some options\n * @param event The type of change\n * @param path Which path has changed\n * @param stats Information about the file\n */\n watchHandler(options: CLILogsOptions, event: string, path: string, stats: Record<string, any>): void {\n if (event === 'add' || !this.fileSizes.has(path)) {\n this.fileSizes.set(path, stats.size);\n if (stats.size > 0 && (this.isReady || (options.complete && this.isTodaysLogfile(path)))) {\n this.streamChange(path, 0, options);\n }\n } else if (event === 'change') {\n const oldFileSize = this.fileSizes.get(path)!;\n this.fileSizes.set(path, stats.size);\n if (this.isReady && stats.size > oldFileSize) {\n this.streamChange(path, oldFileSize, options);\n }\n } else if (event === 'unlink') {\n this.fileSizes.delete(path);\n }\n }\n\n /**\n * If the log file belongs to today\n *\n * @param path The log file path\n */\n isTodaysLogfile(path: string): boolean {\n const YYYYMMDDDate = new Date().toJSON().slice(0, 10);\n return path.includes(YYYYMMDDDate);\n }\n\n /**\n * Streams a portion of a file to the console\n *\n * @param path The file to stream\n * @param start The offset in bytes where to start\n * @param options some options\n */\n streamChange(path: string, start: number, options: CLILogsOptions): void {\n const input = fs.createReadStream(path, {\n encoding: 'utf8',\n start,\n autoClose: true,\n });\n if (options.regex) {\n // Read the input line by line and only include the lines matching the filter\n input\n .pipe(es.split())\n .pipe(es.filterSync(line => options.regex!.test(line)))\n .pipe(es.mapSync((line: string) => line + os.EOL))\n .pipe(process.stdout);\n } else {\n // just pipe the input through\n tools.pipeLinewise(input, process.stdout);\n }\n }\n}\n", "export const __import_meta_url =\n typeof document === 'undefined' ? new (require('url'.replace('', '')).URL)('file:' + __filename).href :\n (document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href)\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;ACAO,IAAM,oBACX,OAAO,aAAa,cAAc,KAAK,QAAQ,MAAM,QAAQ,IAAI,EAAE,CAAC,GAAE,IAAK,UAAU,UAAU,EAAE,OAC9F,SAAS,iBAAiB,SAAS,cAAc,OAAO,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;ADFlG,wBAAmD;AACnD,kCAA6C;AAC7C,sBAAqB;AACrB,sBAAe;AACf,qBAAe;AACf,0BAAe;AACf,yBAA8B;AAE9B,MAAMA,eAAU,kCAAc,qBAAmB,UAAU,UAAU,EAAE;AAEvE,MAAM,EAAE,kBAAiB,IAAK;AAUxB,MAAO,gBAAgB,6BAAU;EAClB,YAAY,oBAAI,IAAG;EAC5B,UAAU
|
|
4
|
+
"sourcesContent": ["import { CLICommand, type CLICommandOptions } from './cliCommand.js';\nimport { tools, logger as toolsLogger } from '@iobroker/js-controller-common';\nimport chokidar from 'chokidar';\nimport fs from 'fs-extra';\nimport os from 'node:os';\nimport es from 'event-stream';\nimport { createRequire } from 'node:module';\n// eslint-disable-next-line unicorn/prefer-module\nconst require = createRequire(import.meta.url || `file://${__filename}`);\n\nconst { getConfigFileName } = tools;\n\ninterface CLILogsOptions {\n /** Whether to show today's full log */\n complete?: boolean;\n /** An optional RegExp to filter by */\n regex?: RegExp;\n}\n\n/** Command ioBroker state ... */\nexport class CLILogs extends CLICommand {\n private readonly fileSizes = new Map<string, number>();\n private isReady = false;\n\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 * @param params additional parsed CLI parameters\n */\n execute(args: any[], params: Record<string, any>): void {\n const adapterName = args[0];\n const watch = params.watch || params.w;\n const count = params.lines || 1_000;\n\n const options: CLILogsOptions = {\n complete: this.options.all,\n };\n\n const config = fs.readJSONSync(require.resolve(getConfigFileName()));\n const logger = toolsLogger(config.log);\n // @ts-expect-error todo adjust logger type\n let fileName = logger.getFileName();\n if (fileName) {\n let lines = fs.readFileSync(fileName).toString('utf-8').split('\\n');\n lines = lines.filter(line => line);\n if (lines.length > count) {\n lines.splice(0, lines.length - count);\n }\n let regex: RegExp;\n if (adapterName) {\n //2019-03-02 13:26:54.698 - debug: iot.0 [ALEXA] Created ALEXA device: Bad.Hauptlicht.Aktor.STATE [\"turnOn\",\"turnOff\"]\n regex = new RegExp(`: ${adapterName}\\\\.`);\n options.regex = regex;\n }\n lines.forEach(line => {\n if (regex && !regex.test(line)) {\n return;\n }\n console.log(line);\n });\n\n if (watch) {\n fileName = fileName.replace(/\\\\/g, '/');\n const parts = fileName.split('/');\n parts.pop();\n chokidar\n .watch(`${parts.join('/')}/iobroker*`, {\n awaitWriteFinish: { stabilityThreshold: 500 },\n followSymlinks: false,\n })\n .on('all', this.watchHandler.bind(this, options))\n .on('ready', () => (this.isReady = true));\n }\n } else {\n console.log('No log file found');\n }\n }\n\n /**\n * Called by chokidar when watched files change\n *\n * @param options some options\n * @param event The type of change\n * @param path Which path has changed\n * @param stats Information about the file\n */\n watchHandler(options: CLILogsOptions, event: string, path: string, stats: Record<string, any>): void {\n if (event === 'add' || !this.fileSizes.has(path)) {\n this.fileSizes.set(path, stats.size);\n if (stats.size > 0 && (this.isReady || (options.complete && this.isTodaysLogfile(path)))) {\n this.streamChange(path, 0, options);\n }\n } else if (event === 'change') {\n const oldFileSize = this.fileSizes.get(path)!;\n this.fileSizes.set(path, stats.size);\n if (this.isReady && stats.size > oldFileSize) {\n this.streamChange(path, oldFileSize, options);\n }\n } else if (event === 'unlink') {\n this.fileSizes.delete(path);\n }\n }\n\n /**\n * If the log file belongs to today\n *\n * @param path The log file path\n */\n isTodaysLogfile(path: string): boolean {\n const YYYYMMDDDate = new Date().toJSON().slice(0, 10);\n return path.includes(YYYYMMDDDate);\n }\n\n /**\n * Streams a portion of a file to the console\n *\n * @param path The file to stream\n * @param start The offset in bytes where to start\n * @param options some options\n */\n streamChange(path: string, start: number, options: CLILogsOptions): void {\n const input = fs.createReadStream(path, {\n encoding: 'utf8',\n start,\n autoClose: true,\n });\n if (options.regex) {\n // Read the input line by line and only include the lines matching the filter\n input\n .pipe(es.split())\n .pipe(es.filterSync(line => options.regex!.test(line)))\n .pipe(es.mapSync((line: string) => line + os.EOL))\n .pipe(process.stdout);\n } else {\n // just pipe the input through\n tools.pipeLinewise(input, process.stdout);\n }\n }\n}\n", "export const __import_meta_url =\n typeof document === 'undefined' ? new (require('url'.replace('', '')).URL)('file:' + __filename).href :\n (document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href)\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;ACAO,IAAM,oBACX,OAAO,aAAa,cAAc,KAAK,QAAQ,MAAM,QAAQ,IAAI,EAAE,CAAC,GAAE,IAAK,UAAU,UAAU,EAAE,OAC9F,SAAS,iBAAiB,SAAS,cAAc,OAAO,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;ADFlG,wBAAmD;AACnD,kCAA6C;AAC7C,sBAAqB;AACrB,sBAAe;AACf,qBAAe;AACf,0BAAe;AACf,yBAA8B;AAE9B,MAAMA,eAAU,kCAAc,qBAAmB,UAAU,UAAU,EAAE;AAEvE,MAAM,EAAE,kBAAiB,IAAK;AAUxB,MAAO,gBAAgB,6BAAU;EAClB,YAAY,oBAAI,IAAG;EAC5B,UAAU;;;;EAKlB,YAAY,SAA0B;AAClC,UAAM,OAAO;EACjB;;;;;;;EAQA,QAAQ,MAAa,QAA2B;AAC5C,U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UAAU,IAAI,MAAM,MAAM,IAAI;AACnC,UAAI,MAAM,OAAO,MAAM,KAAK,WAAY,QAAQ,YAAY,KAAK,gBAAgB,IAAI,IAAK;AACtF,aAAK,aAAa,MAAM,GAAG,OAAO;MACtC;IACJ,WAAW,UAAU,UAAU;AAC3B,YAAM,cAAc,KAAK,UAAU,IAAI,IAAI;AAC3C,WAAK,UAAU,IAAI,MAAM,MAAM,IAAI;AACnC,UAAI,KAAK,WAAW,MAAM,OAAO,aAAa;AAC1C,aAAK,aAAa,MAAM,aAAa,OAAO;MAChD;IACJ,WAAW,UAAU,UAAU;AAC3B,WAAK,UAAU,OAAO,IAAI;IAC9B;EACJ;;;;;;EAOA,gBAAgB,MAAY;AACxB,UAAM,gBAAe,oBAAI,KAAI,GAAG,OAAM,EAAG,MAAM,GAAG,EAAE;AACpD,WAAO,KAAK,SAAS,YAAY;EACrC;;;;;;;;EASA,aAAa,MAAc,OAAe,SAAuB;AAC7D,UAAM,QAAQ,gBAAAF,QAAG,iBAAiB,MAAM;MACpC,UAAU;MACV;MACA,WAAW;KACd;AACD,QAAI,QAAQ,OAAO;AAEf,YACK,KAAK,oBAAAG,QAAG,MAAK,CAAE,EACf,KAAK,oBAAAA,QAAG,WAAW,UAAQ,QAAQ,MAAO,KAAK,IAAI,CAAC,CAAC,EACrD,KAAK,oBAAAA,QAAG,QAAQ,CAAC,SAAiB,OAAO,eAAAC,QAAG,GAAG,CAAC,EAChD,KAAK,QAAQ,MAAM;IAC5B,OAAO;AAEH,wCAAM,aAAa,OAAO,QAAQ,MAAM;IAC5C;EACJ;;",
|
|
6
6
|
"names": ["require", "fs", "toolsLogger", "chokidar", "es", "os"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/cli/cliMessage.ts"],
|
|
4
|
-
"sourcesContent": ["import * as CLI from './messages.js';\nimport { CLICommand, type CLICommandOptions } from './cliCommand.js';\nimport { enumInstances } from './cliTools.js';\nimport type { Client as StatesClient } from '@iobroker/db-states-redis';\n\nexport class CLIMessage extends CLICommand {\n /** @param options The CLI Message options */\n constructor(options: CLICommandOptions) {\n super(options);\n }\n\n /**\n * Executes a command\n *\n * @param args parsed arguments\n */\n execute(args: any[]): void {\n const { callback, dbConnect, showHelp } = this.options;\n let [adapter, command, message] = args;\n if (adapter === null || adapter === undefined) {\n CLI.error.requiredArgumentMissing('adapter');\n showHelp();\n return void callback(1);\n }\n if (message === null || message === undefined) {\n if (command === null || command === undefined) {\n CLI.error.requiredArgumentMissing('message');\n showHelp();\n return void callback(1);\n }\n message = command;\n command = 'send';\n }\n // Try to parse JSON\n // TODO: can we use the methods from cliObjects?\n if (typeof message === 'string' && message.startsWith('{') && message.endsWith('}')) {\n message = JSON.parse(message);\n }\n\n dbConnect(async params => {\n const { states, objects } = params;\n\n try {\n const pos = adapter.indexOf('.');\n let instance = null;\n if (pos !== -1) {\n instance = adapter.substring(pos + 1);\n adapter = adapter.substring(0, pos);\n }\n let messageTargets = [];\n if (instance === null) {\n // This message wasn't meant for a specific instance,\n const adapterInstances = await enumInstances(objects, adapter);\n if (adapterInstances.length === 0) {\n CLI.error.noInstancesFound(adapter);\n return void callback(1);\n }\n messageTargets = adapterInstances.map(row => row._id);\n } else {\n messageTargets.unshift(`system.adapter.${adapter}.${instance}`);\n }\n\n // Send the message to all targets\n const messagePromises = messageTargets.map(t => sendMessage(states, t, command, message));\n await Promise.all(messagePromises);\n return void callback();\n } catch (err) {\n CLI.error.unknown(err.message);\n return void callback(1);\n }\n });\n }\n}\n\n/**\n * @param states The States DB\n * @param targetId The instance or adapter to send the message to\n * @param command The command to send\n * @param message The message to send\n */\nasync function sendMessage(states: StatesClient, targetId: string, command: string, message: string): Promise<void> {\n await states.pushMessage(targetId, { command, message, from: 'cli' });\n CLI.success.messageSent(targetId, command, message);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAAA,UAAqB;AACrB,wBAAmD;AACnD,sBAA8B;
|
|
4
|
+
"sourcesContent": ["import * as CLI from './messages.js';\nimport { CLICommand, type CLICommandOptions } from './cliCommand.js';\nimport { enumInstances } from './cliTools.js';\nimport type { Client as StatesClient } from '@iobroker/db-states-redis';\n\n/** Command iobroker message ... */\nexport class CLIMessage extends CLICommand {\n /** @param options The CLI Message options */\n constructor(options: CLICommandOptions) {\n super(options);\n }\n\n /**\n * Executes a command\n *\n * @param args parsed arguments\n */\n execute(args: any[]): void {\n const { callback, dbConnect, showHelp } = this.options;\n let [adapter, command, message] = args;\n if (adapter === null || adapter === undefined) {\n CLI.error.requiredArgumentMissing('adapter');\n showHelp();\n return void callback(1);\n }\n if (message === null || message === undefined) {\n if (command === null || command === undefined) {\n CLI.error.requiredArgumentMissing('message');\n showHelp();\n return void callback(1);\n }\n message = command;\n command = 'send';\n }\n // Try to parse JSON\n // TODO: can we use the methods from cliObjects?\n if (typeof message === 'string' && message.startsWith('{') && message.endsWith('}')) {\n message = JSON.parse(message);\n }\n\n dbConnect(async params => {\n const { states, objects } = params;\n\n try {\n const pos = adapter.indexOf('.');\n let instance = null;\n if (pos !== -1) {\n instance = adapter.substring(pos + 1);\n adapter = adapter.substring(0, pos);\n }\n let messageTargets = [];\n if (instance === null) {\n // This message wasn't meant for a specific instance,\n const adapterInstances = await enumInstances(objects, adapter);\n if (adapterInstances.length === 0) {\n CLI.error.noInstancesFound(adapter);\n return void callback(1);\n }\n messageTargets = adapterInstances.map(row => row._id);\n } else {\n messageTargets.unshift(`system.adapter.${adapter}.${instance}`);\n }\n\n // Send the message to all targets\n const messagePromises = messageTargets.map(t => sendMessage(states, t, command, message));\n await Promise.all(messagePromises);\n return void callback();\n } catch (err) {\n CLI.error.unknown(err.message);\n return void callback(1);\n }\n });\n }\n}\n\n/**\n * @param states The States DB\n * @param targetId The instance or adapter to send the message to\n * @param command The command to send\n * @param message The message to send\n */\nasync function sendMessage(states: StatesClient, targetId: string, command: string, message: string): Promise<void> {\n await states.pushMessage(targetId, { command, message, from: 'cli' });\n CLI.success.messageSent(targetId, command, message);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAAA,UAAqB;AACrB,wBAAmD;AACnD,sBAA8B;AAIxB,MAAO,mBAAmB,6BAAU;;EAEtC,YAAY,SAA0B;AAClC,UAAM,OAAO;EACjB;;;;;;EAOA,QAAQ,MAAW;AACf,UAAM,EAAE,UAAU,WAAW,SAAQ,IAAK,KAAK;AAC/C,QAAI,CAAC,SAAS,SAAS,OAAO,IAAI;AAClC,QAAI,YAAY,QAAQ,YAAY,QAAW;AAC3C,UAAI,MAAM,wBAAwB,SAAS;AAC3C,eAAQ;AACR,aAAO,KAAK,SAAS,CAAC;IAC1B;AACA,QAAI,YAAY,QAAQ,YAAY,QAAW;AAC3C,UAAI,YAAY,QAAQ,YAAY,QAAW;AAC3C,YAAI,MAAM,wBAAwB,SAAS;AAC3C,iBAAQ;AACR,eAAO,KAAK,SAAS,CAAC;MAC1B;AACA,gBAAU;AACV,gBAAU;IACd;AAGA,QAAI,OAAO,YAAY,YAAY,QAAQ,WAAW,GAAG,KAAK,QAAQ,SAAS,GAAG,GAAG;AACjF,gBAAU,KAAK,MAAM,OAAO;IAChC;AAEA,cAAU,OAAM,WAAS;AACrB,YAAM,EAAE,QAAQ,QAAO,IAAK;AAE5B,UAAI;AACA,cAAM,MAAM,QAAQ,QAAQ,GAAG;AAC/B,YAAI,WAAW;AACf,YAAI,QAAQ,IAAI;AACZ,qBAAW,QAAQ,UAAU,MAAM,CAAC;AACpC,oBAAU,QAAQ,UAAU,GAAG,GAAG;QACtC;AACA,YAAI,iBAAiB,CAAA;AACrB,YAAI,aAAa,MAAM;AAEnB,gBAAM,mBAAmB,UAAM,+BAAc,SAAS,OAAO;AAC7D,cAAI,iBAAiB,WAAW,GAAG;AAC/B,gBAAI,MAAM,iBAAiB,OAAO;AAClC,mBAAO,KAAK,SAAS,CAAC;UAC1B;AACA,2BAAiB,iBAAiB,IAAI,SAAO,IAAI,GAAG;QACxD,OAAO;AACH,yBAAe,QAAQ,kBAAkB,OAAO,IAAI,QAAQ,EAAE;QAClE;AAGA,cAAM,kBAAkB,eAAe,IAAI,OAAK,YAAY,QAAQ,GAAG,SAAS,OAAO,CAAC;AACxF,cAAM,QAAQ,IAAI,eAAe;AACjC,eAAO,KAAK,SAAQ;MACxB,SAAS,KAAK;AACV,YAAI,MAAM,QAAQ,IAAI,OAAO;AAC7B,eAAO,KAAK,SAAS,CAAC;MAC1B;IACJ,CAAC;EACL;;AASJ,eAAe,YAAY,QAAsB,UAAkB,SAAiB,SAAe;AAC/F,QAAM,OAAO,YAAY,UAAU,EAAE,SAAS,SAAS,MAAM,MAAK,CAAE;AACpE,MAAI,QAAQ,YAAY,UAAU,SAAS,OAAO;AACtD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,11 +3,14 @@ import type { Client as ObjectsClient } from '@iobroker/db-objects-redis';
|
|
|
3
3
|
import type { Client as StatesClient } from '@iobroker/db-states-redis';
|
|
4
4
|
/** Command iobroker object ... */
|
|
5
5
|
export declare class CLIObjects extends CLICommand {
|
|
6
|
+
/**
|
|
7
|
+
* @param options The command options including context and parameters
|
|
8
|
+
*/
|
|
6
9
|
constructor(options: CLICommandOptions);
|
|
7
10
|
/**
|
|
8
11
|
* Executes a command
|
|
9
12
|
*
|
|
10
|
-
* @param args
|
|
13
|
+
* @param args The command arguments (the first is the sub-command)
|
|
11
14
|
*/
|
|
12
15
|
execute(args: any[]): void;
|
|
13
16
|
/**
|
|
@@ -29,31 +32,31 @@ export declare class CLIObjects extends CLICommand {
|
|
|
29
32
|
/**
|
|
30
33
|
* Changes access rights for all objects matching the pattern
|
|
31
34
|
*
|
|
32
|
-
* @param args
|
|
35
|
+
* @param args The command arguments (object mode, state mode and pattern)
|
|
33
36
|
*/
|
|
34
37
|
chmod(args: any[]): void;
|
|
35
38
|
/**
|
|
36
39
|
* Changes owner for all objects matching the pattern
|
|
37
40
|
*
|
|
38
|
-
* @param args
|
|
41
|
+
* @param args The command arguments (user, group and pattern)
|
|
39
42
|
*/
|
|
40
43
|
chown(args: any[]): void;
|
|
41
44
|
/**
|
|
42
45
|
* Lists all objects matching a pattern and their access rights
|
|
43
46
|
*
|
|
44
|
-
* @param args
|
|
47
|
+
* @param args The command arguments (the pattern to match)
|
|
45
48
|
*/
|
|
46
49
|
list(args: any[]): void;
|
|
47
50
|
/**
|
|
48
51
|
* Retrieves an object or its property from the DB and prints it
|
|
49
52
|
*
|
|
50
|
-
* @param args
|
|
53
|
+
* @param args The command arguments (the object id and optional property path)
|
|
51
54
|
*/
|
|
52
55
|
get(args: any[]): void;
|
|
53
56
|
/**
|
|
54
57
|
* Updates an object or its property with the given value
|
|
55
58
|
*
|
|
56
|
-
* @param args
|
|
59
|
+
* @param args The command arguments (the object id and the value to set)
|
|
57
60
|
*/
|
|
58
61
|
set(args: any[]): void;
|
|
59
62
|
/**
|
|
@@ -68,7 +71,7 @@ export declare class CLIObjects extends CLICommand {
|
|
|
68
71
|
/**
|
|
69
72
|
* Extends an object with the given value
|
|
70
73
|
*
|
|
71
|
-
* @param args
|
|
74
|
+
* @param args The command arguments (the object id and the value to extend with)
|
|
72
75
|
*/
|
|
73
76
|
extend(args: any[]): void;
|
|
74
77
|
/**
|
|
@@ -83,13 +86,13 @@ export declare class CLIObjects extends CLICommand {
|
|
|
83
86
|
*
|
|
84
87
|
* @param objects class
|
|
85
88
|
* @param ids IDs
|
|
86
|
-
* @param callback
|
|
89
|
+
* @param callback Called with the exit code once all objects have been deleted
|
|
87
90
|
*/
|
|
88
91
|
_deleteObjects(objects: ObjectsClient, ids: string[], callback: (exitCode: number) => void): Promise<void>;
|
|
89
92
|
/**
|
|
90
93
|
* Deletes an object
|
|
91
94
|
*
|
|
92
|
-
* @param args
|
|
95
|
+
* @param args The command arguments (the object id to delete)
|
|
93
96
|
*/
|
|
94
97
|
delete(args: any[]): void;
|
|
95
98
|
/**
|
|
@@ -36,13 +36,16 @@ var CLI = __toESM(require("./messages.js"), 1);
|
|
|
36
36
|
var import_cliTools = require("./cliTools.js");
|
|
37
37
|
var import_js_controller_common = require("@iobroker/js-controller-common");
|
|
38
38
|
class CLIObjects 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;
|
|
@@ -162,7 +165,7 @@ class CLIObjects extends import_cliCommand.CLICommand {
|
|
|
162
165
|
/**
|
|
163
166
|
* Changes access rights for all objects matching the pattern
|
|
164
167
|
*
|
|
165
|
-
* @param args
|
|
168
|
+
* @param args The command arguments (object mode, state mode and pattern)
|
|
166
169
|
*/
|
|
167
170
|
chmod(args) {
|
|
168
171
|
const { callback, dbConnect } = this.options;
|
|
@@ -192,7 +195,7 @@ class CLIObjects extends import_cliCommand.CLICommand {
|
|
|
192
195
|
/**
|
|
193
196
|
* Changes owner for all objects matching the pattern
|
|
194
197
|
*
|
|
195
|
-
* @param args
|
|
198
|
+
* @param args The command arguments (user, group and pattern)
|
|
196
199
|
*/
|
|
197
200
|
chown(args) {
|
|
198
201
|
const { callback, dbConnect } = this.options;
|
|
@@ -224,7 +227,7 @@ class CLIObjects extends import_cliCommand.CLICommand {
|
|
|
224
227
|
/**
|
|
225
228
|
* Lists all objects matching a pattern and their access rights
|
|
226
229
|
*
|
|
227
|
-
* @param args
|
|
230
|
+
* @param args The command arguments (the pattern to match)
|
|
228
231
|
*/
|
|
229
232
|
list(args) {
|
|
230
233
|
const { callback, dbConnect } = this.options;
|
|
@@ -243,7 +246,7 @@ class CLIObjects extends import_cliCommand.CLICommand {
|
|
|
243
246
|
/**
|
|
244
247
|
* Retrieves an object or its property from the DB and prints it
|
|
245
248
|
*
|
|
246
|
-
* @param args
|
|
249
|
+
* @param args The command arguments (the object id and optional property path)
|
|
247
250
|
*/
|
|
248
251
|
get(args) {
|
|
249
252
|
const { callback, pretty, dbConnect } = this.options;
|
|
@@ -275,7 +278,7 @@ class CLIObjects extends import_cliCommand.CLICommand {
|
|
|
275
278
|
/**
|
|
276
279
|
* Updates an object or its property with the given value
|
|
277
280
|
*
|
|
278
|
-
* @param args
|
|
281
|
+
* @param args The command arguments (the object id and the value to set)
|
|
279
282
|
*/
|
|
280
283
|
set(args) {
|
|
281
284
|
const { callback, dbConnect } = this.options;
|
|
@@ -361,7 +364,7 @@ class CLIObjects extends import_cliCommand.CLICommand {
|
|
|
361
364
|
/**
|
|
362
365
|
* Extends an object with the given value
|
|
363
366
|
*
|
|
364
|
-
* @param args
|
|
367
|
+
* @param args The command arguments (the object id and the value to extend with)
|
|
365
368
|
*/
|
|
366
369
|
extend(args) {
|
|
367
370
|
const { callback, dbConnect } = this.options;
|
|
@@ -429,7 +432,7 @@ class CLIObjects extends import_cliCommand.CLICommand {
|
|
|
429
432
|
*
|
|
430
433
|
* @param objects class
|
|
431
434
|
* @param ids IDs
|
|
432
|
-
* @param callback
|
|
435
|
+
* @param callback Called with the exit code once all objects have been deleted
|
|
433
436
|
*/
|
|
434
437
|
async _deleteObjects(objects, ids, callback) {
|
|
435
438
|
if (!ids || !ids.length) {
|
|
@@ -454,7 +457,7 @@ class CLIObjects extends import_cliCommand.CLICommand {
|
|
|
454
457
|
/**
|
|
455
458
|
* Deletes an object
|
|
456
459
|
*
|
|
457
|
-
* @param args
|
|
460
|
+
* @param args The command arguments (the object id to delete)
|
|
458
461
|
*/
|
|
459
462
|
delete(args) {
|
|
460
463
|
const { callback, dbConnect } = this.options;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/cli/cliObjects.ts"],
|
|
4
|
-
"sourcesContent": ["import { CLICommand, type CLICommandOptions } from './cliCommand.js';\n\nimport * as CLI from './messages.js';\nimport { formatValue } from './cliTools.js';\nimport { tools, EXIT_CODES } from '@iobroker/js-controller-common';\nimport type { Client as ObjectsClient } from '@iobroker/db-objects-redis';\nimport type { Client as StatesClient } from '@iobroker/db-states-redis';\n\ninterface ParsedPropPathAndAssignment {\n propPath?: string;\n value: unknown;\n}\n\n/** Command iobroker object ... */\nexport class CLIObjects 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 { callback, showHelp } = this.options;\n const command = args[0];\n\n switch (command) {\n case 'chmod':\n return this.chmod(args);\n case 'chown':\n return this.chown(args);\n case 'list':\n case 'l':\n return this.list(args);\n case 'get':\n return this.get(args);\n case 'set':\n return this.set(args);\n case 'extend':\n return this.extend(args);\n case 'delete':\n case 'del':\n return this.delete(args);\n case 'getDBVersion':\n return this.getDBVersion();\n case 'setDBVersion':\n return this.setDBVersion();\n case 'activateSets':\n return this.activateSets();\n case 'deactivateSets':\n return this.deactivateSets();\n default:\n CLI.error.unknownCommand('object', command);\n showHelp();\n return void callback(3);\n }\n }\n\n /**\n * Activates the usage of Redis Sets\n */\n activateSets(): void {\n const { callback, dbConnect } = this.options;\n dbConnect(async params => {\n const { states, objects } = params;\n\n const useSetsIndicator = await objects.getMeta('objects.features.useSets');\n\n if (!useSetsIndicator || !parseInt(useSetsIndicator)) {\n // all hosts need to be stopped for this\n if (await tools.isHostRunning(objects, states)) {\n console.log('Cannot activate the usage of Redis Sets while one or more hosts are running');\n return void callback(EXIT_CODES.CONTROLLER_RUNNING);\n }\n\n await objects.activateSets();\n const noMigrated = await objects.migrateToSets();\n\n if (noMigrated) {\n console.log(`Successfully migrated ${noMigrated} objects to Redis Sets`);\n }\n console.log(\n `Successfully activated the usage of Redis Sets. Please make sure to only use js-controller 4.0 or higher on all hosts!`,\n );\n } else {\n console.log('Redis Sets are already activated.');\n }\n return void callback(EXIT_CODES.NO_ERROR);\n });\n }\n\n /**\n * Deactivates the usage of Redis Sets\n */\n deactivateSets(): void {\n const { callback, dbConnect } = this.options;\n dbConnect(async params => {\n const { objects } = params;\n const useSetsIndicator = await objects.getMeta('objects.features.useSets');\n\n if (useSetsIndicator && parseInt(useSetsIndicator)) {\n await objects.deactivateSets();\n console.log(`Successfully deactivated the usage of Redis Sets.`);\n } else {\n console.log('Redis Sets are already deactivated.');\n }\n return void callback(EXIT_CODES.NO_ERROR);\n });\n }\n\n /**\n * Get the protocol version\n */\n getDBVersion(): void {\n const { callback, dbConnect } = this.options;\n dbConnect(async params => {\n const { objects } = params;\n\n const version = await objects.getProtocolVersion();\n console.log(`Current Objects DB protocol version: ${version}`);\n return void callback(EXIT_CODES.NO_ERROR);\n });\n }\n\n /**\n * Set protocol version\n */\n setDBVersion(): void {\n const { callback, dbConnect } = this.options;\n dbConnect(async params => {\n const { objects } = params;\n const rl = await import('readline-sync');\n\n let answer = rl.question('Changing the protocol version will restart all hosts! Continue? [N/y]', {\n limit: /^(yes|y|n|no)$/i,\n defaultInput: 'no',\n });\n\n answer = answer.toLowerCase();\n\n if (answer !== 'y' && answer !== 'yes') {\n console.log('Protocol version has not been changed!');\n return void callback(EXIT_CODES.NO_ERROR);\n }\n\n try {\n await objects.setProtocolVersion(this.options.version);\n } catch (e) {\n console.error(`Cannot update protocol version: ${e.message}`);\n return void callback(1);\n }\n console.log(`Objects DB protocol updated to version ${this.options.version}`);\n return void callback(EXIT_CODES.NO_ERROR);\n });\n }\n\n /**\n * Changes access rights for all objects matching the pattern\n *\n * @param args\n */\n chmod(args: any[]): void {\n const { callback, dbConnect } = this.options;\n let [modeObject, modeState, pattern] = args.slice(1);\n\n // Yargs converts numeric string to number, so we can use that to test\n // Afterwards we parse them ourselves, but with base16\n if (typeof modeObject !== 'number') {\n CLI.error.requiredArgumentMissing('mode', 'object chmod 644 system.*');\n return void callback(1);\n }\n modeObject = parseInt(modeObject.toString(), 16);\n\n if (typeof modeState === 'number') {\n // a mode for the state was given, convert it\n modeState = parseInt(modeState.toString(), 16);\n } else {\n pattern = modeState;\n modeState = undefined;\n }\n\n if (pattern === undefined) {\n CLI.error.requiredArgumentMissing('pattern', 'object chmod 644 system.*');\n return void callback(1);\n }\n\n dbConnect(params => {\n const { objects, states } = params;\n\n objects.chmodObject(\n pattern,\n { user: 'system.user.admin', object: modeObject, state: modeState },\n (err, processed) => {\n // Print the new object rights\n this.printObjectList(objects, states, err?.message, processed);\n },\n );\n });\n }\n\n /**\n * Changes owner for all objects matching the pattern\n *\n * @param args\n */\n chown(args: any[]): void {\n const { callback, dbConnect } = this.options;\n let [user, group, pattern] = args.slice(1);\n\n if (!pattern) {\n pattern = group;\n group = undefined;\n }\n\n if (!user) {\n CLI.error.requiredArgumentMissing('user', 'object chown user system.*');\n return void callback(1);\n } else if (!user.startsWith('system.user.')) {\n user = `system.user.${user}`;\n }\n if (group && !group.startsWith('system.group.')) {\n group = `system.group.${group}`;\n }\n\n if (!pattern) {\n CLI.error.requiredArgumentMissing('pattern', 'object chown user system.*');\n return void callback(1);\n }\n dbConnect(params => {\n const { objects, states } = params;\n\n objects.chownObject(\n pattern,\n { user: 'system.user.admin', owner: user, ownerGroup: group },\n (err, processed) => {\n // Print the new object rights\n this.printObjectList(objects, states, err?.message, processed);\n },\n );\n });\n }\n\n /**\n * Lists all objects matching a pattern and their access rights\n *\n * @param args\n */\n list(args: any[]): void {\n const { callback, dbConnect } = this.options;\n let pattern = args[1];\n if (typeof pattern === 'string') {\n pattern = { startkey: pattern.replace('*', ''), endkey: pattern.replace('*', '\\u9999') };\n }\n\n dbConnect(params => {\n const { objects, states } = params;\n\n objects.getObjectList(pattern, { user: 'system.user.admin', sorted: true }, (err, processed) => {\n this.printObjectList(\n objects,\n states,\n err?.message,\n processed && processed.rows && processed.rows.map(r => r.value),\n );\n return void callback(EXIT_CODES.NO_ERROR);\n });\n });\n }\n\n /**\n * Retrieves an object or its property from the DB and prints it\n *\n * @param args\n */\n get(args: any[]): void {\n const { callback, pretty, dbConnect } = this.options;\n const [id, propPath] = args.slice(1);\n if (!id) {\n CLI.error.requiredArgumentMissing('id', 'object get id [propertypath]');\n return void callback(1);\n }\n\n // If propPath is passed, the given property will be retrieved instead.\n // For example: `\"native.something[2].onething\"` selects `onething` of the 3rd array element of `object.native.something`.\n\n dbConnect(params => {\n const { objects } = params;\n\n objects.getObject(id, (err, res) => {\n if (err || !res) {\n CLI.error.objectNotFound(id, err?.message);\n return void callback(3);\n }\n if (typeof propPath === 'string') {\n // We want to select a part of the object\n try {\n res = deepSelectProperty(res, propPath);\n } catch {\n CLI.error.objectPropertyNotFound(id, propPath);\n return void callback(3);\n }\n }\n console.log(formatValue(res, pretty));\n return void callback(EXIT_CODES.NO_ERROR);\n });\n });\n }\n\n /**\n * Updates an object or its property with the given value\n *\n * @param args\n */\n set(args: any[]): void {\n const { callback, dbConnect } = this.options;\n const id: string = args[1];\n if (!id) {\n CLI.error.requiredArgumentMissing('id', 'object set id [propertypath=]value');\n return void callback(1);\n }\n\n const lastArg = args.length >= 2 ? args.slice(2).join(' ') : undefined;\n const parsedArg = parsePropPathAndAssignment(lastArg!);\n if (!parsedArg) {\n CLI.error.invalidPropertyOrValue();\n return void callback(3);\n }\n const { propPath, value } = parsedArg;\n\n dbConnect(params => {\n const { objects } = params;\n\n const doSetObject = (obj: any): void => {\n objects.setObject(id, obj, err => {\n if (err) {\n CLI.error.cannotUpdateObject(id, err.message);\n return void callback(1);\n }\n CLI.success.objectUpdated(id);\n return void callback(EXIT_CODES.NO_ERROR);\n });\n };\n if (!propPath) {\n // We set the entire object, no need to retrieve it first\n doSetObject(value as any);\n } else {\n // We want to update a part of the object\n // Retrieve the object first\n objects.getObject(id, async (err, res) => {\n if (err || !res) {\n CLI.error.objectNotFound(id, err?.message);\n return void callback(3);\n }\n try {\n deepSetProperty(res, propPath, value);\n } catch {\n CLI.error.objectPropertyNotFound(id, propPath);\n return void callback(3);\n }\n\n // auto encrypt -> only do that here, no one configures an instance by setting the whole object,\n // else it would be copied and probably already encrypted\n if (\n /^system\\.adapter\\.(?<adapterName>.+)\\.(?<instanceNr>\\d+)$/g.test(id) &&\n 'encryptedNative' in res\n ) {\n await this._autoEncrypt(objects, res, propPath, value);\n }\n\n doSetObject(res);\n });\n }\n });\n }\n\n /**\n * Encrypts all newly set properties of encryptedNative - currently customized for propPath\n *\n * @param objects - objects db instance\n * @param res - object which will be adapted\n * @param propPath - path of the changed property\n * @param value - value which has been newly set to the property\n */\n private async _autoEncrypt(\n objects: ObjectsClient,\n res: ioBroker.AnyObject,\n propPath: string,\n value: any,\n ): Promise<void> {\n // input: it's an instance object and has encrypted native, was a native value set?\n if (/^native\\..+[^.]$/g.test(propPath) && typeof value === 'string') {\n // single native property\n const prop = propPath.split('.')[1];\n if ('encryptedNative' in res && res.encryptedNative?.includes(prop)) {\n try {\n const config = await objects.getObjectAsync('system.config');\n res.native[prop] = tools.encrypt(config!.native.secret, res.native[prop]);\n } catch (e) {\n console.error(`Could not auto-encrypt property \"${prop}\": ${e.message}`);\n }\n }\n } else if (propPath === 'native' && tools.isObject(value)) {\n // whole native attribute\n let config;\n for (const prop in value) {\n if (\n typeof (res.native as Record<string, any>)[prop] === 'string' &&\n 'encryptedNative' in res &&\n res.encryptedNative?.includes(prop)\n ) {\n try {\n config = config || (await objects.getObjectAsync('system.config'))!;\n res.native[prop] = tools.encrypt(config.native.secret, res.native[prop]);\n } catch (e) {\n console.error(`Could not auto-encrypt property \"${prop}\": ${e.message}`);\n }\n }\n }\n }\n }\n\n /**\n * Extends an object with the given value\n *\n * @param args\n */\n extend(args: any[]): void {\n const { callback, dbConnect } = this.options;\n const id: string = args[1];\n if (!id) {\n CLI.error.requiredArgumentMissing('id', 'object extend id <json-value>');\n return void callback(1);\n }\n\n const lastArg = args.length >= 2 ? args.slice(2).join(' ') : undefined;\n const parsedArg = parsePropPathAndAssignment(lastArg!);\n // extend does not accept a property path, so error when one is passed\n if (!parsedArg || parsedArg.propPath) {\n CLI.error.invalidJSONValue();\n return void callback(3);\n }\n const { value } = parsedArg;\n\n dbConnect(params => {\n const { objects } = params;\n\n objects.extendObject(id, value as any, null, err => {\n if (err) {\n CLI.error.cannotUpdateObject(id, err.message);\n return void callback(1);\n }\n CLI.success.objectUpdated(id);\n return void callback(EXIT_CODES.NO_ERROR);\n });\n });\n }\n\n /**\n * Collects all object for specific path\n *\n * @param objects class\n * @param params parameters for getObjectView\n */\n async _collectObjects(objects: ObjectsClient, params: ioBroker.GetObjectViewParams): Promise<ioBroker.AnyObject[]> {\n const types = [\n 'state',\n 'channel',\n 'device',\n 'enum',\n 'instance',\n 'host',\n 'adapter',\n 'meta',\n 'config',\n 'group',\n 'user',\n 'script',\n ];\n const result: ioBroker.AnyObject[] = [];\n\n for (const type of types) {\n try {\n const res = await objects.getObjectViewAsync('system', type, params);\n res.rows.forEach(item => {\n if (item.value) {\n result.push(item.value);\n }\n });\n } catch {\n // ignore\n }\n }\n return result;\n }\n\n /**\n * Delete all object from list sequentially\n *\n * @param objects class\n * @param ids IDs\n * @param callback\n */\n async _deleteObjects(objects: ObjectsClient, ids: string[], callback: (exitCode: number) => void): Promise<void> {\n if (!ids || !ids.length) {\n return tools.maybeCallback(callback, EXIT_CODES.NO_ERROR);\n }\n let allEnums;\n\n try {\n // cache all enums, else it will be slow to delete many objects\n allEnums = await tools.getAllEnums(objects);\n } catch (e) {\n console.error(`Could not retrieve all enums: ${e.message}`);\n }\n\n for (const id of ids) {\n try {\n await objects.delObjectAsync(id);\n await tools.removeIdFromAllEnums(objects, id, allEnums);\n } catch (e) {\n console.warn(`Could not delete object or remove \"${id}\" from enums: ${e.message}`);\n }\n }\n return tools.maybeCallback(callback, EXIT_CODES.NO_ERROR);\n }\n\n /**\n * Deletes an object\n *\n * @param args\n */\n delete(args: any[]): void {\n const { callback, dbConnect } = this.options;\n const id: string = args[1];\n if (!id) {\n CLI.error.requiredArgumentMissing('id', 'object delete id');\n return void callback(1);\n }\n\n dbConnect(async params => {\n const { objects } = params;\n\n if (id.endsWith('*')) {\n const params = {\n startkey: id.replace(/\\*/g, ''),\n endkey: id.replace(/\\*/g, '\\u9999'),\n };\n\n const result = await this._collectObjects(objects, params);\n if (!result || !result.length) {\n console.log('No IDs found for this pattern.');\n return void callback(EXIT_CODES.NO_ERROR);\n }\n const ids = result.map(item => item._id);\n\n // if no auto confirmation, ask user\n if (!this.options.f && this.options.y && !this.options.yes) {\n const rl = (await import('node:readline')).createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n rl.question(`${result.length} object(s) will be deleted. Are you sure? [y/N]: `, answer => {\n rl.close();\n if (\n answer === 'y' ||\n answer === 'yes' ||\n answer === 'j' ||\n answer === 'ja' ||\n answer === '\u0434\u0430' ||\n answer === '\u0434'\n ) {\n this._deleteObjects(objects, ids, callback);\n } else {\n console.log('Aborted.');\n return void callback(3);\n }\n });\n } else {\n this._deleteObjects(objects, ids, callback);\n }\n } else {\n // only one object\n objects.delObject(id, async err => {\n if (err) {\n CLI.error.objectNotFound(id, err.message);\n callback(3);\n } else {\n try {\n await tools.removeIdFromAllEnums(objects, id);\n CLI.success.objectDeleted(id);\n callback(EXIT_CODES.NO_ERROR);\n } catch (e) {\n CLI.error.cannotDeleteObjectFromEnums(id, e.message);\n callback(3);\n }\n }\n });\n }\n });\n }\n\n /**\n * Prints a list of objects and its access properties\n *\n * @param objects objects db\n * @param states states db\n * @param err An error (if one occurred)\n * @param objList The object list to print\n */\n async printObjectList(\n objects: ObjectsClient,\n states: StatesClient,\n err: string | undefined,\n objList?: ioBroker.AnyObject[],\n ): Promise<void> {\n // TODO: is this supposed to be here?\n const { callback } = this.options;\n if (err) {\n console.error(err);\n return void callback(33);\n }\n if (objList !== null && objList !== undefined) {\n const { List } = await import('../setup/setupList.js');\n const list = new List({\n states,\n objects,\n processExit: callback,\n });\n list.showObjectHeader();\n objList.forEach(list.showObject);\n }\n setTimeout(callback, 1_000);\n }\n}\n\n/**\n * Reverses a string\n *\n * @param str The string to reverse\n */\nfunction reverseString(str: string): string {\n return Array.from(str).reverse().join('');\n}\n\n/**\n * Normalizes a property path for use in deepSelectProperty and deepSetProperty\n *\n * @param path The property path to normalize\n */\nfunction normalizePropertyPath(path: string): string {\n // Basically we want to support paths like \"obj[1][2]\", but the other methods expect \"obj.[1].[2]\"\n // So we need to replace all occurences of square brackets without leading dots\n // JS Regex only supports negative lookbehind in ES 2018, so we fake it using reversed strings and\n // negative lookahead\n const arrayIndexRegex = /(]\\d+\\[)(?!\\.)/g; // Reversing the string reverses the brackets too\n let ret = reverseString(path);\n // Append the dot to each bracket, since we're going to reverse it\n ret = ret.replace(arrayIndexRegex, '$1.');\n return reverseString(ret);\n}\n\n/**\n * Selects a property of an object or its sub-objects and returns it if it exists. E.g.\n * `deepSelectProperty(obj, \"common.asdf.qwer\")` => `obj.common.asdf.qwer`\n *\n * @param object The object to select a property from\n * @param path The property path to search for\n */\nfunction deepSelectProperty(object: ioBroker.AnyObject, path: string): any {\n /**\n * @param obj\n * @param pathArr\n */\n function _deepSelectProperty(obj: any, pathArr: string[]): unknown {\n // are we there yet? then return obj\n if (!pathArr.length) {\n return obj;\n }\n // go deeper\n let propName = pathArr.shift()!;\n if (/\\[\\d+]/.test(propName)) {\n // this is an array index\n // @ts-expect-error // TODO: fix it - this is not ts fashion, assigning numbers to the string array here\n propName = parseInt(propName.slice(1, -1));\n }\n return _deepSelectProperty(obj[propName], pathArr);\n }\n path = normalizePropertyPath(path);\n return _deepSelectProperty(object, path.split('.'));\n}\n\n/**\n * Changes a property of an object or its sub-objects if it exists. Opposite of `deepSelectProperty`.\n *\n * @param object The object to replace a property in\n * @param path The property path to search for\n * @param value\n */\nfunction deepSetProperty(object: ioBroker.AnyObject, path: string, value: any): void {\n /**\n * @param obj\n * @param pathArr\n */\n function _deepSetProperty(obj: any, pathArr: string[]): void {\n // are we there yet? then return obj\n if (pathArr.length === 1) {\n obj[pathArr[0]] = value;\n return;\n }\n // go deeper\n let propName = pathArr.shift()!;\n if (/\\[\\d+]/.test(propName)) {\n // this is an array index\n // @ts-expect-error // TODO: fix it - this is not ts fashion, assigning numbers to the string array here\n propName = parseInt(propName.slice(1, -1));\n }\n _deepSetProperty(obj[propName], pathArr);\n }\n path = normalizePropertyPath(path);\n _deepSetProperty(object, path.split('.'));\n}\n\n/**\n * Tries to parse a CLI argument that could be used to set an object\n *\n * @param arg The CLI argument containing the value to be set\n */\nfunction parseCLIValue(arg: string): any {\n try {\n // JSON.parse does not allow plain strings\n return JSON.parse(arg);\n } catch {\n // arg is a string\n return arg;\n }\n}\n\n/**\n * Tries to parse a CLI argument of the form [propPath=]value.\n *\n * @param arg The CLI argument containing an optional prop path and a JSON value\n */\nfunction parsePropPathAndAssignment(arg: string): ParsedPropPathAndAssignment | undefined {\n const equalsIndex = arg.indexOf('=');\n if (equalsIndex > -1) {\n // This might contain a propPath AND a value\n const propPath = arg.substr(0, equalsIndex);\n const valueString = arg.substr(equalsIndex + 1);\n // For partial assignments, allow strings as the value\n const value = parseCLIValue(valueString);\n return { propPath, value };\n }\n // This is a full assignment, allow only objects\n try {\n const value = JSON.parse(arg);\n if (!tools.isObject(value)) {\n return undefined;\n }\n return { value };\n } catch {\n // nope!\n return undefined;\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAAA,wBAAmD;AAEnD,UAAqB;AACrB,sBAA4B;AAC5B,kCAAkC;AAU5B,MAAO,mBAAmB,6BAAU;EACtC,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;AACD,eAAO,KAAK,MAAM,IAAI;MAC1B,KAAK;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ACJ;",
|
|
4
|
+
"sourcesContent": ["import { CLICommand, type CLICommandOptions } from './cliCommand.js';\n\nimport * as CLI from './messages.js';\nimport { formatValue } from './cliTools.js';\nimport { tools, EXIT_CODES } from '@iobroker/js-controller-common';\nimport type { Client as ObjectsClient } from '@iobroker/db-objects-redis';\nimport type { Client as StatesClient } from '@iobroker/db-states-redis';\n\ninterface ParsedPropPathAndAssignment {\n propPath?: string;\n value: unknown;\n}\n\n/** Command iobroker object ... */\nexport class CLIObjects 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 { callback, showHelp } = this.options;\n const command = args[0];\n\n switch (command) {\n case 'chmod':\n return this.chmod(args);\n case 'chown':\n return this.chown(args);\n case 'list':\n case 'l':\n return this.list(args);\n case 'get':\n return this.get(args);\n case 'set':\n return this.set(args);\n case 'extend':\n return this.extend(args);\n case 'delete':\n case 'del':\n return this.delete(args);\n case 'getDBVersion':\n return this.getDBVersion();\n case 'setDBVersion':\n return this.setDBVersion();\n case 'activateSets':\n return this.activateSets();\n case 'deactivateSets':\n return this.deactivateSets();\n default:\n CLI.error.unknownCommand('object', command);\n showHelp();\n return void callback(3);\n }\n }\n\n /**\n * Activates the usage of Redis Sets\n */\n activateSets(): void {\n const { callback, dbConnect } = this.options;\n dbConnect(async params => {\n const { states, objects } = params;\n\n const useSetsIndicator = await objects.getMeta('objects.features.useSets');\n\n if (!useSetsIndicator || !parseInt(useSetsIndicator)) {\n // all hosts need to be stopped for this\n if (await tools.isHostRunning(objects, states)) {\n console.log('Cannot activate the usage of Redis Sets while one or more hosts are running');\n return void callback(EXIT_CODES.CONTROLLER_RUNNING);\n }\n\n await objects.activateSets();\n const noMigrated = await objects.migrateToSets();\n\n if (noMigrated) {\n console.log(`Successfully migrated ${noMigrated} objects to Redis Sets`);\n }\n console.log(\n `Successfully activated the usage of Redis Sets. Please make sure to only use js-controller 4.0 or higher on all hosts!`,\n );\n } else {\n console.log('Redis Sets are already activated.');\n }\n return void callback(EXIT_CODES.NO_ERROR);\n });\n }\n\n /**\n * Deactivates the usage of Redis Sets\n */\n deactivateSets(): void {\n const { callback, dbConnect } = this.options;\n dbConnect(async params => {\n const { objects } = params;\n const useSetsIndicator = await objects.getMeta('objects.features.useSets');\n\n if (useSetsIndicator && parseInt(useSetsIndicator)) {\n await objects.deactivateSets();\n console.log(`Successfully deactivated the usage of Redis Sets.`);\n } else {\n console.log('Redis Sets are already deactivated.');\n }\n return void callback(EXIT_CODES.NO_ERROR);\n });\n }\n\n /**\n * Get the protocol version\n */\n getDBVersion(): void {\n const { callback, dbConnect } = this.options;\n dbConnect(async params => {\n const { objects } = params;\n\n const version = await objects.getProtocolVersion();\n console.log(`Current Objects DB protocol version: ${version}`);\n return void callback(EXIT_CODES.NO_ERROR);\n });\n }\n\n /**\n * Set protocol version\n */\n setDBVersion(): void {\n const { callback, dbConnect } = this.options;\n dbConnect(async params => {\n const { objects } = params;\n const rl = await import('readline-sync');\n\n let answer = rl.question('Changing the protocol version will restart all hosts! Continue? [N/y]', {\n limit: /^(yes|y|n|no)$/i,\n defaultInput: 'no',\n });\n\n answer = answer.toLowerCase();\n\n if (answer !== 'y' && answer !== 'yes') {\n console.log('Protocol version has not been changed!');\n return void callback(EXIT_CODES.NO_ERROR);\n }\n\n try {\n await objects.setProtocolVersion(this.options.version);\n } catch (e) {\n console.error(`Cannot update protocol version: ${e.message}`);\n return void callback(1);\n }\n console.log(`Objects DB protocol updated to version ${this.options.version}`);\n return void callback(EXIT_CODES.NO_ERROR);\n });\n }\n\n /**\n * Changes access rights for all objects matching the pattern\n *\n * @param args The command arguments (object mode, state mode and pattern)\n */\n chmod(args: any[]): void {\n const { callback, dbConnect } = this.options;\n let [modeObject, modeState, pattern] = args.slice(1);\n\n // Yargs converts numeric string to number, so we can use that to test\n // Afterwards we parse them ourselves, but with base16\n if (typeof modeObject !== 'number') {\n CLI.error.requiredArgumentMissing('mode', 'object chmod 644 system.*');\n return void callback(1);\n }\n modeObject = parseInt(modeObject.toString(), 16);\n\n if (typeof modeState === 'number') {\n // a mode for the state was given, convert it\n modeState = parseInt(modeState.toString(), 16);\n } else {\n pattern = modeState;\n modeState = undefined;\n }\n\n if (pattern === undefined) {\n CLI.error.requiredArgumentMissing('pattern', 'object chmod 644 system.*');\n return void callback(1);\n }\n\n dbConnect(params => {\n const { objects, states } = params;\n\n objects.chmodObject(\n pattern,\n { user: 'system.user.admin', object: modeObject, state: modeState },\n (err, processed) => {\n // Print the new object rights\n this.printObjectList(objects, states, err?.message, processed);\n },\n );\n });\n }\n\n /**\n * Changes owner for all objects matching the pattern\n *\n * @param args The command arguments (user, group and pattern)\n */\n chown(args: any[]): void {\n const { callback, dbConnect } = this.options;\n let [user, group, pattern] = args.slice(1);\n\n if (!pattern) {\n pattern = group;\n group = undefined;\n }\n\n if (!user) {\n CLI.error.requiredArgumentMissing('user', 'object chown user system.*');\n return void callback(1);\n } else if (!user.startsWith('system.user.')) {\n user = `system.user.${user}`;\n }\n if (group && !group.startsWith('system.group.')) {\n group = `system.group.${group}`;\n }\n\n if (!pattern) {\n CLI.error.requiredArgumentMissing('pattern', 'object chown user system.*');\n return void callback(1);\n }\n dbConnect(params => {\n const { objects, states } = params;\n\n objects.chownObject(\n pattern,\n { user: 'system.user.admin', owner: user, ownerGroup: group },\n (err, processed) => {\n // Print the new object rights\n this.printObjectList(objects, states, err?.message, processed);\n },\n );\n });\n }\n\n /**\n * Lists all objects matching a pattern and their access rights\n *\n * @param args The command arguments (the pattern to match)\n */\n list(args: any[]): void {\n const { callback, dbConnect } = this.options;\n let pattern = args[1];\n if (typeof pattern === 'string') {\n pattern = { startkey: pattern.replace('*', ''), endkey: pattern.replace('*', '\\u9999') };\n }\n\n dbConnect(params => {\n const { objects, states } = params;\n\n objects.getObjectList(pattern, { user: 'system.user.admin', sorted: true }, (err, processed) => {\n this.printObjectList(\n objects,\n states,\n err?.message,\n processed && processed.rows && processed.rows.map(r => r.value),\n );\n return void callback(EXIT_CODES.NO_ERROR);\n });\n });\n }\n\n /**\n * Retrieves an object or its property from the DB and prints it\n *\n * @param args The command arguments (the object id and optional property path)\n */\n get(args: any[]): void {\n const { callback, pretty, dbConnect } = this.options;\n const [id, propPath] = args.slice(1);\n if (!id) {\n CLI.error.requiredArgumentMissing('id', 'object get id [propertypath]');\n return void callback(1);\n }\n\n // If propPath is passed, the given property will be retrieved instead.\n // For example: `\"native.something[2].onething\"` selects `onething` of the 3rd array element of `object.native.something`.\n\n dbConnect(params => {\n const { objects } = params;\n\n objects.getObject(id, (err, res) => {\n if (err || !res) {\n CLI.error.objectNotFound(id, err?.message);\n return void callback(3);\n }\n if (typeof propPath === 'string') {\n // We want to select a part of the object\n try {\n res = deepSelectProperty(res, propPath);\n } catch {\n CLI.error.objectPropertyNotFound(id, propPath);\n return void callback(3);\n }\n }\n console.log(formatValue(res, pretty));\n return void callback(EXIT_CODES.NO_ERROR);\n });\n });\n }\n\n /**\n * Updates an object or its property with the given value\n *\n * @param args The command arguments (the object id and the value to set)\n */\n set(args: any[]): void {\n const { callback, dbConnect } = this.options;\n const id: string = args[1];\n if (!id) {\n CLI.error.requiredArgumentMissing('id', 'object set id [propertypath=]value');\n return void callback(1);\n }\n\n const lastArg = args.length >= 2 ? args.slice(2).join(' ') : undefined;\n const parsedArg = parsePropPathAndAssignment(lastArg!);\n if (!parsedArg) {\n CLI.error.invalidPropertyOrValue();\n return void callback(3);\n }\n const { propPath, value } = parsedArg;\n\n dbConnect(params => {\n const { objects } = params;\n\n const doSetObject = (obj: any): void => {\n objects.setObject(id, obj, err => {\n if (err) {\n CLI.error.cannotUpdateObject(id, err.message);\n return void callback(1);\n }\n CLI.success.objectUpdated(id);\n return void callback(EXIT_CODES.NO_ERROR);\n });\n };\n if (!propPath) {\n // We set the entire object, no need to retrieve it first\n doSetObject(value as any);\n } else {\n // We want to update a part of the object\n // Retrieve the object first\n objects.getObject(id, async (err, res) => {\n if (err || !res) {\n CLI.error.objectNotFound(id, err?.message);\n return void callback(3);\n }\n try {\n deepSetProperty(res, propPath, value);\n } catch {\n CLI.error.objectPropertyNotFound(id, propPath);\n return void callback(3);\n }\n\n // auto encrypt -> only do that here, no one configures an instance by setting the whole object,\n // else it would be copied and probably already encrypted\n if (\n /^system\\.adapter\\.(?<adapterName>.+)\\.(?<instanceNr>\\d+)$/g.test(id) &&\n 'encryptedNative' in res\n ) {\n await this._autoEncrypt(objects, res, propPath, value);\n }\n\n doSetObject(res);\n });\n }\n });\n }\n\n /**\n * Encrypts all newly set properties of encryptedNative - currently customized for propPath\n *\n * @param objects - objects db instance\n * @param res - object which will be adapted\n * @param propPath - path of the changed property\n * @param value - value which has been newly set to the property\n */\n private async _autoEncrypt(\n objects: ObjectsClient,\n res: ioBroker.AnyObject,\n propPath: string,\n value: any,\n ): Promise<void> {\n // input: it's an instance object and has encrypted native, was a native value set?\n if (/^native\\..+[^.]$/g.test(propPath) && typeof value === 'string') {\n // single native property\n const prop = propPath.split('.')[1];\n if ('encryptedNative' in res && res.encryptedNative?.includes(prop)) {\n try {\n const config = await objects.getObjectAsync('system.config');\n res.native[prop] = tools.encrypt(config!.native.secret, res.native[prop]);\n } catch (e) {\n console.error(`Could not auto-encrypt property \"${prop}\": ${e.message}`);\n }\n }\n } else if (propPath === 'native' && tools.isObject(value)) {\n // whole native attribute\n let config;\n for (const prop in value) {\n if (\n typeof (res.native as Record<string, any>)[prop] === 'string' &&\n 'encryptedNative' in res &&\n res.encryptedNative?.includes(prop)\n ) {\n try {\n config = config || (await objects.getObjectAsync('system.config'))!;\n res.native[prop] = tools.encrypt(config.native.secret, res.native[prop]);\n } catch (e) {\n console.error(`Could not auto-encrypt property \"${prop}\": ${e.message}`);\n }\n }\n }\n }\n }\n\n /**\n * Extends an object with the given value\n *\n * @param args The command arguments (the object id and the value to extend with)\n */\n extend(args: any[]): void {\n const { callback, dbConnect } = this.options;\n const id: string = args[1];\n if (!id) {\n CLI.error.requiredArgumentMissing('id', 'object extend id <json-value>');\n return void callback(1);\n }\n\n const lastArg = args.length >= 2 ? args.slice(2).join(' ') : undefined;\n const parsedArg = parsePropPathAndAssignment(lastArg!);\n // extend does not accept a property path, so error when one is passed\n if (!parsedArg || parsedArg.propPath) {\n CLI.error.invalidJSONValue();\n return void callback(3);\n }\n const { value } = parsedArg;\n\n dbConnect(params => {\n const { objects } = params;\n\n objects.extendObject(id, value as any, null, err => {\n if (err) {\n CLI.error.cannotUpdateObject(id, err.message);\n return void callback(1);\n }\n CLI.success.objectUpdated(id);\n return void callback(EXIT_CODES.NO_ERROR);\n });\n });\n }\n\n /**\n * Collects all object for specific path\n *\n * @param objects class\n * @param params parameters for getObjectView\n */\n async _collectObjects(objects: ObjectsClient, params: ioBroker.GetObjectViewParams): Promise<ioBroker.AnyObject[]> {\n const types = [\n 'state',\n 'channel',\n 'device',\n 'enum',\n 'instance',\n 'host',\n 'adapter',\n 'meta',\n 'config',\n 'group',\n 'user',\n 'script',\n ];\n const result: ioBroker.AnyObject[] = [];\n\n for (const type of types) {\n try {\n const res = await objects.getObjectViewAsync('system', type, params);\n res.rows.forEach(item => {\n if (item.value) {\n result.push(item.value);\n }\n });\n } catch {\n // ignore\n }\n }\n return result;\n }\n\n /**\n * Delete all object from list sequentially\n *\n * @param objects class\n * @param ids IDs\n * @param callback Called with the exit code once all objects have been deleted\n */\n async _deleteObjects(objects: ObjectsClient, ids: string[], callback: (exitCode: number) => void): Promise<void> {\n if (!ids || !ids.length) {\n return tools.maybeCallback(callback, EXIT_CODES.NO_ERROR);\n }\n let allEnums;\n\n try {\n // cache all enums, else it will be slow to delete many objects\n allEnums = await tools.getAllEnums(objects);\n } catch (e) {\n console.error(`Could not retrieve all enums: ${e.message}`);\n }\n\n for (const id of ids) {\n try {\n await objects.delObjectAsync(id);\n await tools.removeIdFromAllEnums(objects, id, allEnums);\n } catch (e) {\n console.warn(`Could not delete object or remove \"${id}\" from enums: ${e.message}`);\n }\n }\n return tools.maybeCallback(callback, EXIT_CODES.NO_ERROR);\n }\n\n /**\n * Deletes an object\n *\n * @param args The command arguments (the object id to delete)\n */\n delete(args: any[]): void {\n const { callback, dbConnect } = this.options;\n const id: string = args[1];\n if (!id) {\n CLI.error.requiredArgumentMissing('id', 'object delete id');\n return void callback(1);\n }\n\n dbConnect(async params => {\n const { objects } = params;\n\n if (id.endsWith('*')) {\n const params = {\n startkey: id.replace(/\\*/g, ''),\n endkey: id.replace(/\\*/g, '\\u9999'),\n };\n\n const result = await this._collectObjects(objects, params);\n if (!result || !result.length) {\n console.log('No IDs found for this pattern.');\n return void callback(EXIT_CODES.NO_ERROR);\n }\n const ids = result.map(item => item._id);\n\n // if no auto confirmation, ask user\n if (!this.options.f && this.options.y && !this.options.yes) {\n const rl = (await import('node:readline')).createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n rl.question(`${result.length} object(s) will be deleted. Are you sure? [y/N]: `, answer => {\n rl.close();\n if (\n answer === 'y' ||\n answer === 'yes' ||\n answer === 'j' ||\n answer === 'ja' ||\n answer === '\u0434\u0430' ||\n answer === '\u0434'\n ) {\n this._deleteObjects(objects, ids, callback);\n } else {\n console.log('Aborted.');\n return void callback(3);\n }\n });\n } else {\n this._deleteObjects(objects, ids, callback);\n }\n } else {\n // only one object\n objects.delObject(id, async err => {\n if (err) {\n CLI.error.objectNotFound(id, err.message);\n callback(3);\n } else {\n try {\n await tools.removeIdFromAllEnums(objects, id);\n CLI.success.objectDeleted(id);\n callback(EXIT_CODES.NO_ERROR);\n } catch (e) {\n CLI.error.cannotDeleteObjectFromEnums(id, e.message);\n callback(3);\n }\n }\n });\n }\n });\n }\n\n /**\n * Prints a list of objects and its access properties\n *\n * @param objects objects db\n * @param states states db\n * @param err An error (if one occurred)\n * @param objList The object list to print\n */\n async printObjectList(\n objects: ObjectsClient,\n states: StatesClient,\n err: string | undefined,\n objList?: ioBroker.AnyObject[],\n ): Promise<void> {\n // TODO: is this supposed to be here?\n const { callback } = this.options;\n if (err) {\n console.error(err);\n return void callback(33);\n }\n if (objList !== null && objList !== undefined) {\n const { List } = await import('../setup/setupList.js');\n const list = new List({\n states,\n objects,\n processExit: callback,\n });\n list.showObjectHeader();\n objList.forEach(list.showObject);\n }\n setTimeout(callback, 1_000);\n }\n}\n\n/**\n * Reverses a string\n *\n * @param str The string to reverse\n */\nfunction reverseString(str: string): string {\n return Array.from(str).reverse().join('');\n}\n\n/**\n * Normalizes a property path for use in deepSelectProperty and deepSetProperty\n *\n * @param path The property path to normalize\n */\nfunction normalizePropertyPath(path: string): string {\n // Basically we want to support paths like \"obj[1][2]\", but the other methods expect \"obj.[1].[2]\"\n // So we need to replace all occurences of square brackets without leading dots\n // JS Regex only supports negative lookbehind in ES 2018, so we fake it using reversed strings and\n // negative lookahead\n const arrayIndexRegex = /(]\\d+\\[)(?!\\.)/g; // Reversing the string reverses the brackets too\n let ret = reverseString(path);\n // Append the dot to each bracket, since we're going to reverse it\n ret = ret.replace(arrayIndexRegex, '$1.');\n return reverseString(ret);\n}\n\n/**\n * Selects a property of an object or its sub-objects and returns it if it exists. E.g.\n * `deepSelectProperty(obj, \"common.asdf.qwer\")` => `obj.common.asdf.qwer`\n *\n * @param object The object to select a property from\n * @param path The property path to search for\n */\nfunction deepSelectProperty(object: ioBroker.AnyObject, path: string): any {\n /**\n * @param obj The current (sub-)object being traversed\n * @param pathArr The remaining property path segments\n */\n function _deepSelectProperty(obj: any, pathArr: string[]): unknown {\n // are we there yet? then return obj\n if (!pathArr.length) {\n return obj;\n }\n // go deeper\n let propName = pathArr.shift()!;\n if (/\\[\\d+]/.test(propName)) {\n // this is an array index\n // @ts-expect-error // TODO: fix it - this is not ts fashion, assigning numbers to the string array here\n propName = parseInt(propName.slice(1, -1));\n }\n return _deepSelectProperty(obj[propName], pathArr);\n }\n path = normalizePropertyPath(path);\n return _deepSelectProperty(object, path.split('.'));\n}\n\n/**\n * Changes a property of an object or its sub-objects if it exists. Opposite of `deepSelectProperty`.\n *\n * @param object The object to replace a property in\n * @param path The property path to search for\n * @param value The value to set at the given property path\n */\nfunction deepSetProperty(object: ioBroker.AnyObject, path: string, value: any): void {\n /**\n * @param obj The current (sub-)object being traversed\n * @param pathArr The remaining property path segments\n */\n function _deepSetProperty(obj: any, pathArr: string[]): void {\n // are we there yet? then return obj\n if (pathArr.length === 1) {\n obj[pathArr[0]] = value;\n return;\n }\n // go deeper\n let propName = pathArr.shift()!;\n if (/\\[\\d+]/.test(propName)) {\n // this is an array index\n // @ts-expect-error // TODO: fix it - this is not ts fashion, assigning numbers to the string array here\n propName = parseInt(propName.slice(1, -1));\n }\n _deepSetProperty(obj[propName], pathArr);\n }\n path = normalizePropertyPath(path);\n _deepSetProperty(object, path.split('.'));\n}\n\n/**\n * Tries to parse a CLI argument that could be used to set an object\n *\n * @param arg The CLI argument containing the value to be set\n */\nfunction parseCLIValue(arg: string): any {\n try {\n // JSON.parse does not allow plain strings\n return JSON.parse(arg);\n } catch {\n // arg is a string\n return arg;\n }\n}\n\n/**\n * Tries to parse a CLI argument of the form [propPath=]value.\n *\n * @param arg The CLI argument containing an optional prop path and a JSON value\n */\nfunction parsePropPathAndAssignment(arg: string): ParsedPropPathAndAssignment | undefined {\n const equalsIndex = arg.indexOf('=');\n if (equalsIndex > -1) {\n // This might contain a propPath AND a value\n const propPath = arg.substr(0, equalsIndex);\n const valueString = arg.substr(equalsIndex + 1);\n // For partial assignments, allow strings as the value\n const value = parseCLIValue(valueString);\n return { propPath, value };\n }\n // This is a full assignment, allow only objects\n try {\n const value = JSON.parse(arg);\n if (!tools.isObject(value)) {\n return undefined;\n }\n return { value };\n } catch {\n // nope!\n return undefined;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAAA,wBAAmD;AAEnD,UAAqB;AACrB,sBAA4B;AAC5B,kCAAkC;AAU5B,MAAO,mBAAmB,6BAAU;;;;EAItC,YAAY,SAA0B;AA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O,EAAE,UAAU,MAAK;EAC5B;AAEA,MAAI;AACA,UAAM,QAAQ,KAAK,MAAM,GAAG;AAC5B,QAAI,CAAC,kCAAM,SAAS,KAAK,GAAG;AACxB,aAAO;IACX;AACA,WAAO,EAAE,MAAK;EAClB,QAAQ;AAEJ,WAAO;EACX;AACJ;",
|
|
6
6
|
"names": ["params"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/cli/cliPlugin.ts", "../../../../../../node_modules/@alcalzone/esm2cjs/shims/import.meta.url/shim.js"],
|
|
4
|
-
"sourcesContent": ["import * as CLI from './messages.js';\nimport { type CLICommandOptions, CLICommand } from './cliCommand.js';\nimport { getObjectFrom } from './cliTools.js';\nimport { tools } from '@iobroker/js-controller-common';\nimport fs from 'fs-extra';\nimport path from 'node:path';\nimport { createRequire } from 'node:module';\n\n// eslint-disable-next-line unicorn/prefer-module\nconst require = createRequire(import.meta.url || `file://${__filename}`);\n\nconst controllerIoPackPath = require.resolve('iobroker.js-controller/io-package.json');\n\ninterface CLIPluginOptions extends CLICommandOptions {\n /** If plugin is scoped on adapter */\n adapter?: string;\n /** If plugin is scoped on instance */\n instance?: string;\n}\n\n/** Command iobroker plugin <enable/disable/status> <pluginname> [--host this/hostname] ... */\nexport class CLIPlugin extends CLICommand<CLIPluginOptions> {\n /** @param options the cli command options */\n constructor(options: CLIPluginOptions) {\n super(options);\n }\n\n /**\n * Executes a command\n *\n * @param args parsed cli args\n */\n execute(args: any[]): void {\n const { callback, showHelp } = this.options;\n const command = args[0];\n\n switch (command) {\n case 'on':\n case 'enable':\n return this.set(args, true);\n case 'off':\n case 'disable':\n return this.set(args, false);\n case 'status':\n return this.status(args);\n default:\n CLI.error.unknownCommand('plugin', command);\n showHelp();\n return void callback(3);\n }\n }\n\n /**\n * Enables or disables the given plugin\n *\n * @param args the parsed CLI args\n * @param enabled if plugin should be enabled\n */\n set(args: any[], enabled: boolean): void {\n const { callback, dbConnect } = this.options;\n const pluginName: string = args[1];\n if (!pluginName) {\n CLI.error.requiredArgumentMissing('pluginName', 'plugin enable <pluginname>');\n return void callback(34);\n }\n\n let hostname: string;\n let instance: string;\n\n if (this.options.adapter || this.options.instance) {\n instance = (this.options.adapter || this.options.instance) as string;\n // default to instance 0\n if (!/\\.\\d+$/.test(instance)) {\n instance += '.0';\n }\n } else {\n // Use host if no adapter was specified and fallback to the current one\n hostname = this.options.host;\n if (!hostname || hostname === 'this') {\n hostname = tools.getHostName();\n }\n }\n\n dbConnect(async params => {\n const { states, objects, config: iobrokerJson } = params;\n\n try {\n // Check if the host or instance exists\n let objectNamespace: string;\n if (hostname) {\n objectNamespace = `system.host.${hostname}`;\n const hostObject = await objects.getObject(objectNamespace);\n if (!hostObject) {\n CLI.error.hostDoesNotExist(hostname);\n return void callback(30);\n }\n } else {\n objectNamespace = `system.adapter.${instance}`;\n const instanceObject = await objects.getObject(objectNamespace);\n if (!instanceObject) {\n CLI.error.invalidInstance(instance);\n return void callback(30);\n }\n }\n\n // Check if the plugin is defined\n if (!pluginExists(pluginName, iobrokerJson, instance)) {\n CLI.error.pluginNotDefined(pluginName, hostname, instance);\n return void callback(30);\n }\n\n // Create the plugin state if it does not exist\n const pluginsFolderId = `${objectNamespace}.plugins`;\n if (!(await objects.getObjectAsync(pluginsFolderId))) {\n await objects.setObject(pluginsFolderId, {\n type: 'folder',\n common: {\n name: `${hostname ? 'host' : 'instance'}: plugin states`,\n },\n native: {},\n });\n }\n const pluginFolderId = `${objectNamespace}.plugins.${pluginName}`;\n if (!(await objects.getObjectAsync(pluginFolderId))) {\n await objects.setObject(pluginFolderId, {\n type: 'folder',\n common: {\n name: `${pluginName}: plugin states`,\n },\n native: {},\n });\n }\n const pluginEnabledId = `${pluginFolderId}.enabled`;\n if (!(await objects.getObjectAsync(pluginEnabledId))) {\n await objects.setObject(pluginEnabledId, {\n type: 'state',\n common: {\n name: 'Plugin enabled',\n type: 'boolean',\n read: true,\n write: true,\n role: 'value',\n },\n native: {},\n });\n }\n\n // Update the state\n await states.setStateAsync(pluginEnabledId, {\n val: enabled,\n from: getObjectFrom(),\n });\n\n // Notify the user that we are done\n CLI.success.pluginEnabledOrDisabled(pluginName, hostname, instance, enabled);\n return void callback();\n } catch (err) {\n CLI.error.unknown(err.message);\n return void callback(1);\n }\n });\n }\n\n /**\n * Prints the status of the given plugin\n *\n * @param args the parsed CLI arguments\n */\n status(args: any[]): void {\n const { callback, dbConnect } = this.options;\n const pluginName = args[1];\n if (!pluginName) {\n CLI.error.requiredArgumentMissing('pluginName', 'plugin status <pluginname>');\n return void callback(34);\n }\n\n let hostname: string;\n let instance: string;\n\n if (this.options.adapter || this.options.instance) {\n instance = (this.options.adapter || this.options.instance) as string;\n // default to instance 0\n if (!/\\.\\d+$/.test(instance)) {\n instance += '.0';\n }\n } else {\n // Use host if no adapter was specified and fallback to the current one\n hostname = this.options.host;\n if (!hostname || hostname === 'this') {\n hostname = tools.getHostName();\n }\n }\n\n dbConnect(async params => {\n const { states, objects, config: iobrokerJson } = params;\n\n try {\n // Check if the host or instance exists\n let objectNamespace: string;\n if (hostname) {\n objectNamespace = `system.host.${hostname}`;\n const hostObject = await objects.getObject(objectNamespace);\n if (!hostObject) {\n CLI.error.hostDoesNotExist(hostname);\n return void callback(30);\n }\n } else {\n objectNamespace = `system.adapter.${instance}`;\n const instanceObject = await objects.getObject(objectNamespace);\n if (!instanceObject) {\n CLI.error.invalidInstance(instance);\n return void callback(30);\n }\n }\n\n // Check if the plugin is defined\n if (!pluginExists(pluginName, iobrokerJson, instance)) {\n CLI.error.pluginNotDefined(pluginName, hostname, instance);\n return void callback(30);\n }\n\n const pluginEnabledId = `${objectNamespace}.plugins.${pluginName}.enabled`;\n\n // Read the state\n try {\n const val = (await states.getStateAsync(pluginEnabledId))?.val;\n\n if (typeof val === 'boolean') {\n CLI.success.pluginStatus(pluginName, hostname, instance, val);\n return void callback();\n }\n } catch {\n /* ignore */\n }\n\n // If the state could not be read or had no value, fall back to the configuration\n const enabled = pluginEnabled(\n pluginName,\n instance,\n await objects.getObjectAsync('system.config'),\n iobrokerJson,\n );\n CLI.success.pluginStatus(pluginName, hostname, instance, enabled);\n return void callback();\n } catch (err) {\n CLI.error.unknown(err.message);\n return void callback(1);\n }\n });\n }\n}\n\n/**\n * Checks if a plugin exists and can be configured\n *\n * @param pluginName\n * @param iobrokerJson The contents of iobroker.json\n * @param [adapter] (optional) - If passed, the adapter configuration will be searched for defined plugins instead of js-controller\n */\nfunction pluginExists(pluginName: string, iobrokerJson?: ioBroker.IoBrokerJson, adapter?: string): boolean {\n // 1. check if the plugin is defined in io-package.json\n try {\n const ioPackPath = adapter ? path.join(tools.getAdapterDir(adapter)!, 'io-package.json') : controllerIoPackPath;\n const ioPack = fs.readJSONSync(ioPackPath, { encoding: 'utf8' });\n if (ioPack?.common?.plugins && pluginName in ioPack.common.plugins) {\n return true;\n }\n } catch {\n /* ignore */\n }\n\n // 2. check if the plugin is defined in iobroker.json\n return !!(iobrokerJson?.plugins && pluginName in iobrokerJson.plugins);\n}\n\n/**\n * Checks if a plugin exists and can be configured\n *\n * @param pluginName name of the plugin, e.g. `sentry`\n * @param adapter If defined, the adapter configuration will be searched for defined plugins instead of js-controller\n * @param systemConfig The system.config object\n * @param iobrokerJson The contents of iobroker.json\n */\nfunction pluginEnabled(\n pluginName: string,\n adapter?: string,\n systemConfig?: ioBroker.SystemConfigObject | null,\n iobrokerJson?: ioBroker.IoBrokerJson,\n): boolean {\n // 1. check if diagnostics are disabled in ioBroker\n if (systemConfig?.common?.diag === 'none') {\n return false;\n }\n\n // 2. check if the plugin is disabled in io-package.json\n try {\n const ioPackPath = adapter ? path.join(tools.getAdapterDir(adapter)!, 'io-package.json') : controllerIoPackPath;\n const ioPack = fs.readJSONSync(ioPackPath, { encoding: 'utf8' });\n if (\n ioPack?.common?.plugins &&\n pluginName in ioPack.common.plugins &&\n ioPack.common.plugins[pluginName].enabled === false\n ) {\n return false;\n }\n } catch {\n /* ignore */\n }\n\n // 3. check if the plugin is disabled in iobroker.json\n if (\n iobrokerJson?.plugins &&\n pluginName in iobrokerJson.plugins &&\n iobrokerJson.plugins[pluginName].enabled === false\n ) {\n return false;\n }\n\n // default: enabled\n return true;\n}\n", "export const __import_meta_url =\n typeof document === 'undefined' ? new (require('url'.replace('', '')).URL)('file:' + __filename).href :\n (document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href)\n"],
|
|
4
|
+
"sourcesContent": ["import * as CLI from './messages.js';\nimport { type CLICommandOptions, CLICommand } from './cliCommand.js';\nimport { getObjectFrom } from './cliTools.js';\nimport { tools } from '@iobroker/js-controller-common';\nimport fs from 'fs-extra';\nimport path from 'node:path';\nimport { createRequire } from 'node:module';\n\n// eslint-disable-next-line unicorn/prefer-module\nconst require = createRequire(import.meta.url || `file://${__filename}`);\n\nconst controllerIoPackPath = require.resolve('iobroker.js-controller/io-package.json');\n\ninterface CLIPluginOptions extends CLICommandOptions {\n /** If plugin is scoped on adapter */\n adapter?: string;\n /** If plugin is scoped on instance */\n instance?: string;\n}\n\n/** Command iobroker plugin <enable/disable/status> <pluginname> [--host this/hostname] ... */\nexport class CLIPlugin extends CLICommand<CLIPluginOptions> {\n /** @param options the cli command options */\n constructor(options: CLIPluginOptions) {\n super(options);\n }\n\n /**\n * Executes a command\n *\n * @param args parsed cli args\n */\n execute(args: any[]): void {\n const { callback, showHelp } = this.options;\n const command = args[0];\n\n switch (command) {\n case 'on':\n case 'enable':\n return this.set(args, true);\n case 'off':\n case 'disable':\n return this.set(args, false);\n case 'status':\n return this.status(args);\n default:\n CLI.error.unknownCommand('plugin', command);\n showHelp();\n return void callback(3);\n }\n }\n\n /**\n * Enables or disables the given plugin\n *\n * @param args the parsed CLI args\n * @param enabled if plugin should be enabled\n */\n set(args: any[], enabled: boolean): void {\n const { callback, dbConnect } = this.options;\n const pluginName: string = args[1];\n if (!pluginName) {\n CLI.error.requiredArgumentMissing('pluginName', 'plugin enable <pluginname>');\n return void callback(34);\n }\n\n let hostname: string;\n let instance: string;\n\n if (this.options.adapter || this.options.instance) {\n instance = (this.options.adapter || this.options.instance) as string;\n // default to instance 0\n if (!/\\.\\d+$/.test(instance)) {\n instance += '.0';\n }\n } else {\n // Use host if no adapter was specified and fallback to the current one\n hostname = this.options.host;\n if (!hostname || hostname === 'this') {\n hostname = tools.getHostName();\n }\n }\n\n dbConnect(async params => {\n const { states, objects, config: iobrokerJson } = params;\n\n try {\n // Check if the host or instance exists\n let objectNamespace: string;\n if (hostname) {\n objectNamespace = `system.host.${hostname}`;\n const hostObject = await objects.getObject(objectNamespace);\n if (!hostObject) {\n CLI.error.hostDoesNotExist(hostname);\n return void callback(30);\n }\n } else {\n objectNamespace = `system.adapter.${instance}`;\n const instanceObject = await objects.getObject(objectNamespace);\n if (!instanceObject) {\n CLI.error.invalidInstance(instance);\n return void callback(30);\n }\n }\n\n // Check if the plugin is defined\n if (!pluginExists(pluginName, iobrokerJson, instance)) {\n CLI.error.pluginNotDefined(pluginName, hostname, instance);\n return void callback(30);\n }\n\n // Create the plugin state if it does not exist\n const pluginsFolderId = `${objectNamespace}.plugins`;\n if (!(await objects.getObjectAsync(pluginsFolderId))) {\n await objects.setObject(pluginsFolderId, {\n type: 'folder',\n common: {\n name: `${hostname ? 'host' : 'instance'}: plugin states`,\n },\n native: {},\n });\n }\n const pluginFolderId = `${objectNamespace}.plugins.${pluginName}`;\n if (!(await objects.getObjectAsync(pluginFolderId))) {\n await objects.setObject(pluginFolderId, {\n type: 'folder',\n common: {\n name: `${pluginName}: plugin states`,\n },\n native: {},\n });\n }\n const pluginEnabledId = `${pluginFolderId}.enabled`;\n if (!(await objects.getObjectAsync(pluginEnabledId))) {\n await objects.setObject(pluginEnabledId, {\n type: 'state',\n common: {\n name: 'Plugin enabled',\n type: 'boolean',\n read: true,\n write: true,\n role: 'value',\n },\n native: {},\n });\n }\n\n // Update the state\n await states.setStateAsync(pluginEnabledId, {\n val: enabled,\n from: getObjectFrom(),\n });\n\n // Notify the user that we are done\n CLI.success.pluginEnabledOrDisabled(pluginName, hostname, instance, enabled);\n return void callback();\n } catch (err) {\n CLI.error.unknown(err.message);\n return void callback(1);\n }\n });\n }\n\n /**\n * Prints the status of the given plugin\n *\n * @param args the parsed CLI arguments\n */\n status(args: any[]): void {\n const { callback, dbConnect } = this.options;\n const pluginName = args[1];\n if (!pluginName) {\n CLI.error.requiredArgumentMissing('pluginName', 'plugin status <pluginname>');\n return void callback(34);\n }\n\n let hostname: string;\n let instance: string;\n\n if (this.options.adapter || this.options.instance) {\n instance = (this.options.adapter || this.options.instance) as string;\n // default to instance 0\n if (!/\\.\\d+$/.test(instance)) {\n instance += '.0';\n }\n } else {\n // Use host if no adapter was specified and fallback to the current one\n hostname = this.options.host;\n if (!hostname || hostname === 'this') {\n hostname = tools.getHostName();\n }\n }\n\n dbConnect(async params => {\n const { states, objects, config: iobrokerJson } = params;\n\n try {\n // Check if the host or instance exists\n let objectNamespace: string;\n if (hostname) {\n objectNamespace = `system.host.${hostname}`;\n const hostObject = await objects.getObject(objectNamespace);\n if (!hostObject) {\n CLI.error.hostDoesNotExist(hostname);\n return void callback(30);\n }\n } else {\n objectNamespace = `system.adapter.${instance}`;\n const instanceObject = await objects.getObject(objectNamespace);\n if (!instanceObject) {\n CLI.error.invalidInstance(instance);\n return void callback(30);\n }\n }\n\n // Check if the plugin is defined\n if (!pluginExists(pluginName, iobrokerJson, instance)) {\n CLI.error.pluginNotDefined(pluginName, hostname, instance);\n return void callback(30);\n }\n\n const pluginEnabledId = `${objectNamespace}.plugins.${pluginName}.enabled`;\n\n // Read the state\n try {\n const val = (await states.getStateAsync(pluginEnabledId))?.val;\n\n if (typeof val === 'boolean') {\n CLI.success.pluginStatus(pluginName, hostname, instance, val);\n return void callback();\n }\n } catch {\n /* ignore */\n }\n\n // If the state could not be read or had no value, fall back to the configuration\n const enabled = pluginEnabled(\n pluginName,\n instance,\n await objects.getObjectAsync('system.config'),\n iobrokerJson,\n );\n CLI.success.pluginStatus(pluginName, hostname, instance, enabled);\n return void callback();\n } catch (err) {\n CLI.error.unknown(err.message);\n return void callback(1);\n }\n });\n }\n}\n\n/**\n * Checks if a plugin exists and can be configured\n *\n * @param pluginName The name of the plugin to check\n * @param iobrokerJson The contents of iobroker.json\n * @param [adapter] (optional) - If passed, the adapter configuration will be searched for defined plugins instead of js-controller\n */\nfunction pluginExists(pluginName: string, iobrokerJson?: ioBroker.IoBrokerJson, adapter?: string): boolean {\n // 1. check if the plugin is defined in io-package.json\n try {\n const ioPackPath = adapter ? path.join(tools.getAdapterDir(adapter)!, 'io-package.json') : controllerIoPackPath;\n const ioPack = fs.readJSONSync(ioPackPath, { encoding: 'utf8' });\n if (ioPack?.common?.plugins && pluginName in ioPack.common.plugins) {\n return true;\n }\n } catch {\n /* ignore */\n }\n\n // 2. check if the plugin is defined in iobroker.json\n return !!(iobrokerJson?.plugins && pluginName in iobrokerJson.plugins);\n}\n\n/**\n * Checks if a plugin exists and can be configured\n *\n * @param pluginName name of the plugin, e.g. `sentry`\n * @param adapter If defined, the adapter configuration will be searched for defined plugins instead of js-controller\n * @param systemConfig The system.config object\n * @param iobrokerJson The contents of iobroker.json\n */\nfunction pluginEnabled(\n pluginName: string,\n adapter?: string,\n systemConfig?: ioBroker.SystemConfigObject | null,\n iobrokerJson?: ioBroker.IoBrokerJson,\n): boolean {\n // 1. check if diagnostics are disabled in ioBroker\n if (systemConfig?.common?.diag === 'none') {\n return false;\n }\n\n // 2. check if the plugin is disabled in io-package.json\n try {\n const ioPackPath = adapter ? path.join(tools.getAdapterDir(adapter)!, 'io-package.json') : controllerIoPackPath;\n const ioPack = fs.readJSONSync(ioPackPath, { encoding: 'utf8' });\n if (\n ioPack?.common?.plugins &&\n pluginName in ioPack.common.plugins &&\n ioPack.common.plugins[pluginName].enabled === false\n ) {\n return false;\n }\n } catch {\n /* ignore */\n }\n\n // 3. check if the plugin is disabled in iobroker.json\n if (\n iobrokerJson?.plugins &&\n pluginName in iobrokerJson.plugins &&\n iobrokerJson.plugins[pluginName].enabled === false\n ) {\n return false;\n }\n\n // default: enabled\n return true;\n}\n", "export const __import_meta_url =\n typeof document === 'undefined' ? new (require('url'.replace('', '')).URL)('file:' + __filename).href :\n (document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href)\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;ACAO,IAAM,oBACX,OAAO,aAAa,cAAc,KAAK,QAAQ,MAAM,QAAQ,IAAI,EAAE,CAAC,GAAE,IAAK,UAAU,UAAU,EAAE,OAC9F,SAAS,iBAAiB,SAAS,cAAc,OAAO,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;ADFlG,UAAqB;AACrB,wBAAmD;AACnD,sBAA8B;AAC9B,kCAAsB;AACtB,sBAAe;AACf,uBAAiB;AACjB,yBAA8B;AAG9B,MAAMA,eAAU,kCAAc,qBAAmB,UAAU,UAAU,EAAE;AAEvE,MAAM,uBAAuBA,SAAQ,QAAQ,wCAAwC;AAU/E,MAAO,kBAAkB,6BAA4B;;EAEvD,YAAY,SAAyB;AACjC,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,IAAI,MAAM,IAAI;MAC9B,KAAK;MACL,KAAK;AACD,eAAO,KAAK,IAAI,MAAM,KAAK;MAC/B,KAAK;AACD,eAAO,KAAK,OAAO,IAAI;MAC3B;AACI,YAAI,MAAM,eAAe,UAAU,OAAO;AAC1C,iBAAQ;AACR,eAAO,KAAK,SAAS,CAAC;IAC9B;EACJ;;;;;;;EAQA,IAAI,MAAa,SAAgB;AAC7B,UAAM,EAAE,UAAU,UAAS,IAAK,KAAK;AACrC,UAAM,aAAqB,KAAK,CAAC;AACjC,Q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aAAa,YAAY,EAAE,UAAU,OAAM,CAAE;AAC/D,QAAI,QAAQ,QAAQ,WAAW,cAAc,OAAO,OAAO,SAAS;AAChE,aAAO;IACX;EACJ,QAAQ;EAER;AAGA,SAAO,CAAC,EAAE,cAAc,WAAW,cAAc,aAAa;AAClE;AAUA,SAAS,cACL,YACA,SACA,cACA,cAAoC;AAGpC,MAAI,cAAc,QAAQ,SAAS,QAAQ;AACvC,WAAO;EACX;AAGA,MAAI;AACA,UAAM,aAAa,UAAU,iBAAAD,QAAK,KAAK,kCAAM,cAAc,OAAO,GAAI,iBAAiB,IAAI;AAC3F,UAAM,SAAS,gBAAAC,QAAG,aAAa,YAAY,EAAE,UAAU,OAAM,CAAE;AAC/D,QACI,QAAQ,QAAQ,WAChB,cAAc,OAAO,OAAO,WAC5B,OAAO,OAAO,QAAQ,UAAU,EAAE,YAAY,OAChD;AACE,aAAO;IACX;EACJ,QAAQ;EAER;AAGA,MACI,cAAc,WACd,cAAc,aAAa,WAC3B,aAAa,QAAQ,UAAU,EAAE,YAAY,OAC/C;AACE,WAAO;EACX;AAGA,SAAO;AACX;",
|
|
6
6
|
"names": ["require", "path", "fs"]
|
|
7
7
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { CLICommand } from '../../lib/cli/cliCommand.js';
|
|
2
2
|
import type { CLICommandOptions } from '../../lib/cli/cliCommand.js';
|
|
3
|
+
/** Command ioBroker process control (start/stop/restart/status) ... */
|
|
3
4
|
export declare class CLIProcess extends CLICommand {
|
|
5
|
+
/**
|
|
6
|
+
* @param options The command options including context and parameters
|
|
7
|
+
*/
|
|
4
8
|
constructor(options: CLICommandOptions);
|
|
5
9
|
/**
|
|
6
10
|
* Starts one or more adapters or the js-controller
|
|
@@ -46,6 +46,9 @@ const TRY_KILL_WAIT_MS = 5e3;
|
|
|
46
46
|
const rootDir = import_js_controller_common2.tools.getControllerDir();
|
|
47
47
|
const killAllScriptPath = import_node_path.default.join(rootDir, "killall.sh");
|
|
48
48
|
class CLIProcess extends import_cliCommand.CLICommand {
|
|
49
|
+
/**
|
|
50
|
+
* @param options The command options including context and parameters
|
|
51
|
+
*/
|
|
49
52
|
constructor(options) {
|
|
50
53
|
super(options);
|
|
51
54
|
}
|