Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions packages/cli/src/lib/setup/setupInstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,13 @@ export class Install {
// combine both dependencies
const allDeps = { ...deps, ...globalDeps };

// Almost all vis-1 widgets are compatible with vis-2
const list = Object.keys(allDeps);
if (list.includes('vis') && !list.includes('vis-2')) {
allDeps['vis-2'] = '*';
globalDeps['vis-2'] = '*';
}

// Get all installed adapters
const objs = await this.objects.getObjectViewAsync('system', 'instance', {
startkey: 'system.adapter.',
Expand All @@ -520,7 +527,7 @@ export class Install {

if (dName === 'js-controller') {
const version = allDeps[dName];
// Check only if version not *, else we dont have to read io-pack unnecessarily
// Check only if version not *, else we don't have to read io-pack unnecessarily
if (version !== '*') {
const packJson = fs.readJSONSync(`${tools.getControllerDir()}/package.json`);
if (!semver.satisfies(packJson.version, version, { includePrerelease: true })) {
Expand All @@ -539,24 +546,21 @@ export class Install {
if (!isFound) {
let gInstances: ioBroker.GetObjectViewItem<ioBroker.InstanceObject>[] = [];
let locInstances: ioBroker.GetObjectViewItem<ioBroker.InstanceObject>[] = [];
// if global dep get all instances of adapter
// if global deps, then get all instances of adapter
if (globalDeps[dName] !== undefined) {
gInstances = objs.rows.filter(obj => obj.value.common && obj.value.common.name === dName);
gInstances = objs.rows.filter(obj => obj.value.common?.name === dName);
}
if (deps[dName] !== undefined) {
// local dep get all instances on same host
// local deps, then get all instances on the same host
locInstances = objs.rows.filter(
obj =>
obj.value.common &&
obj.value.common.name === dName &&
obj.value.common.host === hostname
obj => obj.value.common?.name === dName && obj.value.common.host === hostname
);
if (locInstances.length === 0) {
console.error(`host.${hostname} Required dependency "${dName}" not found on this host.`);
}
}

// we check, that all existing instances match - respect different versions for local and global deps
// we check that all existing instances match - respect different versions for local and global deps
for (const instance of locInstances) {
const instanceVersion = instance.value.common.version;
if (
Expand Down
18 changes: 15 additions & 3 deletions packages/controller/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3701,13 +3701,25 @@ async function checkVersions(id: string, deps?: Dependencies, globalDeps?: Depen
}
});

// this ensures we have a real object with correct structure
// this ensures we have a real object with the correct structure
deps = tools.parseDependencies(deps);
globalDeps = tools.parseDependencies(globalDeps);
const listDeps = Object.keys(deps);
const listGlobDeps = Object.keys(globalDeps);

// almost all vis-1 widgets are compatible with vis-2
if (
(listDeps.includes('vis') || listGlobDeps.includes('vis')) &&
!listDeps.includes('vis-2') &&
!listGlobDeps.includes('vis-2')
) {
globalDeps['vis-2'] = '*';
listGlobDeps.push('vis-2');
}

// check local dependencies: required adapter must be installed on the same host
try {
for (const dep of Object.keys(deps)) {
for (const dep of listDeps) {
checkVersion(dep, deps[dep], instances);
}
} catch (e) {
Expand All @@ -3717,7 +3729,7 @@ async function checkVersions(id: string, deps?: Dependencies, globalDeps?: Depen

// check global dependencies: required adapter must be NOT installed on the same host
try {
for (const gDep of Object.keys(globalDeps)) {
for (const gDep of listGlobDeps) {
checkVersion(gDep, globalDeps[gDep], globInstances);
}
} catch (e) {
Expand Down