@iobroker/js-controller-cli 7.2.3 → 8.0.0-alpha.2-20260923-99da17fcc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/index.js +3 -3
- package/build/cjs/lib/_Types.d.ts +8 -1
- package/build/cjs/lib/cli/cliCert.d.ts +7 -4
- package/build/cjs/lib/cli/cliCert.js +10 -6
- package/build/cjs/lib/cli/cliCert.js.map +2 -2
- package/build/cjs/lib/cli/cliCommand.d.ts +63 -15
- package/build/cjs/lib/cli/cliCommand.js +8 -1
- package/build/cjs/lib/cli/cliCommand.js.map +2 -2
- package/build/cjs/lib/cli/cliCompact.d.ts +5 -2
- package/build/cjs/lib/cli/cliCompact.js +9 -2
- package/build/cjs/lib/cli/cliCompact.js.map +2 -2
- package/build/cjs/lib/cli/cliDebug.d.ts +5 -2
- package/build/cjs/lib/cli/cliDebug.js +8 -1
- package/build/cjs/lib/cli/cliDebug.js.map +2 -2
- package/build/cjs/lib/cli/cliHost.d.ts +13 -10
- package/build/cjs/lib/cli/cliHost.js +13 -5
- package/build/cjs/lib/cli/cliHost.js.map +2 -2
- package/build/cjs/lib/cli/cliLogs.d.ts +9 -3
- package/build/cjs/lib/cli/cliLogs.js +12 -1
- package/build/cjs/lib/cli/cliLogs.js.map +2 -2
- package/build/cjs/lib/cli/cliMessage.d.ts +2 -1
- package/build/cjs/lib/cli/cliMessage.js +5 -0
- package/build/cjs/lib/cli/cliMessage.js.map +2 -2
- package/build/cjs/lib/cli/cliObjects.d.ts +21 -18
- package/build/cjs/lib/cli/cliObjects.js +51 -33
- package/build/cjs/lib/cli/cliObjects.js.map +2 -2
- package/build/cjs/lib/cli/cliPlugin.d.ts +3 -3
- package/build/cjs/lib/cli/cliPlugin.js +6 -0
- package/build/cjs/lib/cli/cliPlugin.js.map +2 -2
- package/build/cjs/lib/cli/cliProcess.d.ts +17 -7
- package/build/cjs/lib/cli/cliProcess.js +77 -24
- package/build/cjs/lib/cli/cliProcess.js.map +3 -3
- package/build/cjs/lib/cli/cliStates.d.ts +7 -4
- package/build/cjs/lib/cli/cliStates.js +14 -6
- package/build/cjs/lib/cli/cliStates.js.map +2 -2
- package/build/cjs/lib/cli/cliTools.js +11 -0
- package/build/cjs/lib/cli/cliTools.js.map +1 -1
- package/build/cjs/lib/cli/messages.js +47 -46
- package/build/cjs/lib/cli/messages.js.map +1 -1
- package/build/cjs/lib/progressBar.d.ts +59 -0
- package/build/cjs/lib/progressBar.js +115 -0
- package/build/cjs/lib/progressBar.js.map +7 -0
- package/build/cjs/lib/setup/customError.d.ts +4 -0
- package/build/cjs/lib/setup/customError.js +7 -0
- package/build/cjs/lib/setup/customError.js.map +2 -2
- package/build/cjs/lib/setup/dbConnection.js +69 -64
- package/build/cjs/lib/setup/dbConnection.js.map +3 -3
- package/build/cjs/lib/setup/formatters.d.ts +4 -4
- package/build/cjs/lib/setup/formatters.js +5 -0
- package/build/cjs/lib/setup/formatters.js.map +2 -2
- package/build/cjs/lib/setup/multihostClient.js +6 -2
- package/build/cjs/lib/setup/multihostClient.js.map +1 -1
- package/build/cjs/lib/setup/pluginInfos.d.ts +5 -0
- package/build/cjs/lib/setup/pluginInfos.js +2 -0
- package/build/cjs/lib/setup/pluginInfos.js.map +2 -2
- package/build/cjs/lib/setup/setupBackup.d.ts +53 -0
- package/build/cjs/lib/setup/setupBackup.js +125 -14
- package/build/cjs/lib/setup/setupBackup.js.map +3 -3
- package/build/cjs/lib/setup/setupInstall.d.ts +66 -15
- package/build/cjs/lib/setup/setupInstall.js +282 -28
- package/build/cjs/lib/setup/setupInstall.js.map +2 -2
- package/build/cjs/lib/setup/setupLicense.d.ts +13 -0
- package/build/cjs/lib/setup/setupLicense.js +33 -2
- package/build/cjs/lib/setup/setupLicense.js.map +2 -2
- package/build/cjs/lib/setup/setupList.d.ts +55 -1
- package/build/cjs/lib/setup/setupList.js +78 -24
- package/build/cjs/lib/setup/setupList.js.map +3 -3
- package/build/cjs/lib/setup/setupMultihost.d.ts +7 -0
- package/build/cjs/lib/setup/setupMultihost.js +78 -11
- package/build/cjs/lib/setup/setupMultihost.js.map +3 -3
- package/build/cjs/lib/setup/setupPacketManager.d.ts +10 -0
- package/build/cjs/lib/setup/setupPacketManager.js +16 -6
- package/build/cjs/lib/setup/setupPacketManager.js.map +2 -2
- package/build/cjs/lib/setup/setupRepo.d.ts +19 -0
- package/build/cjs/lib/setup/setupRepo.js +141 -13
- package/build/cjs/lib/setup/setupRepo.js.map +2 -2
- package/build/cjs/lib/setup/setupSetup.d.ts +34 -0
- package/build/cjs/lib/setup/setupSetup.js +209 -35
- package/build/cjs/lib/setup/setupSetup.js.map +3 -3
- package/build/cjs/lib/setup/setupUpgrade.d.ts +13 -2
- package/build/cjs/lib/setup/setupUpgrade.js +72 -12
- package/build/cjs/lib/setup/setupUpgrade.js.map +2 -2
- package/build/cjs/lib/setup/setupUpload.d.ts +77 -1
- package/build/cjs/lib/setup/setupUpload.js +152 -9
- package/build/cjs/lib/setup/setupUpload.js.map +2 -2
- package/build/cjs/lib/setup/setupUsers.d.ts +44 -14
- package/build/cjs/lib/setup/setupUsers.js +330 -17
- package/build/cjs/lib/setup/setupUsers.js.map +2 -2
- package/build/cjs/lib/setup/setupVendor.d.ts +14 -1
- package/build/cjs/lib/setup/setupVendor.js +40 -8
- package/build/cjs/lib/setup/setupVendor.js.map +2 -2
- package/build/cjs/lib/setup/setupVisDebug.d.ts +16 -2
- package/build/cjs/lib/setup/setupVisDebug.js +41 -17
- package/build/cjs/lib/setup/setupVisDebug.js.map +3 -3
- package/build/cjs/lib/setup/utils.d.ts +1 -1
- package/build/cjs/lib/setup/utils.js +13 -9
- package/build/cjs/lib/setup/utils.js.map +3 -3
- package/build/cjs/lib/setup.d.ts +1 -1
- package/build/cjs/lib/setup.js +858 -1758
- package/build/cjs/lib/setup.js.map +3 -3
- package/build/esm/lib/_Types.d.ts +8 -1
- package/build/esm/lib/_Types.d.ts.map +1 -1
- package/build/esm/lib/cli/cliCert.d.ts +7 -4
- package/build/esm/lib/cli/cliCert.d.ts.map +1 -1
- package/build/esm/lib/cli/cliCert.js +6 -6
- package/build/esm/lib/cli/cliCert.js.map +1 -1
- package/build/esm/lib/cli/cliCommand.d.ts +63 -15
- package/build/esm/lib/cli/cliCommand.d.ts.map +1 -1
- package/build/esm/lib/cli/cliCommand.js +4 -1
- package/build/esm/lib/cli/cliCommand.js.map +1 -1
- package/build/esm/lib/cli/cliCompact.d.ts +5 -2
- package/build/esm/lib/cli/cliCompact.d.ts.map +1 -1
- package/build/esm/lib/cli/cliCompact.js +5 -2
- package/build/esm/lib/cli/cliCompact.js.map +1 -1
- package/build/esm/lib/cli/cliDebug.d.ts +5 -2
- package/build/esm/lib/cli/cliDebug.d.ts.map +1 -1
- package/build/esm/lib/cli/cliDebug.js +4 -1
- package/build/esm/lib/cli/cliDebug.js.map +1 -1
- package/build/esm/lib/cli/cliHost.d.ts +13 -10
- package/build/esm/lib/cli/cliHost.d.ts.map +1 -1
- package/build/esm/lib/cli/cliHost.js +8 -5
- package/build/esm/lib/cli/cliHost.js.map +1 -1
- package/build/esm/lib/cli/cliLogs.d.ts +9 -3
- package/build/esm/lib/cli/cliLogs.d.ts.map +1 -1
- package/build/esm/lib/cli/cliLogs.js +8 -1
- package/build/esm/lib/cli/cliLogs.js.map +1 -1
- package/build/esm/lib/cli/cliMessage.d.ts +2 -1
- package/build/esm/lib/cli/cliMessage.d.ts.map +1 -1
- package/build/esm/lib/cli/cliMessage.js +1 -0
- package/build/esm/lib/cli/cliMessage.js.map +1 -1
- package/build/esm/lib/cli/cliObjects.d.ts +21 -18
- package/build/esm/lib/cli/cliObjects.d.ts.map +1 -1
- package/build/esm/lib/cli/cliObjects.js +44 -38
- package/build/esm/lib/cli/cliObjects.js.map +1 -1
- package/build/esm/lib/cli/cliPlugin.d.ts +3 -3
- package/build/esm/lib/cli/cliPlugin.d.ts.map +1 -1
- package/build/esm/lib/cli/cliPlugin.js +1 -1
- package/build/esm/lib/cli/cliPlugin.js.map +1 -1
- package/build/esm/lib/cli/cliProcess.d.ts +17 -7
- package/build/esm/lib/cli/cliProcess.d.ts.map +1 -1
- package/build/esm/lib/cli/cliProcess.js +73 -12
- package/build/esm/lib/cli/cliProcess.js.map +1 -1
- package/build/esm/lib/cli/cliStates.d.ts +7 -4
- package/build/esm/lib/cli/cliStates.d.ts.map +1 -1
- package/build/esm/lib/cli/cliStates.js +6 -2
- package/build/esm/lib/cli/cliStates.js.map +1 -1
- package/build/esm/lib/progressBar.d.ts +59 -0
- package/build/esm/lib/progressBar.d.ts.map +1 -0
- package/build/esm/lib/progressBar.js +104 -0
- package/build/esm/lib/progressBar.js.map +1 -0
- package/build/esm/lib/setup/customError.d.ts +4 -0
- package/build/esm/lib/setup/customError.d.ts.map +1 -1
- package/build/esm/lib/setup/customError.js +3 -0
- package/build/esm/lib/setup/customError.js.map +1 -1
- package/build/esm/lib/setup/dbConnection.d.ts.map +1 -1
- package/build/esm/lib/setup/dbConnection.js +10 -13
- package/build/esm/lib/setup/dbConnection.js.map +1 -1
- package/build/esm/lib/setup/formatters.d.ts +4 -4
- package/build/esm/lib/setup/formatters.js +4 -4
- package/build/esm/lib/setup/pluginInfos.d.ts +5 -0
- package/build/esm/lib/setup/pluginInfos.d.ts.map +1 -1
- package/build/esm/lib/setup/pluginInfos.js +5 -0
- package/build/esm/lib/setup/pluginInfos.js.map +1 -1
- package/build/esm/lib/setup/setupBackup.d.ts +53 -0
- package/build/esm/lib/setup/setupBackup.d.ts.map +1 -1
- package/build/esm/lib/setup/setupBackup.js +132 -13
- package/build/esm/lib/setup/setupBackup.js.map +1 -1
- package/build/esm/lib/setup/setupInstall.d.ts +66 -15
- package/build/esm/lib/setup/setupInstall.d.ts.map +1 -1
- package/build/esm/lib/setup/setupInstall.js +309 -23
- package/build/esm/lib/setup/setupInstall.js.map +1 -1
- package/build/esm/lib/setup/setupLicense.d.ts +13 -0
- package/build/esm/lib/setup/setupLicense.d.ts.map +1 -1
- package/build/esm/lib/setup/setupLicense.js +31 -1
- package/build/esm/lib/setup/setupLicense.js.map +1 -1
- package/build/esm/lib/setup/setupList.d.ts +55 -1
- package/build/esm/lib/setup/setupList.d.ts.map +1 -1
- package/build/esm/lib/setup/setupList.js +61 -8
- package/build/esm/lib/setup/setupList.js.map +1 -1
- package/build/esm/lib/setup/setupMultihost.d.ts +7 -0
- package/build/esm/lib/setup/setupMultihost.d.ts.map +1 -1
- package/build/esm/lib/setup/setupMultihost.js +85 -6
- package/build/esm/lib/setup/setupMultihost.js.map +1 -1
- package/build/esm/lib/setup/setupPacketManager.d.ts +10 -0
- package/build/esm/lib/setup/setupPacketManager.d.ts.map +1 -1
- package/build/esm/lib/setup/setupPacketManager.js +9 -0
- package/build/esm/lib/setup/setupPacketManager.js.map +1 -1
- package/build/esm/lib/setup/setupRepo.d.ts +19 -0
- package/build/esm/lib/setup/setupRepo.d.ts.map +1 -1
- package/build/esm/lib/setup/setupRepo.js +164 -14
- package/build/esm/lib/setup/setupRepo.js.map +1 -1
- package/build/esm/lib/setup/setupSetup.d.ts +34 -0
- package/build/esm/lib/setup/setupSetup.d.ts.map +1 -1
- package/build/esm/lib/setup/setupSetup.js +218 -21
- package/build/esm/lib/setup/setupSetup.js.map +1 -1
- package/build/esm/lib/setup/setupUpgrade.d.ts +13 -2
- package/build/esm/lib/setup/setupUpgrade.d.ts.map +1 -1
- package/build/esm/lib/setup/setupUpgrade.js +70 -6
- package/build/esm/lib/setup/setupUpgrade.js.map +1 -1
- package/build/esm/lib/setup/setupUpload.d.ts +77 -1
- package/build/esm/lib/setup/setupUpload.d.ts.map +1 -1
- package/build/esm/lib/setup/setupUpload.js +164 -7
- package/build/esm/lib/setup/setupUpload.js.map +1 -1
- package/build/esm/lib/setup/setupUsers.d.ts +44 -14
- package/build/esm/lib/setup/setupUsers.d.ts.map +1 -1
- package/build/esm/lib/setup/setupUsers.js +346 -14
- package/build/esm/lib/setup/setupUsers.js.map +1 -1
- package/build/esm/lib/setup/setupVendor.d.ts +14 -1
- package/build/esm/lib/setup/setupVendor.d.ts.map +1 -1
- package/build/esm/lib/setup/setupVendor.js +33 -2
- package/build/esm/lib/setup/setupVendor.js.map +1 -1
- package/build/esm/lib/setup/setupVisDebug.d.ts +16 -2
- package/build/esm/lib/setup/setupVisDebug.d.ts.map +1 -1
- package/build/esm/lib/setup/setupVisDebug.js +39 -14
- package/build/esm/lib/setup/setupVisDebug.js.map +1 -1
- package/build/esm/lib/setup/utils.d.ts +1 -1
- package/build/esm/lib/setup/utils.d.ts.map +1 -1
- package/build/esm/lib/setup/utils.js +2 -4
- package/build/esm/lib/setup/utils.js.map +1 -1
- package/build/esm/lib/setup.d.ts +1 -1
- package/build/esm/lib/setup.d.ts.map +1 -1
- package/build/esm/lib/setup.js +959 -1910
- package/build/esm/lib/setup.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +14 -14
|
@@ -5,6 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
9
|
var __export = (target, all) => {
|
|
9
10
|
for (var name in all)
|
|
10
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -28,28 +29,36 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
30
|
var setupInstall_exports = {};
|
|
30
31
|
__export(setupInstall_exports, {
|
|
31
|
-
Install: () => Install
|
|
32
|
+
Install: () => Install,
|
|
33
|
+
processCommandDelete: () => processCommandDelete,
|
|
34
|
+
processCommandInstall: () => processCommandInstall,
|
|
35
|
+
processCommandUrl: () => processCommandUrl
|
|
32
36
|
});
|
|
33
37
|
module.exports = __toCommonJS(setupInstall_exports);
|
|
34
38
|
var __import_meta_url = typeof document === "undefined" ? new (require("url".replace("", ""))).URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
35
|
-
var import_js_controller_common = require("@iobroker/js-controller-common");
|
|
36
|
-
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
37
39
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
38
|
-
var import_semver = __toESM(require("semver"), 1);
|
|
39
40
|
var import_node_child_process = __toESM(require("node:child_process"), 1);
|
|
40
|
-
var import_axios = __toESM(require("axios"), 1);
|
|
41
41
|
var import_node_url = require("node:url");
|
|
42
|
+
var import_node_module = require("node:module");
|
|
43
|
+
var import_axios = __toESM(require("axios"), 1);
|
|
44
|
+
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
45
|
+
var import_semver = __toESM(require("semver"), 1);
|
|
46
|
+
var import_js_controller_common = require("@iobroker/js-controller-common");
|
|
42
47
|
var import_setupUpload = require("../../lib/setup/setupUpload.js");
|
|
43
48
|
var import_setupPacketManager = require("../../lib/setup/setupPacketManager.js");
|
|
44
49
|
var import_utils = require("../../lib/setup/utils.js");
|
|
45
50
|
var import_customError = require("../../lib/setup/customError.js");
|
|
51
|
+
var import_dbConnection = require("../../lib/setup/dbConnection.js");
|
|
52
|
+
var CLITools = __toESM(require("../../lib/cli/cliTools.js"), 1);
|
|
46
53
|
var import_constants = require("@iobroker/js-controller-common-db/constants");
|
|
47
|
-
var import_node_module = require("node:module");
|
|
48
54
|
const require2 = (0, import_node_module.createRequire)(__import_meta_url || `file://${__filename}`);
|
|
49
55
|
const hostname = import_js_controller_common.tools.getHostName();
|
|
50
56
|
const osPlatform = process.platform;
|
|
51
57
|
const RECOMMENDED_NPM_VERSION = 8;
|
|
52
58
|
class Install {
|
|
59
|
+
static {
|
|
60
|
+
__name(this, "Install");
|
|
61
|
+
}
|
|
53
62
|
isRootOnUnix;
|
|
54
63
|
objects;
|
|
55
64
|
states;
|
|
@@ -58,6 +67,9 @@ class Install {
|
|
|
58
67
|
tarballRegex;
|
|
59
68
|
upload;
|
|
60
69
|
packetManager;
|
|
70
|
+
/**
|
|
71
|
+
* @param options The states/objects clients, CLI parameters and the process-exit callback
|
|
72
|
+
*/
|
|
61
73
|
constructor(options) {
|
|
62
74
|
this.isRootOnUnix = typeof process.getuid === "function" && process.getuid() === 0;
|
|
63
75
|
options = options || {};
|
|
@@ -111,7 +123,7 @@ class Install {
|
|
|
111
123
|
if (!options || typeof options !== "object") {
|
|
112
124
|
options = {};
|
|
113
125
|
}
|
|
114
|
-
stoppedList
|
|
126
|
+
stoppedList ||= [];
|
|
115
127
|
let sources;
|
|
116
128
|
if (!repoUrlOrRepo || !import_js_controller_common.tools.isObject(repoUrlOrRepo)) {
|
|
117
129
|
sources = await (0, import_utils.getRepository)({ repoName: repoUrlOrRepo, objects: this.objects });
|
|
@@ -247,7 +259,7 @@ class Install {
|
|
|
247
259
|
debug: !!debug,
|
|
248
260
|
unsafePerm: !!options.unsafePerm
|
|
249
261
|
});
|
|
250
|
-
const isSuccess = result.success || result.exitCode === 1 && !result.stderr.startsWith("npm ERR!");
|
|
262
|
+
const isSuccess = result.success || result.exitCode === 1 && !result.stderr.startsWith("npm ERR!") && !result.stderr.startsWith("npm error ");
|
|
251
263
|
if (isSuccess) {
|
|
252
264
|
let packetDirName;
|
|
253
265
|
if (options.packetName) {
|
|
@@ -294,7 +306,7 @@ class Install {
|
|
|
294
306
|
handleNpmNotEmptyError(notEmptyErrorOptions) {
|
|
295
307
|
const { debug, npmUrl, options, result } = notEmptyErrorOptions;
|
|
296
308
|
console.info("Try to solve ENOTEMPTY error automatically");
|
|
297
|
-
const errorFilePath = result.stderr.split("\n")?.find((line) => line.startsWith("npm ERR! dest"))?.split("dest")[1].trim();
|
|
309
|
+
const errorFilePath = result.stderr.split("\n")?.find((line) => line.startsWith("npm ERR! dest") || line.startsWith("npm error dest"))?.split("dest")[1].trim();
|
|
298
310
|
const affectedNodeModulesPath = errorFilePath ? import_node_path.default.join(errorFilePath, "..") : void 0;
|
|
299
311
|
if (affectedNodeModulesPath) {
|
|
300
312
|
const parts = affectedNodeModulesPath.replace(/\\/g, "/").split("/");
|
|
@@ -432,7 +444,7 @@ class Install {
|
|
|
432
444
|
obj.from = `system.host.${hostname}.cli`;
|
|
433
445
|
obj.ts = Date.now();
|
|
434
446
|
try {
|
|
435
|
-
await this.objects.
|
|
447
|
+
await this.objects.extendObject(obj._id, obj);
|
|
436
448
|
} catch (err) {
|
|
437
449
|
console.error(`host.${hostname} error setObject ${obj._id} ${err.message}`);
|
|
438
450
|
return;
|
|
@@ -445,8 +457,8 @@ class Install {
|
|
|
445
457
|
* Installs given adapter
|
|
446
458
|
*
|
|
447
459
|
* @param adapter The adapter name
|
|
448
|
-
* @param repoUrl
|
|
449
|
-
* @param _installCount
|
|
460
|
+
* @param repoUrl Optional repository URL to install the adapter from
|
|
461
|
+
* @param _installCount Internal recursion counter limiting the number of dependency installs
|
|
450
462
|
*/
|
|
451
463
|
async installAdapter(adapter, repoUrl, _installCount) {
|
|
452
464
|
_installCount = _installCount || 0;
|
|
@@ -506,6 +518,11 @@ class Install {
|
|
|
506
518
|
await this.upload.upgradeAdapterObjects(adapter);
|
|
507
519
|
return adapter;
|
|
508
520
|
}
|
|
521
|
+
/**
|
|
522
|
+
* Install the OS packages required by an adapter
|
|
523
|
+
*
|
|
524
|
+
* @param osDependencies The OS dependencies declared by the adapter, keyed by platform
|
|
525
|
+
*/
|
|
509
526
|
async installOSPackages(osDependencies) {
|
|
510
527
|
if (osPlatform in osDependencies) {
|
|
511
528
|
try {
|
|
@@ -517,6 +534,12 @@ class Install {
|
|
|
517
534
|
}
|
|
518
535
|
}
|
|
519
536
|
}
|
|
537
|
+
/**
|
|
538
|
+
* Run the custom install script of an adapter if it defines one
|
|
539
|
+
*
|
|
540
|
+
* @param adapter The adapter name
|
|
541
|
+
* @param config The adapter object containing the install configuration
|
|
542
|
+
*/
|
|
520
543
|
async callInstallOfAdapter(adapter, config) {
|
|
521
544
|
if (config.common.install) {
|
|
522
545
|
let cmd = "node ";
|
|
@@ -740,10 +763,10 @@ class Install {
|
|
|
740
763
|
/**
|
|
741
764
|
* Enumerate all instances of an adapter
|
|
742
765
|
*
|
|
743
|
-
* @param knownObjIDs
|
|
744
|
-
* @param notDeleted
|
|
745
|
-
* @param adapter
|
|
746
|
-
* @param instance
|
|
766
|
+
* @param knownObjIDs Accumulator of object IDs found so far
|
|
767
|
+
* @param notDeleted Accumulator of object IDs that must not be deleted
|
|
768
|
+
* @param adapter The adapter name
|
|
769
|
+
* @param instance Optional instance number to restrict the search to
|
|
747
770
|
*/
|
|
748
771
|
async _enumerateAdapterInstances(knownObjIDs, notDeleted, adapter, instance) {
|
|
749
772
|
if (!notDeleted) {
|
|
@@ -775,9 +798,9 @@ class Install {
|
|
|
775
798
|
/**
|
|
776
799
|
* Enumerate all meta objects of an adapter
|
|
777
800
|
*
|
|
778
|
-
* @param knownObjIDs
|
|
779
|
-
* @param adapter
|
|
780
|
-
* @param metaFilesToDelete
|
|
801
|
+
* @param knownObjIDs Accumulator of object IDs found so far
|
|
802
|
+
* @param adapter The adapter name
|
|
803
|
+
* @param metaFilesToDelete Accumulator of meta files that should be deleted
|
|
781
804
|
*/
|
|
782
805
|
async _enumerateAdapterMeta(knownObjIDs, adapter, metaFilesToDelete) {
|
|
783
806
|
try {
|
|
@@ -934,9 +957,9 @@ class Install {
|
|
|
934
957
|
/**
|
|
935
958
|
* Enumerate all state IDs of an adapter (or instance)
|
|
936
959
|
*
|
|
937
|
-
* @param knownStateIDs
|
|
938
|
-
* @param adapter
|
|
939
|
-
* @param instance
|
|
960
|
+
* @param knownStateIDs Accumulator of state IDs found so far
|
|
961
|
+
* @param adapter The adapter name
|
|
962
|
+
* @param instance Optional instance number to restrict the search to
|
|
940
963
|
*/
|
|
941
964
|
async _enumerateAdapterStates(knownStateIDs, adapter, instance) {
|
|
942
965
|
for (const pattern of [
|
|
@@ -963,8 +986,8 @@ class Install {
|
|
|
963
986
|
/**
|
|
964
987
|
* delete WWW pages, objects and meta files
|
|
965
988
|
*
|
|
966
|
-
* @param adapter
|
|
967
|
-
* @param metaFilesToDelete
|
|
989
|
+
* @param adapter The adapter name
|
|
990
|
+
* @param metaFilesToDelete The meta files that should be deleted
|
|
968
991
|
*/
|
|
969
992
|
async _deleteAdapterFiles(adapter, metaFilesToDelete) {
|
|
970
993
|
const filesToDelete = [
|
|
@@ -1051,7 +1074,7 @@ class Install {
|
|
|
1051
1074
|
const notDeletedObjectIDs = [];
|
|
1052
1075
|
const knownStateIDs = [];
|
|
1053
1076
|
let resultCode = import_js_controller_common.EXIT_CODES.NO_ERROR;
|
|
1054
|
-
const _uninstallNpm = async () => {
|
|
1077
|
+
const _uninstallNpm = /* @__PURE__ */ __name(async () => {
|
|
1055
1078
|
try {
|
|
1056
1079
|
const adapterNpm = `${import_js_controller_common.tools.appName.toLowerCase()}.${adapter}`;
|
|
1057
1080
|
const ioPackPath = require2.resolve(`${adapterNpm}/io-package.json`);
|
|
@@ -1094,7 +1117,7 @@ class Install {
|
|
|
1094
1117
|
console.error(`Error deleting adapter ${adapter} from disk: ${e.message}`);
|
|
1095
1118
|
console.error(`You might have to delete it yourself!`);
|
|
1096
1119
|
}
|
|
1097
|
-
};
|
|
1120
|
+
}, "_uninstallNpm");
|
|
1098
1121
|
try {
|
|
1099
1122
|
await this._enumerateAdapterInstances(knownObjectIDs, notDeletedObjectIDs, adapter);
|
|
1100
1123
|
if (notDeletedObjectIDs.length) {
|
|
@@ -1120,6 +1143,7 @@ class Install {
|
|
|
1120
1143
|
await this._deleteAdapterFiles(adapter, metaFilesToDelete);
|
|
1121
1144
|
await this._deleteAdapterObjects(knownObjectIDs);
|
|
1122
1145
|
await this._deleteAdapterStates(knownStateIDs);
|
|
1146
|
+
await this._freeUsedResources(adapter);
|
|
1123
1147
|
if (this.params.custom) {
|
|
1124
1148
|
await this._removeCustomFromObjects([...instances, adapter]);
|
|
1125
1149
|
}
|
|
@@ -1153,10 +1177,79 @@ class Install {
|
|
|
1153
1177
|
await this._enumerateAdapterDocs(knownObjectIDs, adapter, instance);
|
|
1154
1178
|
await this._deleteAdapterObjects(knownObjectIDs);
|
|
1155
1179
|
await this._deleteAdapterStates(knownStateIDs);
|
|
1180
|
+
await this._freeUsedResources(adapter, instance);
|
|
1156
1181
|
if (this.params.custom) {
|
|
1157
1182
|
await this._removeCustomFromObjects([`${adapter}.${instance}`]);
|
|
1158
1183
|
}
|
|
1159
1184
|
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Free all exclusive resources (serial ports, TCP/UDP ports, ...) the given instance(s) had registered.
|
|
1187
|
+
*
|
|
1188
|
+
* This is needed because an instance can be deleted via the CLI while a js-controller is not running: it
|
|
1189
|
+
* cannot notice that the instance object disappeared, so its `system.host.<host>.usedResources.<type>`
|
|
1190
|
+
* states would keep listing the resources of an instance that no longer exists.
|
|
1191
|
+
*
|
|
1192
|
+
* Hosts that are running are deliberately skipped. Such a host cleans its own registry up when it sees the
|
|
1193
|
+
* instance object being deleted, and it holds the registry in memory: it rewrites the state from that copy
|
|
1194
|
+
* on its next change, which would silently undo a write made here.
|
|
1195
|
+
*
|
|
1196
|
+
* @param adapter adapter name, e.g. "mqtt"
|
|
1197
|
+
* @param instance instance number; if undefined, all instances of the adapter are freed
|
|
1198
|
+
*/
|
|
1199
|
+
async _freeUsedResources(adapter, instance) {
|
|
1200
|
+
const matches = /* @__PURE__ */ __name((namespace) => instance !== void 0 ? namespace === `${adapter}.${instance}` : namespace.startsWith(`${adapter}.`), "matches");
|
|
1201
|
+
let keys;
|
|
1202
|
+
try {
|
|
1203
|
+
keys = await this.states.getKeys("system.host.*.usedResources.*");
|
|
1204
|
+
} catch (e) {
|
|
1205
|
+
console.warn(`Cannot read the used resources registry: ${e.message}`);
|
|
1206
|
+
return;
|
|
1207
|
+
}
|
|
1208
|
+
if (!keys?.length) {
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
1211
|
+
const hostPrefix = "system.host.";
|
|
1212
|
+
const registryMarker = ".usedResources.";
|
|
1213
|
+
const hostIsRunning = /* @__PURE__ */ new Map();
|
|
1214
|
+
for (const id of keys) {
|
|
1215
|
+
const markerIndex = id.lastIndexOf(registryMarker);
|
|
1216
|
+
if (!id.startsWith(hostPrefix) || markerIndex <= hostPrefix.length) {
|
|
1217
|
+
continue;
|
|
1218
|
+
}
|
|
1219
|
+
const host = id.substring(hostPrefix.length, markerIndex);
|
|
1220
|
+
let isRunning = hostIsRunning.get(host);
|
|
1221
|
+
if (isRunning === void 0) {
|
|
1222
|
+
try {
|
|
1223
|
+
const aliveState = await this.states.getState(`${hostPrefix}${host}.alive`);
|
|
1224
|
+
isRunning = aliveState?.val === true;
|
|
1225
|
+
} catch (e) {
|
|
1226
|
+
console.warn(`Cannot check whether host "${host}" is running: ${e.message}`);
|
|
1227
|
+
isRunning = true;
|
|
1228
|
+
}
|
|
1229
|
+
hostIsRunning.set(host, isRunning);
|
|
1230
|
+
}
|
|
1231
|
+
if (isRunning) {
|
|
1232
|
+
continue;
|
|
1233
|
+
}
|
|
1234
|
+
try {
|
|
1235
|
+
const state = await this.states.getState(id);
|
|
1236
|
+
if (!state || typeof state.val !== "string" || !state.val) {
|
|
1237
|
+
continue;
|
|
1238
|
+
}
|
|
1239
|
+
const parsed = JSON.parse(state.val);
|
|
1240
|
+
if (!Array.isArray(parsed)) {
|
|
1241
|
+
continue;
|
|
1242
|
+
}
|
|
1243
|
+
const original = parsed;
|
|
1244
|
+
const filtered = original.filter((entry) => typeof entry?.instance !== "string" || !matches(entry.instance));
|
|
1245
|
+
if (filtered.length !== original.length) {
|
|
1246
|
+
await this.states.setStateAsync(id, { val: JSON.stringify(filtered), ack: true });
|
|
1247
|
+
}
|
|
1248
|
+
} catch (e) {
|
|
1249
|
+
console.warn(`Cannot free the used resources in "${id}": ${e.message}`);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1160
1253
|
/**
|
|
1161
1254
|
* Remove all node modules that has been installed by this instance
|
|
1162
1255
|
*
|
|
@@ -1226,7 +1319,7 @@ class Install {
|
|
|
1226
1319
|
headers: {
|
|
1227
1320
|
"User-Agent": "ioBroker Adapter install",
|
|
1228
1321
|
// @ts-expect-error should be okay...
|
|
1229
|
-
validateStatus: (status) => status === 200
|
|
1322
|
+
validateStatus: /* @__PURE__ */ __name((status) => status === 200, "validateStatus")
|
|
1230
1323
|
}
|
|
1231
1324
|
});
|
|
1232
1325
|
if (result.data && Array.isArray(result.data) && result.data.length >= 1 && result.data[0].sha) {
|
|
@@ -1401,8 +1494,169 @@ class Install {
|
|
|
1401
1494
|
return instances;
|
|
1402
1495
|
}
|
|
1403
1496
|
}
|
|
1497
|
+
function processCommandUrl(options) {
|
|
1498
|
+
const { args, params, callback } = options;
|
|
1499
|
+
let url = args[0];
|
|
1500
|
+
const name = args[1];
|
|
1501
|
+
if (!url) {
|
|
1502
|
+
console.log("Please provide a URL to install from and optionally a name of the adapter to install");
|
|
1503
|
+
return void callback(import_js_controller_common.EXIT_CODES.INVALID_ARGUMENTS);
|
|
1504
|
+
}
|
|
1505
|
+
if (url[0] === '"' && url[url.length - 1] === '"') {
|
|
1506
|
+
url = url.substring(1, url.length - 1);
|
|
1507
|
+
}
|
|
1508
|
+
url = url.trim();
|
|
1509
|
+
(0, import_dbConnection.dbConnect)(params, async ({ objects, states }) => {
|
|
1510
|
+
const install = new Install({
|
|
1511
|
+
objects,
|
|
1512
|
+
states,
|
|
1513
|
+
processExit: callback,
|
|
1514
|
+
params
|
|
1515
|
+
});
|
|
1516
|
+
try {
|
|
1517
|
+
await install.installAdapterFromUrl(url, name);
|
|
1518
|
+
return void callback(import_js_controller_common.EXIT_CODES.NO_ERROR);
|
|
1519
|
+
} catch (e) {
|
|
1520
|
+
console.error(`Could not install adapter from url: ${e.message}`);
|
|
1521
|
+
return void callback(import_js_controller_common.EXIT_CODES.CANNOT_INSTALL_NPM_PACKET);
|
|
1522
|
+
}
|
|
1523
|
+
});
|
|
1524
|
+
}
|
|
1525
|
+
__name(processCommandUrl, "processCommandUrl");
|
|
1526
|
+
function processCommandInstall(options) {
|
|
1527
|
+
const { command, args, params, callback } = options;
|
|
1528
|
+
const { showHelp } = options.commandOptions;
|
|
1529
|
+
let name = args[0];
|
|
1530
|
+
let instance = args[1];
|
|
1531
|
+
let repoUrl = args[2];
|
|
1532
|
+
if (parseInt(instance, 10).toString() !== (instance || "").toString()) {
|
|
1533
|
+
repoUrl = instance;
|
|
1534
|
+
instance = void 0;
|
|
1535
|
+
}
|
|
1536
|
+
if (parseInt(repoUrl, 10).toString() === (repoUrl || "").toString()) {
|
|
1537
|
+
const temp = instance;
|
|
1538
|
+
instance = repoUrl;
|
|
1539
|
+
repoUrl = temp;
|
|
1540
|
+
}
|
|
1541
|
+
if (instance && parseInt(instance, 10).toString() === (instance || "").toString()) {
|
|
1542
|
+
params.instance = parseInt(instance, 10);
|
|
1543
|
+
}
|
|
1544
|
+
name = CLITools.normalizeAdapterName(name);
|
|
1545
|
+
const parsedName = CLITools.splitAdapterOrInstanceIdentifierWithVersion(name);
|
|
1546
|
+
if (!parsedName) {
|
|
1547
|
+
console.log("Invalid adapter name for install");
|
|
1548
|
+
showHelp();
|
|
1549
|
+
return void callback(import_js_controller_common.EXIT_CODES.INVALID_ADAPTER_ID);
|
|
1550
|
+
}
|
|
1551
|
+
if (parsedName.instance !== null) {
|
|
1552
|
+
params.instance = parsedName.instance;
|
|
1553
|
+
}
|
|
1554
|
+
name = parsedName.name;
|
|
1555
|
+
const installName = parsedName.nameWithVersion;
|
|
1556
|
+
const adapterDir = import_js_controller_common.tools.getAdapterDir(name);
|
|
1557
|
+
(0, import_dbConnection.dbConnect)(params, async ({ objects, states }) => {
|
|
1558
|
+
const install = new Install({
|
|
1559
|
+
objects,
|
|
1560
|
+
states,
|
|
1561
|
+
processExit: callback,
|
|
1562
|
+
params
|
|
1563
|
+
});
|
|
1564
|
+
if (params.host && params.host !== import_js_controller_common.tools.getHostName()) {
|
|
1565
|
+
let obj;
|
|
1566
|
+
try {
|
|
1567
|
+
obj = await objects.getObjectAsync(`system.host.${params.host}`);
|
|
1568
|
+
} catch (err) {
|
|
1569
|
+
console.warn(`Could not check existence of host "${params.host}": ${err.message}`);
|
|
1570
|
+
}
|
|
1571
|
+
if (!obj) {
|
|
1572
|
+
console.error(`Cannot add instance to non-existing host "${params.host}"`);
|
|
1573
|
+
return void callback(import_js_controller_common.EXIT_CODES.NON_EXISTING_HOST);
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
if (!adapterDir || !import_fs_extra.default.existsSync(adapterDir)) {
|
|
1577
|
+
try {
|
|
1578
|
+
const { stoppedList } = await install.downloadPacket(repoUrl, installName);
|
|
1579
|
+
await install.installAdapter(installName, repoUrl);
|
|
1580
|
+
await install.enableInstances(stoppedList, true);
|
|
1581
|
+
if (command !== "install" && command !== "i") {
|
|
1582
|
+
await install.createInstance(name, params);
|
|
1583
|
+
}
|
|
1584
|
+
return void callback();
|
|
1585
|
+
} catch (e) {
|
|
1586
|
+
console.error(`adapter "${name}" cannot be installed: ${e.message}`);
|
|
1587
|
+
return void callback(e instanceof import_customError.IoBrokerError ? e.code : import_js_controller_common.EXIT_CODES.UNKNOWN_ERROR);
|
|
1588
|
+
}
|
|
1589
|
+
} else if (command !== "install" && command !== "i") {
|
|
1590
|
+
try {
|
|
1591
|
+
await install.createInstance(name, params);
|
|
1592
|
+
return void callback();
|
|
1593
|
+
} catch (err) {
|
|
1594
|
+
console.error(`adapter "${name}" cannot be installed: ${err.message}`);
|
|
1595
|
+
return void callback(import_js_controller_common.EXIT_CODES.UNKNOWN_ERROR);
|
|
1596
|
+
}
|
|
1597
|
+
} else {
|
|
1598
|
+
console.log(`adapter "${name}" already installed. Use "upgrade" to upgrade to a newer version.`);
|
|
1599
|
+
return void callback(import_js_controller_common.EXIT_CODES.ADAPTER_ALREADY_INSTALLED);
|
|
1600
|
+
}
|
|
1601
|
+
});
|
|
1602
|
+
}
|
|
1603
|
+
__name(processCommandInstall, "processCommandInstall");
|
|
1604
|
+
function processCommandDelete(options) {
|
|
1605
|
+
const { args, params, callback } = options;
|
|
1606
|
+
const { showHelp } = options.commandOptions;
|
|
1607
|
+
let adapter = args[0];
|
|
1608
|
+
let instance = args[1];
|
|
1609
|
+
if (!adapter) {
|
|
1610
|
+
showHelp();
|
|
1611
|
+
return void callback(import_js_controller_common.EXIT_CODES.INVALID_ADAPTER_ID);
|
|
1612
|
+
}
|
|
1613
|
+
adapter = CLITools.normalizeAdapterName(adapter);
|
|
1614
|
+
if (!instance) {
|
|
1615
|
+
if (!CLITools.validateAdapterOrInstanceIdentifier(adapter)) {
|
|
1616
|
+
showHelp();
|
|
1617
|
+
return void callback(import_js_controller_common.EXIT_CODES.INVALID_ADAPTER_ID);
|
|
1618
|
+
}
|
|
1619
|
+
if (adapter.indexOf(".") > -1) {
|
|
1620
|
+
[adapter, instance] = adapter.split(".", 2);
|
|
1621
|
+
}
|
|
1622
|
+
} else {
|
|
1623
|
+
if (!CLITools.validateAdapterIdentifier(adapter) || !/^\d+$/.test(instance)) {
|
|
1624
|
+
showHelp();
|
|
1625
|
+
return void callback(import_js_controller_common.EXIT_CODES.INVALID_ADAPTER_ID);
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
if (instance) {
|
|
1629
|
+
(0, import_dbConnection.dbConnect)(params, async ({ objects, states }) => {
|
|
1630
|
+
const install = new Install({
|
|
1631
|
+
objects,
|
|
1632
|
+
states,
|
|
1633
|
+
processExit: callback,
|
|
1634
|
+
params
|
|
1635
|
+
});
|
|
1636
|
+
console.log(`Delete instance "${adapter}.${instance}"`);
|
|
1637
|
+
await install.deleteInstance(adapter, parseInt(instance));
|
|
1638
|
+
callback();
|
|
1639
|
+
});
|
|
1640
|
+
} else {
|
|
1641
|
+
(0, import_dbConnection.dbConnect)(params, async ({ objects, states }) => {
|
|
1642
|
+
const install = new Install({
|
|
1643
|
+
objects,
|
|
1644
|
+
states,
|
|
1645
|
+
processExit: callback,
|
|
1646
|
+
params
|
|
1647
|
+
});
|
|
1648
|
+
console.log(`Delete adapter "${adapter}"`);
|
|
1649
|
+
const resultCode = await install.deleteAdapter(adapter);
|
|
1650
|
+
callback(resultCode);
|
|
1651
|
+
});
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
__name(processCommandDelete, "processCommandDelete");
|
|
1404
1655
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1405
1656
|
0 && (module.exports = {
|
|
1406
|
-
Install
|
|
1657
|
+
Install,
|
|
1658
|
+
processCommandDelete,
|
|
1659
|
+
processCommandInstall,
|
|
1660
|
+
processCommandUrl
|
|
1407
1661
|
});
|
|
1408
1662
|
//# sourceMappingURL=setupInstall.js.map
|