@iobroker/js-controller-cli 7.2.3-alpha.9-20260711-3ea5f3c89 → 7.2.4

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