Add adapter compatibility checks for GitHub installations
Description
Fixes installation of adapters from GitHub URLs by validating adapter compatibility before installation begins. Previously, the CLI would install adapters from GitHub without checking if they support GitHub installation (common.nogit flag) or are compatible with the current system, resulting in startup errors due to missing files or incompatible configurations.
Changes
This PR implements comprehensive pre-installation validation by fetching and checking the io-package.json file directly from GitHub:
-
Added
_fetchAndValidateIoPackagemethod that:- Fetches
io-package.jsonfrom GitHub's raw content API using the commit hash - Returns the full adapter object for validation
- Handles fetch failures gracefully
- Fetches
-
Added
_performAdapterChecksmethod that performs compatibility checks:-
nogit flag: Blocks installation if
common.nogitistrue -
OS compatibility: Validates the adapter supports the current operating system (
common.os)
-
nogit flag: Blocks installation if
-
Modified
installAdapterFromUrlto validate before installation:- Tracks GitHub user, repo, and commit information during URL parsing
- Calls validation checks after the commit hash is determined
- Handles both full GitHub URLs (
https://github.com/user/repo) and short format (user/repo#commit)
Behavior
When installing an adapter from GitHub:
-
If
common.nogitistrue: Installation is blocked with error:Cannot install adapter from GitHub: The adapter "repo" has set the "nogit" flag which prevents manual installation from GitHub. -
If OS is incompatible: Installation is blocked with error:
Cannot install adapter from GitHub: Adapter does not support current OS. Required linux. Actual platform: win32 -
If
io-package.jsoncannot be fetched: Installation continues with a warning that the adapter may not support GitHub installation -
If the commit hash cannot be determined: Installation continues with a warning
-
If all checks pass: Installation proceeds normally
Example
For adapters like ioBroker.modbus that have common.nogit: true, the command:
iob url https://github.com/ioBroker/ioBroker.modbus
Will now fail with a descriptive error instead of installing and causing runtime errors.
Closes #2623
Fixes ioBroker/ioBroker.js-controller#3119
Original prompt
This section details on the original issue you should resolve
<issue_title>[bug]: Requirement check for 'nogit' missing</issue_title> <issue_description>### No existing issues.
- [x] There is no existing issue for my problem.
Description
iob url https://... installs an adapter even if the flag common.nogit is set to true.
This results in various errors, most likely startup errors due to missing files.
Installation should be blocked.
If this is not possible (do to limited access to sources - iob url seems to simply call npm) a BIG info should be logged AFTER installation and any attempt to start the adapter should be blocked (as after installation io-package.json is definitly available this should be possible in any case). The combination "installed from github and nogit should be available to check,
Reproduction instruction
Try to install any adapter with common.nogit set to true (i.e. ioBroker.modbus) using commandline
iob url https://...JS-controller version
7.0.6
Node version
22</issue_description>
Comments on the Issue (you are @copilot in this section)
@Apollon77 The problem here is that a "URL" install does not know the adapter name and so can not check the repository. Additionally usually this is used to install development adapters.We can do the following: When we already determine the commit hash of the installation (and make sure we do this before npm install call) we could use this commit has to read the "io-package.json" directly from GitHub. If we can read it we can check basically all infos. if we can not access that we should log a warning that we could not determine the adapter details but still install.</comment_new>
Fixes ioBroker/ioBroker.js-controller#3119
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
@copilot remove changed the package-lock.json file from this PR. This was not part of the order.
Additional please adjust to not only check the Nogit flag when loading of the io-package was possible...
Done in commit 52a8302. Reverted package-lock.json changes and enhanced the implementation to perform all adapter compatibility checks (OS compatibility, nogit flag, etc.) when io-package.json is successfully fetched from GitHub, not just the nogit check.
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
spdx.org
- Triggering command:
node /home/REDACTED/work/ioBroker.js-controller/ioBroker.js-controller/node_modules/.bin/ts-node schemas/updateSchemas.ts(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to the custom allowlist in this repository's Copilot coding agent settings (admins only)