@iobroker/js-controller-cli 7.2.5 → 8.0.0-alpha.11-20261103-58da667b3
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 +81 -15
- package/build/cjs/lib/setup/setupInstall.js +307 -26
- 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 +81 -15
- package/build/esm/lib/setup/setupInstall.d.ts.map +1 -1
- package/build/esm/lib/setup/setupInstall.js +334 -21
- 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 });
|
|
@@ -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) {
|
|
@@ -1103,6 +1126,7 @@ class Install {
|
|
|
1103
1126
|
}
|
|
1104
1127
|
await this._removeCustomFromObjects([adapter]);
|
|
1105
1128
|
await _uninstallNpm();
|
|
1129
|
+
await this._removePythonEnvironment(adapter);
|
|
1106
1130
|
} else {
|
|
1107
1131
|
const dependentInstance = await this._hasDependentInstances(adapter);
|
|
1108
1132
|
if (dependentInstance) {
|
|
@@ -1120,16 +1144,43 @@ class Install {
|
|
|
1120
1144
|
await this._deleteAdapterFiles(adapter, metaFilesToDelete);
|
|
1121
1145
|
await this._deleteAdapterObjects(knownObjectIDs);
|
|
1122
1146
|
await this._deleteAdapterStates(knownStateIDs);
|
|
1147
|
+
await this._freeUsedResources(adapter);
|
|
1123
1148
|
if (this.params.custom) {
|
|
1124
1149
|
await this._removeCustomFromObjects([...instances, adapter]);
|
|
1125
1150
|
}
|
|
1126
1151
|
await _uninstallNpm();
|
|
1152
|
+
await this._removePythonEnvironment(adapter);
|
|
1127
1153
|
}
|
|
1128
1154
|
} catch (e) {
|
|
1129
1155
|
console.error(`There was an error uninstalling ${adapter} on ${hostname}: ${e.message}`);
|
|
1130
1156
|
}
|
|
1131
1157
|
return resultCode;
|
|
1132
1158
|
}
|
|
1159
|
+
/**
|
|
1160
|
+
* Remove the virtual environment a Python adapter leaves behind in the data directory
|
|
1161
|
+
*
|
|
1162
|
+
* Host-local state like `node_modules` - rebuildable, but easily a few hundred megabytes - so it goes when
|
|
1163
|
+
* the adapter goes. Deliberately not part of the npm uninstall: that one starts by resolving the adapter's
|
|
1164
|
+
* `io-package.json`, so for a half-removed installation, where the package directory is already gone, it
|
|
1165
|
+
* throws before ever getting here - and that is precisely the case which leaves the environment behind with
|
|
1166
|
+
* nothing pointing at it.
|
|
1167
|
+
*
|
|
1168
|
+
* Removed without looking at `common.platform` for the same reason: the directory only exists for Python
|
|
1169
|
+
* adapters, and the `io-package.json` that would say so may no longer be there.
|
|
1170
|
+
*
|
|
1171
|
+
* @param adapter adapter name, e.g. "pyexample"
|
|
1172
|
+
*/
|
|
1173
|
+
async _removePythonEnvironment(adapter) {
|
|
1174
|
+
try {
|
|
1175
|
+
const pythonEnvDir = import_js_controller_common.tools.getPythonEnvDir(adapter);
|
|
1176
|
+
if (await import_fs_extra.default.pathExists(pythonEnvDir)) {
|
|
1177
|
+
await import_fs_extra.default.remove(pythonEnvDir);
|
|
1178
|
+
console.log(`host.${hostname} Python environment "${pythonEnvDir}" deleted`);
|
|
1179
|
+
}
|
|
1180
|
+
} catch (e) {
|
|
1181
|
+
console.error(`Cannot delete the Python environment of ${adapter}: ${e.message}`);
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1133
1184
|
/**
|
|
1134
1185
|
* Deletes given instance of an adapter
|
|
1135
1186
|
*
|
|
@@ -1153,10 +1204,79 @@ class Install {
|
|
|
1153
1204
|
await this._enumerateAdapterDocs(knownObjectIDs, adapter, instance);
|
|
1154
1205
|
await this._deleteAdapterObjects(knownObjectIDs);
|
|
1155
1206
|
await this._deleteAdapterStates(knownStateIDs);
|
|
1207
|
+
await this._freeUsedResources(adapter, instance);
|
|
1156
1208
|
if (this.params.custom) {
|
|
1157
1209
|
await this._removeCustomFromObjects([`${adapter}.${instance}`]);
|
|
1158
1210
|
}
|
|
1159
1211
|
}
|
|
1212
|
+
/**
|
|
1213
|
+
* Free all exclusive resources (serial ports, TCP/UDP ports, ...) the given instance(s) had registered.
|
|
1214
|
+
*
|
|
1215
|
+
* This is needed because an instance can be deleted via the CLI while a js-controller is not running: it
|
|
1216
|
+
* cannot notice that the instance object disappeared, so its `system.host.<host>.usedResources.<type>`
|
|
1217
|
+
* states would keep listing the resources of an instance that no longer exists.
|
|
1218
|
+
*
|
|
1219
|
+
* Hosts that are running are deliberately skipped. Such a host cleans its own registry up when it sees the
|
|
1220
|
+
* instance object being deleted, and it holds the registry in memory: it rewrites the state from that copy
|
|
1221
|
+
* on its next change, which would silently undo a write made here.
|
|
1222
|
+
*
|
|
1223
|
+
* @param adapter adapter name, e.g. "mqtt"
|
|
1224
|
+
* @param instance instance number; if undefined, all instances of the adapter are freed
|
|
1225
|
+
*/
|
|
1226
|
+
async _freeUsedResources(adapter, instance) {
|
|
1227
|
+
const matches = /* @__PURE__ */ __name((namespace) => instance !== void 0 ? namespace === `${adapter}.${instance}` : namespace.startsWith(`${adapter}.`), "matches");
|
|
1228
|
+
let keys;
|
|
1229
|
+
try {
|
|
1230
|
+
keys = await this.states.getKeys("system.host.*.usedResources.*");
|
|
1231
|
+
} catch (e) {
|
|
1232
|
+
console.warn(`Cannot read the used resources registry: ${e.message}`);
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1235
|
+
if (!keys?.length) {
|
|
1236
|
+
return;
|
|
1237
|
+
}
|
|
1238
|
+
const hostPrefix = "system.host.";
|
|
1239
|
+
const registryMarker = ".usedResources.";
|
|
1240
|
+
const hostIsRunning = /* @__PURE__ */ new Map();
|
|
1241
|
+
for (const id of keys) {
|
|
1242
|
+
const markerIndex = id.lastIndexOf(registryMarker);
|
|
1243
|
+
if (!id.startsWith(hostPrefix) || markerIndex <= hostPrefix.length) {
|
|
1244
|
+
continue;
|
|
1245
|
+
}
|
|
1246
|
+
const host = id.substring(hostPrefix.length, markerIndex);
|
|
1247
|
+
let isRunning = hostIsRunning.get(host);
|
|
1248
|
+
if (isRunning === void 0) {
|
|
1249
|
+
try {
|
|
1250
|
+
const aliveState = await this.states.getState(`${hostPrefix}${host}.alive`);
|
|
1251
|
+
isRunning = aliveState?.val === true;
|
|
1252
|
+
} catch (e) {
|
|
1253
|
+
console.warn(`Cannot check whether host "${host}" is running: ${e.message}`);
|
|
1254
|
+
isRunning = true;
|
|
1255
|
+
}
|
|
1256
|
+
hostIsRunning.set(host, isRunning);
|
|
1257
|
+
}
|
|
1258
|
+
if (isRunning) {
|
|
1259
|
+
continue;
|
|
1260
|
+
}
|
|
1261
|
+
try {
|
|
1262
|
+
const state = await this.states.getState(id);
|
|
1263
|
+
if (!state || typeof state.val !== "string" || !state.val) {
|
|
1264
|
+
continue;
|
|
1265
|
+
}
|
|
1266
|
+
const parsed = JSON.parse(state.val);
|
|
1267
|
+
if (!Array.isArray(parsed)) {
|
|
1268
|
+
continue;
|
|
1269
|
+
}
|
|
1270
|
+
const original = parsed;
|
|
1271
|
+
const filtered = original.filter((entry) => typeof entry?.instance !== "string" || !matches(entry.instance));
|
|
1272
|
+
if (filtered.length !== original.length) {
|
|
1273
|
+
await this.states.setStateAsync(id, { val: JSON.stringify(filtered), ack: true });
|
|
1274
|
+
}
|
|
1275
|
+
} catch (e) {
|
|
1276
|
+
console.warn(`Cannot free the used resources in "${id}": ${e.message}`);
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1160
1280
|
/**
|
|
1161
1281
|
* Remove all node modules that has been installed by this instance
|
|
1162
1282
|
*
|
|
@@ -1226,7 +1346,7 @@ class Install {
|
|
|
1226
1346
|
headers: {
|
|
1227
1347
|
"User-Agent": "ioBroker Adapter install",
|
|
1228
1348
|
// @ts-expect-error should be okay...
|
|
1229
|
-
validateStatus: (status) => status === 200
|
|
1349
|
+
validateStatus: /* @__PURE__ */ __name((status) => status === 200, "validateStatus")
|
|
1230
1350
|
}
|
|
1231
1351
|
});
|
|
1232
1352
|
if (result.data && Array.isArray(result.data) && result.data.length >= 1 && result.data[0].sha) {
|
|
@@ -1401,8 +1521,169 @@ class Install {
|
|
|
1401
1521
|
return instances;
|
|
1402
1522
|
}
|
|
1403
1523
|
}
|
|
1524
|
+
function processCommandUrl(options) {
|
|
1525
|
+
const { args, params, callback } = options;
|
|
1526
|
+
let url = args[0];
|
|
1527
|
+
const name = args[1];
|
|
1528
|
+
if (!url) {
|
|
1529
|
+
console.log("Please provide a URL to install from and optionally a name of the adapter to install");
|
|
1530
|
+
return void callback(import_js_controller_common.EXIT_CODES.INVALID_ARGUMENTS);
|
|
1531
|
+
}
|
|
1532
|
+
if (url[0] === '"' && url[url.length - 1] === '"') {
|
|
1533
|
+
url = url.substring(1, url.length - 1);
|
|
1534
|
+
}
|
|
1535
|
+
url = url.trim();
|
|
1536
|
+
(0, import_dbConnection.dbConnect)(params, async ({ objects, states }) => {
|
|
1537
|
+
const install = new Install({
|
|
1538
|
+
objects,
|
|
1539
|
+
states,
|
|
1540
|
+
processExit: callback,
|
|
1541
|
+
params
|
|
1542
|
+
});
|
|
1543
|
+
try {
|
|
1544
|
+
await install.installAdapterFromUrl(url, name);
|
|
1545
|
+
return void callback(import_js_controller_common.EXIT_CODES.NO_ERROR);
|
|
1546
|
+
} catch (e) {
|
|
1547
|
+
console.error(`Could not install adapter from url: ${e.message}`);
|
|
1548
|
+
return void callback(import_js_controller_common.EXIT_CODES.CANNOT_INSTALL_NPM_PACKET);
|
|
1549
|
+
}
|
|
1550
|
+
});
|
|
1551
|
+
}
|
|
1552
|
+
__name(processCommandUrl, "processCommandUrl");
|
|
1553
|
+
function processCommandInstall(options) {
|
|
1554
|
+
const { command, args, params, callback } = options;
|
|
1555
|
+
const { showHelp } = options.commandOptions;
|
|
1556
|
+
let name = args[0];
|
|
1557
|
+
let instance = args[1];
|
|
1558
|
+
let repoUrl = args[2];
|
|
1559
|
+
if (parseInt(instance, 10).toString() !== (instance || "").toString()) {
|
|
1560
|
+
repoUrl = instance;
|
|
1561
|
+
instance = void 0;
|
|
1562
|
+
}
|
|
1563
|
+
if (parseInt(repoUrl, 10).toString() === (repoUrl || "").toString()) {
|
|
1564
|
+
const temp = instance;
|
|
1565
|
+
instance = repoUrl;
|
|
1566
|
+
repoUrl = temp;
|
|
1567
|
+
}
|
|
1568
|
+
if (instance && parseInt(instance, 10).toString() === (instance || "").toString()) {
|
|
1569
|
+
params.instance = parseInt(instance, 10);
|
|
1570
|
+
}
|
|
1571
|
+
name = CLITools.normalizeAdapterName(name);
|
|
1572
|
+
const parsedName = CLITools.splitAdapterOrInstanceIdentifierWithVersion(name);
|
|
1573
|
+
if (!parsedName) {
|
|
1574
|
+
console.log("Invalid adapter name for install");
|
|
1575
|
+
showHelp();
|
|
1576
|
+
return void callback(import_js_controller_common.EXIT_CODES.INVALID_ADAPTER_ID);
|
|
1577
|
+
}
|
|
1578
|
+
if (parsedName.instance !== null) {
|
|
1579
|
+
params.instance = parsedName.instance;
|
|
1580
|
+
}
|
|
1581
|
+
name = parsedName.name;
|
|
1582
|
+
const installName = parsedName.nameWithVersion;
|
|
1583
|
+
const adapterDir = import_js_controller_common.tools.getAdapterDir(name);
|
|
1584
|
+
(0, import_dbConnection.dbConnect)(params, async ({ objects, states }) => {
|
|
1585
|
+
const install = new Install({
|
|
1586
|
+
objects,
|
|
1587
|
+
states,
|
|
1588
|
+
processExit: callback,
|
|
1589
|
+
params
|
|
1590
|
+
});
|
|
1591
|
+
if (params.host && params.host !== import_js_controller_common.tools.getHostName()) {
|
|
1592
|
+
let obj;
|
|
1593
|
+
try {
|
|
1594
|
+
obj = await objects.getObjectAsync(`system.host.${params.host}`);
|
|
1595
|
+
} catch (err) {
|
|
1596
|
+
console.warn(`Could not check existence of host "${params.host}": ${err.message}`);
|
|
1597
|
+
}
|
|
1598
|
+
if (!obj) {
|
|
1599
|
+
console.error(`Cannot add instance to non-existing host "${params.host}"`);
|
|
1600
|
+
return void callback(import_js_controller_common.EXIT_CODES.NON_EXISTING_HOST);
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
if (!adapterDir || !import_fs_extra.default.existsSync(adapterDir)) {
|
|
1604
|
+
try {
|
|
1605
|
+
const { stoppedList } = await install.downloadPacket(repoUrl, installName);
|
|
1606
|
+
await install.installAdapter(installName, repoUrl);
|
|
1607
|
+
await install.enableInstances(stoppedList, true);
|
|
1608
|
+
if (command !== "install" && command !== "i") {
|
|
1609
|
+
await install.createInstance(name, params);
|
|
1610
|
+
}
|
|
1611
|
+
return void callback();
|
|
1612
|
+
} catch (e) {
|
|
1613
|
+
console.error(`adapter "${name}" cannot be installed: ${e.message}`);
|
|
1614
|
+
return void callback(e instanceof import_customError.IoBrokerError ? e.code : import_js_controller_common.EXIT_CODES.UNKNOWN_ERROR);
|
|
1615
|
+
}
|
|
1616
|
+
} else if (command !== "install" && command !== "i") {
|
|
1617
|
+
try {
|
|
1618
|
+
await install.createInstance(name, params);
|
|
1619
|
+
return void callback();
|
|
1620
|
+
} catch (err) {
|
|
1621
|
+
console.error(`adapter "${name}" cannot be installed: ${err.message}`);
|
|
1622
|
+
return void callback(import_js_controller_common.EXIT_CODES.UNKNOWN_ERROR);
|
|
1623
|
+
}
|
|
1624
|
+
} else {
|
|
1625
|
+
console.log(`adapter "${name}" already installed. Use "upgrade" to upgrade to a newer version.`);
|
|
1626
|
+
return void callback(import_js_controller_common.EXIT_CODES.ADAPTER_ALREADY_INSTALLED);
|
|
1627
|
+
}
|
|
1628
|
+
});
|
|
1629
|
+
}
|
|
1630
|
+
__name(processCommandInstall, "processCommandInstall");
|
|
1631
|
+
function processCommandDelete(options) {
|
|
1632
|
+
const { args, params, callback } = options;
|
|
1633
|
+
const { showHelp } = options.commandOptions;
|
|
1634
|
+
let adapter = args[0];
|
|
1635
|
+
let instance = args[1];
|
|
1636
|
+
if (!adapter) {
|
|
1637
|
+
showHelp();
|
|
1638
|
+
return void callback(import_js_controller_common.EXIT_CODES.INVALID_ADAPTER_ID);
|
|
1639
|
+
}
|
|
1640
|
+
adapter = CLITools.normalizeAdapterName(adapter);
|
|
1641
|
+
if (!instance) {
|
|
1642
|
+
if (!CLITools.validateAdapterOrInstanceIdentifier(adapter)) {
|
|
1643
|
+
showHelp();
|
|
1644
|
+
return void callback(import_js_controller_common.EXIT_CODES.INVALID_ADAPTER_ID);
|
|
1645
|
+
}
|
|
1646
|
+
if (adapter.indexOf(".") > -1) {
|
|
1647
|
+
[adapter, instance] = adapter.split(".", 2);
|
|
1648
|
+
}
|
|
1649
|
+
} else {
|
|
1650
|
+
if (!CLITools.validateAdapterIdentifier(adapter) || !/^\d+$/.test(instance)) {
|
|
1651
|
+
showHelp();
|
|
1652
|
+
return void callback(import_js_controller_common.EXIT_CODES.INVALID_ADAPTER_ID);
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
if (instance) {
|
|
1656
|
+
(0, import_dbConnection.dbConnect)(params, async ({ objects, states }) => {
|
|
1657
|
+
const install = new Install({
|
|
1658
|
+
objects,
|
|
1659
|
+
states,
|
|
1660
|
+
processExit: callback,
|
|
1661
|
+
params
|
|
1662
|
+
});
|
|
1663
|
+
console.log(`Delete instance "${adapter}.${instance}"`);
|
|
1664
|
+
await install.deleteInstance(adapter, parseInt(instance));
|
|
1665
|
+
callback();
|
|
1666
|
+
});
|
|
1667
|
+
} else {
|
|
1668
|
+
(0, import_dbConnection.dbConnect)(params, async ({ objects, states }) => {
|
|
1669
|
+
const install = new Install({
|
|
1670
|
+
objects,
|
|
1671
|
+
states,
|
|
1672
|
+
processExit: callback,
|
|
1673
|
+
params
|
|
1674
|
+
});
|
|
1675
|
+
console.log(`Delete adapter "${adapter}"`);
|
|
1676
|
+
const resultCode = await install.deleteAdapter(adapter);
|
|
1677
|
+
callback(resultCode);
|
|
1678
|
+
});
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
__name(processCommandDelete, "processCommandDelete");
|
|
1404
1682
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1405
1683
|
0 && (module.exports = {
|
|
1406
|
-
Install
|
|
1684
|
+
Install,
|
|
1685
|
+
processCommandDelete,
|
|
1686
|
+
processCommandInstall,
|
|
1687
|
+
processCommandUrl
|
|
1407
1688
|
});
|
|
1408
1689
|
//# sourceMappingURL=setupInstall.js.map
|