From 396974772ce001e19cd95dc9b63cfb7c1c4e4b0c Mon Sep 17 00:00:00 2001 From: "Martin M." Date: Sat, 18 Jan 2025 23:01:08 +0100 Subject: [PATCH] "common.singleton" causes a warning now for non-onlyWWW Adapters --- README.md | 1 + lib/M100_IOPackageJson.js | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6ae23b7..c8d011a 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ npx @iobroker/repochecker https://github.com/ioBroker/ioBroker.javascript --loca ## Changelog ### **WORK IN PROGRESS** +- (mcm1957) "common.singleton" causes a warning now for non-onlyWWW Adapters. - (mcm1957) "$schema" has been blacklisted at io-package.json. - (mcm1957) Warn if 'common.nondeletable' flag is detected. - (mcm1957) Report request as deprecated package. diff --git a/lib/M100_IOPackageJson.js b/lib/M100_IOPackageJson.js index caadfad..208cd80 100644 --- a/lib/M100_IOPackageJson.js +++ b/lib/M100_IOPackageJson.js @@ -63,6 +63,20 @@ const blacklistIOPackageJson = { msg: '"common.nondeleteable" detected at io-package.json. Please check why this adapter cannot be deleted or updated and remove flag if possible.', err: false, }, + 'common.singleton': { + msg: '"common.singleton" detected for non onlyWWW adapter. Is this really desired?', + err: false, + condition: { + onlyWWW: false, + }, + }, + 'common.singletonHost': { + msg: '"common.singletonHost" detected for non onlyWWW adapter. Is this really desired?', + err: false, + condition: { + onlyWWW: false, + }, + }, 'common.subscribe': { msg: '"common.subscribe" will be removed with js-controller >= 6. Please remove from io-package.json and adapt code if required.', err: true, @@ -763,13 +777,32 @@ async function checkIOPackageJson(context) { let log = ''; for (const element of blacklist.split('.')) { log = `${log}.${element}`; - //console.log(` check ${log}`); + // console.log(` check ${log}`); tmp = tmp[element]; if (!tmp) { - //console.log(` ${log} does not exist`); + // console.log(` ${log} does not exist`); break; } } + if (tmp) { + if (blacklistIOPackageJson[blacklist].condition) { + for (const condition in blacklistIOPackageJson[blacklist].condition) { + // console.log( + // ` check condition "${condition}": ${blacklistIOPackageJson[blacklist].condition[condition]}`, + // ); + if (condition === 'onlyWWW') { + const onlyWWW = context.ioPackageJson.common.onlyWWW ? true : false; // convert undefined to false + if (onlyWWW !== blacklistIOPackageJson[blacklist].condition[condition]) { + // console.log(` check failed`); + // console.log(` ${context.ioPackageJson.common.onlyWWW}`); + // console.log(` ${onlyWWW}`); + // console.log(` ${blacklistIOPackageJson[blacklist].condition[condition]}`); + tmp = undefined; + } + } + } + } + } if (tmp) { if (blacklistIOPackageJson[blacklist].err) { context.errors.push(`[E184] ${blacklistIOPackageJson[blacklist].msg}`);