@iobroker/js-controller-cli 7.2.3 → 8.0.0-alpha.1-20260921-e5941ca8a

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 (225) hide show
  1. package/build/cjs/index.js +3 -3
  2. package/build/cjs/lib/_Types.d.ts +8 -1
  3. package/build/cjs/lib/cli/cliCert.d.ts +7 -4
  4. package/build/cjs/lib/cli/cliCert.js +10 -6
  5. package/build/cjs/lib/cli/cliCert.js.map +2 -2
  6. package/build/cjs/lib/cli/cliCommand.d.ts +63 -15
  7. package/build/cjs/lib/cli/cliCommand.js +8 -1
  8. package/build/cjs/lib/cli/cliCommand.js.map +2 -2
  9. package/build/cjs/lib/cli/cliCompact.d.ts +5 -2
  10. package/build/cjs/lib/cli/cliCompact.js +9 -2
  11. package/build/cjs/lib/cli/cliCompact.js.map +2 -2
  12. package/build/cjs/lib/cli/cliDebug.d.ts +5 -2
  13. package/build/cjs/lib/cli/cliDebug.js +8 -1
  14. package/build/cjs/lib/cli/cliDebug.js.map +2 -2
  15. package/build/cjs/lib/cli/cliHost.d.ts +13 -10
  16. package/build/cjs/lib/cli/cliHost.js +13 -5
  17. package/build/cjs/lib/cli/cliHost.js.map +2 -2
  18. package/build/cjs/lib/cli/cliLogs.d.ts +9 -3
  19. package/build/cjs/lib/cli/cliLogs.js +12 -1
  20. package/build/cjs/lib/cli/cliLogs.js.map +2 -2
  21. package/build/cjs/lib/cli/cliMessage.d.ts +2 -1
  22. package/build/cjs/lib/cli/cliMessage.js +5 -0
  23. package/build/cjs/lib/cli/cliMessage.js.map +2 -2
  24. package/build/cjs/lib/cli/cliObjects.d.ts +21 -18
  25. package/build/cjs/lib/cli/cliObjects.js +51 -33
  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 +6 -0
  29. package/build/cjs/lib/cli/cliPlugin.js.map +2 -2
  30. package/build/cjs/lib/cli/cliProcess.d.ts +17 -7
  31. package/build/cjs/lib/cli/cliProcess.js +77 -24
  32. package/build/cjs/lib/cli/cliProcess.js.map +3 -3
  33. package/build/cjs/lib/cli/cliStates.d.ts +7 -4
  34. package/build/cjs/lib/cli/cliStates.js +14 -6
  35. package/build/cjs/lib/cli/cliStates.js.map +2 -2
  36. package/build/cjs/lib/cli/cliTools.js +11 -0
  37. package/build/cjs/lib/cli/cliTools.js.map +1 -1
  38. package/build/cjs/lib/cli/messages.js +47 -46
  39. package/build/cjs/lib/cli/messages.js.map +1 -1
  40. package/build/cjs/lib/progressBar.d.ts +59 -0
  41. package/build/cjs/lib/progressBar.js +115 -0
  42. package/build/cjs/lib/progressBar.js.map +7 -0
  43. package/build/cjs/lib/setup/customError.d.ts +4 -0
  44. package/build/cjs/lib/setup/customError.js +7 -0
  45. package/build/cjs/lib/setup/customError.js.map +2 -2
  46. package/build/cjs/lib/setup/dbConnection.js +69 -64
  47. package/build/cjs/lib/setup/dbConnection.js.map +3 -3
  48. package/build/cjs/lib/setup/formatters.d.ts +4 -4
  49. package/build/cjs/lib/setup/formatters.js +5 -0
  50. package/build/cjs/lib/setup/formatters.js.map +2 -2
  51. package/build/cjs/lib/setup/multihostClient.js +6 -2
  52. package/build/cjs/lib/setup/multihostClient.js.map +1 -1
  53. package/build/cjs/lib/setup/pluginInfos.d.ts +5 -0
  54. package/build/cjs/lib/setup/pluginInfos.js +2 -0
  55. package/build/cjs/lib/setup/pluginInfos.js.map +2 -2
  56. package/build/cjs/lib/setup/setupBackup.d.ts +53 -0
  57. package/build/cjs/lib/setup/setupBackup.js +125 -14
  58. package/build/cjs/lib/setup/setupBackup.js.map +3 -3
  59. package/build/cjs/lib/setup/setupInstall.d.ts +51 -15
  60. package/build/cjs/lib/setup/setupInstall.js +212 -28
  61. package/build/cjs/lib/setup/setupInstall.js.map +2 -2
  62. package/build/cjs/lib/setup/setupLicense.d.ts +13 -0
  63. package/build/cjs/lib/setup/setupLicense.js +33 -2
  64. package/build/cjs/lib/setup/setupLicense.js.map +2 -2
  65. package/build/cjs/lib/setup/setupList.d.ts +55 -1
  66. package/build/cjs/lib/setup/setupList.js +78 -24
  67. package/build/cjs/lib/setup/setupList.js.map +3 -3
  68. package/build/cjs/lib/setup/setupMultihost.d.ts +7 -0
  69. package/build/cjs/lib/setup/setupMultihost.js +78 -11
  70. package/build/cjs/lib/setup/setupMultihost.js.map +3 -3
  71. package/build/cjs/lib/setup/setupPacketManager.d.ts +10 -0
  72. package/build/cjs/lib/setup/setupPacketManager.js +16 -6
  73. package/build/cjs/lib/setup/setupPacketManager.js.map +2 -2
  74. package/build/cjs/lib/setup/setupRepo.d.ts +19 -0
  75. package/build/cjs/lib/setup/setupRepo.js +141 -13
  76. package/build/cjs/lib/setup/setupRepo.js.map +2 -2
  77. package/build/cjs/lib/setup/setupSetup.d.ts +34 -0
  78. package/build/cjs/lib/setup/setupSetup.js +209 -35
  79. package/build/cjs/lib/setup/setupSetup.js.map +3 -3
  80. package/build/cjs/lib/setup/setupUpgrade.d.ts +13 -2
  81. package/build/cjs/lib/setup/setupUpgrade.js +72 -12
  82. package/build/cjs/lib/setup/setupUpgrade.js.map +2 -2
  83. package/build/cjs/lib/setup/setupUpload.d.ts +77 -1
  84. package/build/cjs/lib/setup/setupUpload.js +152 -9
  85. package/build/cjs/lib/setup/setupUpload.js.map +2 -2
  86. package/build/cjs/lib/setup/setupUsers.d.ts +44 -14
  87. package/build/cjs/lib/setup/setupUsers.js +330 -17
  88. package/build/cjs/lib/setup/setupUsers.js.map +2 -2
  89. package/build/cjs/lib/setup/setupVendor.d.ts +14 -1
  90. package/build/cjs/lib/setup/setupVendor.js +40 -8
  91. package/build/cjs/lib/setup/setupVendor.js.map +2 -2
  92. package/build/cjs/lib/setup/setupVisDebug.d.ts +16 -2
  93. package/build/cjs/lib/setup/setupVisDebug.js +41 -17
  94. package/build/cjs/lib/setup/setupVisDebug.js.map +3 -3
  95. package/build/cjs/lib/setup/utils.d.ts +1 -1
  96. package/build/cjs/lib/setup/utils.js +13 -9
  97. package/build/cjs/lib/setup/utils.js.map +3 -3
  98. package/build/cjs/lib/setup.d.ts +1 -1
  99. package/build/cjs/lib/setup.js +858 -1758
  100. package/build/cjs/lib/setup.js.map +3 -3
  101. package/build/esm/lib/_Types.d.ts +8 -1
  102. package/build/esm/lib/_Types.d.ts.map +1 -1
  103. package/build/esm/lib/cli/cliCert.d.ts +7 -4
  104. package/build/esm/lib/cli/cliCert.d.ts.map +1 -1
  105. package/build/esm/lib/cli/cliCert.js +6 -6
  106. package/build/esm/lib/cli/cliCert.js.map +1 -1
  107. package/build/esm/lib/cli/cliCommand.d.ts +63 -15
  108. package/build/esm/lib/cli/cliCommand.d.ts.map +1 -1
  109. package/build/esm/lib/cli/cliCommand.js +4 -1
  110. package/build/esm/lib/cli/cliCommand.js.map +1 -1
  111. package/build/esm/lib/cli/cliCompact.d.ts +5 -2
  112. package/build/esm/lib/cli/cliCompact.d.ts.map +1 -1
  113. package/build/esm/lib/cli/cliCompact.js +5 -2
  114. package/build/esm/lib/cli/cliCompact.js.map +1 -1
  115. package/build/esm/lib/cli/cliDebug.d.ts +5 -2
  116. package/build/esm/lib/cli/cliDebug.d.ts.map +1 -1
  117. package/build/esm/lib/cli/cliDebug.js +4 -1
  118. package/build/esm/lib/cli/cliDebug.js.map +1 -1
  119. package/build/esm/lib/cli/cliHost.d.ts +13 -10
  120. package/build/esm/lib/cli/cliHost.d.ts.map +1 -1
  121. package/build/esm/lib/cli/cliHost.js +8 -5
  122. package/build/esm/lib/cli/cliHost.js.map +1 -1
  123. package/build/esm/lib/cli/cliLogs.d.ts +9 -3
  124. package/build/esm/lib/cli/cliLogs.d.ts.map +1 -1
  125. package/build/esm/lib/cli/cliLogs.js +8 -1
  126. package/build/esm/lib/cli/cliLogs.js.map +1 -1
  127. package/build/esm/lib/cli/cliMessage.d.ts +2 -1
  128. package/build/esm/lib/cli/cliMessage.d.ts.map +1 -1
  129. package/build/esm/lib/cli/cliMessage.js +1 -0
  130. package/build/esm/lib/cli/cliMessage.js.map +1 -1
  131. package/build/esm/lib/cli/cliObjects.d.ts +21 -18
  132. package/build/esm/lib/cli/cliObjects.d.ts.map +1 -1
  133. package/build/esm/lib/cli/cliObjects.js +44 -38
  134. package/build/esm/lib/cli/cliObjects.js.map +1 -1
  135. package/build/esm/lib/cli/cliPlugin.d.ts +3 -3
  136. package/build/esm/lib/cli/cliPlugin.d.ts.map +1 -1
  137. package/build/esm/lib/cli/cliPlugin.js +1 -1
  138. package/build/esm/lib/cli/cliPlugin.js.map +1 -1
  139. package/build/esm/lib/cli/cliProcess.d.ts +17 -7
  140. package/build/esm/lib/cli/cliProcess.d.ts.map +1 -1
  141. package/build/esm/lib/cli/cliProcess.js +73 -12
  142. package/build/esm/lib/cli/cliProcess.js.map +1 -1
  143. package/build/esm/lib/cli/cliStates.d.ts +7 -4
  144. package/build/esm/lib/cli/cliStates.d.ts.map +1 -1
  145. package/build/esm/lib/cli/cliStates.js +6 -2
  146. package/build/esm/lib/cli/cliStates.js.map +1 -1
  147. package/build/esm/lib/progressBar.d.ts +59 -0
  148. package/build/esm/lib/progressBar.d.ts.map +1 -0
  149. package/build/esm/lib/progressBar.js +104 -0
  150. package/build/esm/lib/progressBar.js.map +1 -0
  151. package/build/esm/lib/setup/customError.d.ts +4 -0
  152. package/build/esm/lib/setup/customError.d.ts.map +1 -1
  153. package/build/esm/lib/setup/customError.js +3 -0
  154. package/build/esm/lib/setup/customError.js.map +1 -1
  155. package/build/esm/lib/setup/dbConnection.d.ts.map +1 -1
  156. package/build/esm/lib/setup/dbConnection.js +10 -13
  157. package/build/esm/lib/setup/dbConnection.js.map +1 -1
  158. package/build/esm/lib/setup/formatters.d.ts +4 -4
  159. package/build/esm/lib/setup/formatters.js +4 -4
  160. package/build/esm/lib/setup/pluginInfos.d.ts +5 -0
  161. package/build/esm/lib/setup/pluginInfos.d.ts.map +1 -1
  162. package/build/esm/lib/setup/pluginInfos.js +5 -0
  163. package/build/esm/lib/setup/pluginInfos.js.map +1 -1
  164. package/build/esm/lib/setup/setupBackup.d.ts +53 -0
  165. package/build/esm/lib/setup/setupBackup.d.ts.map +1 -1
  166. package/build/esm/lib/setup/setupBackup.js +132 -13
  167. package/build/esm/lib/setup/setupBackup.js.map +1 -1
  168. package/build/esm/lib/setup/setupInstall.d.ts +51 -15
  169. package/build/esm/lib/setup/setupInstall.d.ts.map +1 -1
  170. package/build/esm/lib/setup/setupInstall.js +228 -23
  171. package/build/esm/lib/setup/setupInstall.js.map +1 -1
  172. package/build/esm/lib/setup/setupLicense.d.ts +13 -0
  173. package/build/esm/lib/setup/setupLicense.d.ts.map +1 -1
  174. package/build/esm/lib/setup/setupLicense.js +31 -1
  175. package/build/esm/lib/setup/setupLicense.js.map +1 -1
  176. package/build/esm/lib/setup/setupList.d.ts +55 -1
  177. package/build/esm/lib/setup/setupList.d.ts.map +1 -1
  178. package/build/esm/lib/setup/setupList.js +61 -8
  179. package/build/esm/lib/setup/setupList.js.map +1 -1
  180. package/build/esm/lib/setup/setupMultihost.d.ts +7 -0
  181. package/build/esm/lib/setup/setupMultihost.d.ts.map +1 -1
  182. package/build/esm/lib/setup/setupMultihost.js +85 -6
  183. package/build/esm/lib/setup/setupMultihost.js.map +1 -1
  184. package/build/esm/lib/setup/setupPacketManager.d.ts +10 -0
  185. package/build/esm/lib/setup/setupPacketManager.d.ts.map +1 -1
  186. package/build/esm/lib/setup/setupPacketManager.js +9 -0
  187. package/build/esm/lib/setup/setupPacketManager.js.map +1 -1
  188. package/build/esm/lib/setup/setupRepo.d.ts +19 -0
  189. package/build/esm/lib/setup/setupRepo.d.ts.map +1 -1
  190. package/build/esm/lib/setup/setupRepo.js +164 -14
  191. package/build/esm/lib/setup/setupRepo.js.map +1 -1
  192. package/build/esm/lib/setup/setupSetup.d.ts +34 -0
  193. package/build/esm/lib/setup/setupSetup.d.ts.map +1 -1
  194. package/build/esm/lib/setup/setupSetup.js +218 -21
  195. package/build/esm/lib/setup/setupSetup.js.map +1 -1
  196. package/build/esm/lib/setup/setupUpgrade.d.ts +13 -2
  197. package/build/esm/lib/setup/setupUpgrade.d.ts.map +1 -1
  198. package/build/esm/lib/setup/setupUpgrade.js +70 -6
  199. package/build/esm/lib/setup/setupUpgrade.js.map +1 -1
  200. package/build/esm/lib/setup/setupUpload.d.ts +77 -1
  201. package/build/esm/lib/setup/setupUpload.d.ts.map +1 -1
  202. package/build/esm/lib/setup/setupUpload.js +164 -7
  203. package/build/esm/lib/setup/setupUpload.js.map +1 -1
  204. package/build/esm/lib/setup/setupUsers.d.ts +44 -14
  205. package/build/esm/lib/setup/setupUsers.d.ts.map +1 -1
  206. package/build/esm/lib/setup/setupUsers.js +346 -14
  207. package/build/esm/lib/setup/setupUsers.js.map +1 -1
  208. package/build/esm/lib/setup/setupVendor.d.ts +14 -1
  209. package/build/esm/lib/setup/setupVendor.d.ts.map +1 -1
  210. package/build/esm/lib/setup/setupVendor.js +33 -2
  211. package/build/esm/lib/setup/setupVendor.js.map +1 -1
  212. package/build/esm/lib/setup/setupVisDebug.d.ts +16 -2
  213. package/build/esm/lib/setup/setupVisDebug.d.ts.map +1 -1
  214. package/build/esm/lib/setup/setupVisDebug.js +39 -14
  215. package/build/esm/lib/setup/setupVisDebug.js.map +1 -1
  216. package/build/esm/lib/setup/utils.d.ts +1 -1
  217. package/build/esm/lib/setup/utils.d.ts.map +1 -1
  218. package/build/esm/lib/setup/utils.js +2 -4
  219. package/build/esm/lib/setup/utils.js.map +1 -1
  220. package/build/esm/lib/setup.d.ts +1 -1
  221. package/build/esm/lib/setup.d.ts.map +1 -1
  222. package/build/esm/lib/setup.js +959 -1910
  223. package/build/esm/lib/setup.js.map +1 -1
  224. package/build/tsconfig.build.tsbuildinfo +1 -1
  225. package/package.json +14 -14
@@ -1,11 +1,18 @@
1
1
  import type { CleanDatabaseHandler, IoPackage, ProcessExitCallback, RestartController } from '../../lib/_Types.js';
2
+ import type { ProcessCommandOptions } from '../../lib/cli/cliCommand.js';
2
3
  import { EXIT_CODES } from '@iobroker/js-controller-common';
4
+ /** Options for the setup command */
3
5
  export interface CLISetupOptions {
6
+ /** Handler to clean the database */
4
7
  cleanDatabase: CleanDatabaseHandler;
8
+ /** Callback to exit the process with an exit code */
5
9
  processExit: ProcessExitCallback;
10
+ /** Parsed CLI parameters */
6
11
  params: Record<string, any>;
12
+ /** Handler to restart the controller */
7
13
  restartController: RestartController;
8
14
  }
15
+ /** Options for running the setup command */
9
16
  export interface SetupCommandOptions {
10
17
  /** Callback called afterward */
11
18
  callback: (isCreated?: boolean) => void;
@@ -14,6 +21,9 @@ export interface SetupCommandOptions {
14
21
  /** If redis should be setup */
15
22
  useRedis: boolean;
16
23
  }
24
+ /**
25
+ * CLI command that performs the initial ioBroker setup (databases, config and objects)
26
+ */
17
27
  export declare class Setup {
18
28
  /** Object IDs which are not allowed to exist but could be generated due to errors in the past */
19
29
  private readonly KNOWN_GARBAGE_OBJECT_IDS;
@@ -25,7 +35,15 @@ export declare class Setup {
25
35
  private readonly params;
26
36
  private readonly cleanDatabase;
27
37
  private readonly restartController;
38
+ /**
39
+ * @param options Handlers for cleaning the DB, exiting and restarting, plus the CLI parameters
40
+ */
28
41
  constructor(options: CLISetupOptions);
42
+ /**
43
+ * Print information about the plugins configured for the controller
44
+ *
45
+ * @param systemConfig The system.config object, used to read the active repository
46
+ */
29
47
  informAboutPlugins(systemConfig?: ioBroker.SystemConfigObject | null): Promise<void>;
30
48
  /**
31
49
  * Called after io-package objects are created (hence object view functionalities are now available)
@@ -34,6 +52,13 @@ export declare class Setup {
34
52
  * @param callback callback function
35
53
  */
36
54
  setupReady(systemConfig: ioBroker.SystemConfigObject | undefined | null, callback: () => void): Promise<void>;
55
+ /**
56
+ * Create the initial set of objects and design documents in the database
57
+ *
58
+ * @param iopkg The io-package.json of the controller
59
+ * @param ignoreExisting Whether to proceed even if the config already exists
60
+ * @param callback Called once the database has been set up
61
+ */
37
62
  dbSetup(iopkg: IoPackage, ignoreExisting: boolean, callback: () => void): Promise<void>;
38
63
  /**
39
64
  * Fix the config object if existing
@@ -55,6 +80,9 @@ export declare class Setup {
55
80
  * @param oldConfig - previous config
56
81
  */
57
82
  migrateObjects(newConfig: ioBroker.IoBrokerJson, oldConfig: ioBroker.IoBrokerJson): Promise<EXIT_CODES>;
83
+ /**
84
+ * Interactively configure the databases and write the configuration file
85
+ */
58
86
  setupCustom(): Promise<EXIT_CODES>;
59
87
  /**
60
88
  * Checks if single host setup and if so migrates and activates Redis Sets Usage
@@ -107,4 +135,10 @@ export declare class Setup {
107
135
  */
108
136
  setup(options: SetupCommandOptions): void;
109
137
  }
138
+ /**
139
+ * Process the `setup` command
140
+ *
141
+ * @param options the command options
142
+ */
143
+ export declare function processCommandSetup(options: ProcessCommandOptions): Promise<void>;
110
144
  //# sourceMappingURL=setupSetup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setupSetup.d.ts","sourceRoot":"","sources":["../../../../src/lib/setup/setupSetup.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAI/G,OAAO,EAAE,UAAU,EAAS,MAAM,gCAAgC,CAAC;AAiCnE,MAAM,WAAW,eAAe;IAC5B,aAAa,EAAE,oBAAoB,CAAC;IACpC,WAAW,EAAE,mBAAmB,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,iBAAiB,EAAE,iBAAiB,CAAC;CACxC;AAED,MAAM,WAAW,mBAAmB;IAChC,gCAAgC;IAChC,QAAQ,EAAE,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,0FAA0F;IAC1F,aAAa,EAAE,OAAO,CAAC;IACvB,+BAA+B;IAC/B,QAAQ,EAAE,OAAO,CAAC;CACrB;AAED,qBAAa,KAAK;IACd,iGAAiG;IACjG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C;;OAEG;YACW,wBAAwB;IA2CtC;;OAEG;YACW,oBAAoB;IAgClC;;OAEG;YACW,sBAAsB;IAepC;;OAEG;YACW,oBAAoB;IA0ClC;;OAEG;YACW,+BAA+B;IAuC7C;;;;OAIG;IACH,KAAK,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI;CA4J5C;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkMvF"}
@@ -1,27 +1,29 @@
1
1
  /**
2
2
  * Setup
3
3
  *
4
- * Copyright 2013-2024 bluefox <dogafox@gmail.com>
4
+ * Copyright 2013-2026 bluefox <dogafox@gmail.com>
5
5
  *
6
6
  * MIT License
7
7
  *
8
8
  */
9
9
  import fs from 'fs-extra';
10
10
  import path from 'node:path';
11
- import { EXIT_CODES, tools } from '@iobroker/js-controller-common';
12
- import { statesDbHasServer, isLocalStatesDbServer, isLocalObjectsDbServer, objectsDbHasServer, performObjectsInterview, performStatesInterview, } from '@iobroker/js-controller-common';
13
- import { resetDbConnect, dbConnectAsync } from '../../lib/setup/dbConnection.js';
14
- import { BackupRestore } from '../../lib/setup/setupBackup.js';
11
+ import os from 'node:os';
15
12
  import crypto from 'node:crypto';
16
13
  import deepClone from 'deep-clone';
17
- import * as pluginInfos from '../../lib/setup/pluginInfos.js';
14
+ import * as url from 'node:url';
15
+ import { createRequire } from 'node:module';
16
+ import { isDeepStrictEqual } from 'node:util';
18
17
  import rl from 'readline-sync';
18
+ import { CLICert } from '../../lib/cli/cliCert.js';
19
+ import { statesDbHasServer, isLocalStatesDbServer, isLocalObjectsDbServer, objectsDbHasServer, performObjectsInterview, performStatesInterview, EXIT_CODES, tools, } from '@iobroker/js-controller-common';
19
20
  import { FORBIDDEN_CHARS, getHostObject } from '@iobroker/js-controller-common-db/tools';
20
- import os from 'node:os';
21
21
  import { SYSTEM_ADAPTER_PREFIX, SYSTEM_HOST_PREFIX } from '@iobroker/js-controller-common-db/constants';
22
+ import { resetDbConnect, dbConnectAsync } from '../../lib/setup/dbConnection.js';
23
+ import { BETA_REPO_URL, STABLE_REPO_URL } from '../../lib/setup/utils.js';
24
+ import { BackupRestore } from '../../lib/setup/setupBackup.js';
25
+ import * as pluginInfos from '../../lib/setup/pluginInfos.js';
22
26
  import { Upload } from '../../lib/setup/setupUpload.js';
23
- import { createRequire } from 'node:module';
24
- import * as url from 'node:url';
25
27
  // eslint-disable-next-line unicorn/prefer-module
26
28
  const thisDir = url.fileURLToPath(new URL('.', import.meta.url || `file://${__filename}`));
27
29
  // eslint-disable-next-line unicorn/prefer-module
@@ -31,6 +33,9 @@ const COLOR_YELLOW = '\x1b[33m';
31
33
  const COLOR_RESET = '\x1b[0m';
32
34
  const COLOR_GREEN = '\x1b[32m';
33
35
  const CONTROLLER_DIR = tools.getControllerDir();
36
+ /**
37
+ * CLI command that performs the initial ioBroker setup (databases, config and objects)
38
+ */
34
39
  export class Setup {
35
40
  /** Object IDs which are not allowed to exist but could be generated due to errors in the past */
36
41
  KNOWN_GARBAGE_OBJECT_IDS = ['null', 'undefined'];
@@ -42,6 +47,9 @@ export class Setup {
42
47
  params;
43
48
  cleanDatabase;
44
49
  restartController;
50
+ /**
51
+ * @param options Handlers for cleaning the DB, exiting and restarting, plus the CLI parameters
52
+ */
45
53
  constructor(options) {
46
54
  this.processExit = options.processExit;
47
55
  this.params = options.params;
@@ -49,6 +57,11 @@ export class Setup {
49
57
  this.restartController = options.restartController;
50
58
  this.dbSetup = this.dbSetup.bind(this);
51
59
  }
60
+ /**
61
+ * Print information about the plugins configured for the controller
62
+ *
63
+ * @param systemConfig The system.config object, used to read the active repository
64
+ */
52
65
  async informAboutPlugins(systemConfig) {
53
66
  if (!this.states) {
54
67
  throw new Error('States not set up, call setupObjects first');
@@ -202,6 +215,13 @@ Please DO NOT copy files manually into ioBroker storage directories!`);
202
215
  return void callback();
203
216
  }
204
217
  }
218
+ /**
219
+ * Create the initial set of objects and design documents in the database
220
+ *
221
+ * @param iopkg The io-package.json of the controller
222
+ * @param ignoreExisting Whether to proceed even if the config already exists
223
+ * @param callback Called once the database has been set up
224
+ */
205
225
  async dbSetup(iopkg, ignoreExisting, callback) {
206
226
  if (!this.objects) {
207
227
  throw new Error('Objects not set up, call setupObjects first');
@@ -341,19 +361,14 @@ Please DO NOT copy files manually into ioBroker storage directories!`);
341
361
  catch {
342
362
  //ignore
343
363
  }
344
- this.dbSetup(iopkg, true, callback);
345
- return;
364
+ return this.dbSetup(iopkg, true, callback);
346
365
  }
347
366
  }
348
- this.dbSetup(iopkg, true, callback);
349
- }
350
- else {
351
- this.dbSetup(iopkg, true, callback);
367
+ return this.dbSetup(iopkg, true, callback);
352
368
  }
369
+ return this.dbSetup(iopkg, true, callback);
353
370
  }
354
- else {
355
- this.dbSetup(iopkg, false, callback);
356
- }
371
+ return this.dbSetup(iopkg, false, callback);
357
372
  }
358
373
  /**
359
374
  * Asks the user if he wants to migrate objects if it makes sense and performs migration according to input
@@ -559,6 +574,9 @@ Please DO NOT copy files manually into ioBroker storage directories!`);
559
574
  fs.writeFileSync(tools.getConfigFileName(), JSON.stringify(newConfig, null, 2));
560
575
  return EXIT_CODES.NO_ERROR;
561
576
  }
577
+ /**
578
+ * Interactively configure the databases and write the configuration file
579
+ */
562
580
  async setupCustom() {
563
581
  let config;
564
582
  // read actual configuration
@@ -982,7 +1000,7 @@ Please DO NOT copy files manually into ioBroker storage directories!`);
982
1000
  * Replace the `controller.js` file in the root directory to work with ESM
983
1001
  */
984
1002
  async _fixWindowsControllerJs() {
985
- const content = `import('./node_modules/iobroker.js-controller/controller.js');`;
1003
+ const content = `import('./node_modules/iobroker.js-controller/controller.js');\n`;
986
1004
  const filePath = path.join(tools.getRootDir(), 'controller.js');
987
1005
  try {
988
1006
  await fs.writeFile(filePath, content, { encoding: 'utf-8' });
@@ -1311,10 +1329,189 @@ require('${path.normalize(`${thisDir}/..`)}/setup').execute();`;
1311
1329
  }
1312
1330
  else if (ignoreIfExist) {
1313
1331
  // it is a setup first run and config exists yet
1314
- this.setupObjects(() => callback?.(), true);
1332
+ this.setupObjects(() => callback?.(), true).catch(e => console.error(`Cannot setup objects: ${e.message}`));
1315
1333
  return;
1316
1334
  }
1317
- this.setupObjects(() => callback?.(isCreated));
1335
+ this.setupObjects(() => callback?.(isCreated)).catch(e => console.error(`Cannot setup objects: ${e.message}`));
1318
1336
  }
1319
1337
  }
1338
+ /**
1339
+ * Process the `setup` command
1340
+ *
1341
+ * @param options the command options
1342
+ */
1343
+ export async function processCommandSetup(options) {
1344
+ const { args, params, callback, commandOptions, cleanDatabase, restartController } = options;
1345
+ const setup = new Setup({
1346
+ processExit: callback,
1347
+ cleanDatabase,
1348
+ restartController,
1349
+ params,
1350
+ });
1351
+ if (args[0] === 'custom' || params.custom) {
1352
+ const exitCode = await setup.setupCustom();
1353
+ callback(exitCode);
1354
+ return;
1355
+ }
1356
+ let isFirst = false;
1357
+ let isRedis = false;
1358
+ // we support "first" and "redis" without "--" flag
1359
+ for (const arg of args) {
1360
+ if (arg === 'first') {
1361
+ isFirst = true;
1362
+ }
1363
+ else if (arg === 'redis') {
1364
+ isRedis = true;
1365
+ }
1366
+ }
1367
+ // and as --flag
1368
+ isRedis = params.redis || isRedis;
1369
+ isFirst = params.first || isFirst;
1370
+ setup.setup({
1371
+ callback: async () => {
1372
+ const { states, objects } = await dbConnectAsync(false, params);
1373
+ if (isFirst) {
1374
+ // Creates all instances that are needed on a fresh installation
1375
+ const { Install } = await import('../../lib/setup/setupInstall.js');
1376
+ const install = new Install({
1377
+ objects,
1378
+ states,
1379
+ processExit: callback,
1380
+ params,
1381
+ });
1382
+ // Define the necessary instances
1383
+ const initialInstances = ['admin', 'discovery', 'backitup'];
1384
+ // And try to install each of them
1385
+ for (const instance of initialInstances) {
1386
+ try {
1387
+ const adapterInstalled = !!require.resolve(`${tools.appName.toLowerCase()}.${instance}`);
1388
+ if (adapterInstalled) {
1389
+ let otherInstanceExists = false;
1390
+ try {
1391
+ // check if another instance exists
1392
+ const res = await objects.getObjectViewAsync('system', 'instance', {
1393
+ startkey: `system.adapter.${instance}`,
1394
+ endkey: `system.adapter.${instance}\u9999`,
1395
+ });
1396
+ otherInstanceExists = !!res.rows.length;
1397
+ }
1398
+ catch {
1399
+ // ignore - on install we have no object views
1400
+ }
1401
+ if (!otherInstanceExists) {
1402
+ await install.createInstance(instance, {
1403
+ enabled: true,
1404
+ ignoreIfExists: true,
1405
+ });
1406
+ }
1407
+ }
1408
+ }
1409
+ catch {
1410
+ // not found, just continue
1411
+ }
1412
+ }
1413
+ await new Promise(resolve => {
1414
+ // Creates a fresh certificate
1415
+ // Create a new instance of the cert command,
1416
+ // but use the resolve method as a callback
1417
+ const cert = new CLICert({ ...commandOptions, callback: resolve });
1418
+ cert.create().catch(e => console.error(`Cannot create certificate: ${e.message}`));
1419
+ });
1420
+ }
1421
+ // we update existing things, in first as well as normal setup
1422
+ // Rename repositories
1423
+ const { Repo } = await import('../../lib/setup/setupRepo.js');
1424
+ const repo = new Repo({ objects, states });
1425
+ try {
1426
+ await repo.rename('default', 'stable', STABLE_REPO_URL);
1427
+ await repo.rename('latest', 'beta', BETA_REPO_URL);
1428
+ }
1429
+ catch (err) {
1430
+ console.warn(`Cannot rename: ${err.message}`);
1431
+ }
1432
+ // there has been a bug that user can upload js-controller
1433
+ try {
1434
+ await objects.delObjectAsync('system.adapter.js-controller');
1435
+ }
1436
+ catch {
1437
+ // ignore
1438
+ }
1439
+ try {
1440
+ const configFile = tools.getConfigFileName();
1441
+ const configOrig = fs.readJSONSync(configFile);
1442
+ const config = deepClone(configOrig);
1443
+ config.objects.options = config.objects.options || {
1444
+ auth_pass: null,
1445
+ retry_max_delay: 5_000,
1446
+ };
1447
+ if (config.objects.options.retry_max_delay === 15_000 || !config.objects.options.retry_max_delay) {
1448
+ config.objects.options.retry_max_delay = 5_000;
1449
+ }
1450
+ config.states.options = config.states.options || {
1451
+ auth_pass: null,
1452
+ retry_max_delay: 5_000,
1453
+ };
1454
+ if (config.states.options.retry_max_delay === 15_000 || !config.states.options.retry_max_delay) {
1455
+ config.states.options.retry_max_delay = 5_000;
1456
+ }
1457
+ let migrated = '';
1458
+ // We migrate file to jsonl
1459
+ if (config.states.type === 'file') {
1460
+ config.states.type = 'jsonl';
1461
+ const hasLocalStatesServer = await isLocalStatesDbServer('file', config.states.host);
1462
+ if (hasLocalStatesServer) {
1463
+ // silent config change on secondaries
1464
+ console.log('States DB type migrated from "file" to "jsonl"');
1465
+ migrated += 'States';
1466
+ }
1467
+ }
1468
+ if (config.objects.type === 'file') {
1469
+ config.objects.type = 'jsonl';
1470
+ const hasLocalObjectsServer = await isLocalObjectsDbServer('file', config.objects.host);
1471
+ if (hasLocalObjectsServer) {
1472
+ // silent config change on secondaries
1473
+ console.log('Objects DB type migrated from "file" to "jsonl"');
1474
+ migrated += migrated ? ' and Objects' : 'Objects';
1475
+ }
1476
+ }
1477
+ if (migrated) {
1478
+ const { NotificationHandler } = await import('@iobroker/js-controller-common');
1479
+ const hostname = tools.getHostName();
1480
+ const notificationSettings = {
1481
+ states,
1482
+ objects,
1483
+ log: console,
1484
+ logPrefix: '',
1485
+ host: hostname,
1486
+ };
1487
+ const notificationHandler = new NotificationHandler(notificationSettings);
1488
+ try {
1489
+ const ioPackage = fs.readJsonSync(path.join(tools.getControllerDir(), 'io-package.json'));
1490
+ await notificationHandler.addConfig(ioPackage.notifications);
1491
+ await notificationHandler.addMessage({
1492
+ scope: 'system',
1493
+ category: 'fileToJsonl',
1494
+ message: `Migrated: ${migrated}`,
1495
+ instance: `system.host.${hostname}`,
1496
+ });
1497
+ notificationHandler.storeNotifications();
1498
+ }
1499
+ catch (e) {
1500
+ console.warn(`Could not add File-to-JSONL notification: ${e.message}`);
1501
+ }
1502
+ }
1503
+ if (!isDeepStrictEqual(config, configOrig)) {
1504
+ fs.writeFileSync(configFile, JSON.stringify(config, null, 2));
1505
+ console.log('ioBroker configuration updated');
1506
+ }
1507
+ }
1508
+ catch (err) {
1509
+ console.log(`Could not update ioBroker configuration: ${err.message}`);
1510
+ }
1511
+ return void callback();
1512
+ },
1513
+ ignoreIfExist: isFirst,
1514
+ useRedis: isRedis,
1515
+ });
1516
+ }
1320
1517
  //# sourceMappingURL=setupSetup.js.map