ioBroker / ioBroker.js-controller

ioBroker controller
http://iobroker.net
MIT License
294 stars 58 forks source link

[enhancement]: Allow to install adapters which are scoped packages (Vendor-feature) #2942

Open foxriver76 opened 4 days ago

foxriver76 commented 4 days ago

No existing issues.

Description

Currently adapters cannot be published as scoped packages because the controller cannot handle it. We could allow to also install scoped packages.

Why?

If I as a ioBroker consultant want to provide packages which are not public available to my customer, the way to go nowadays is to use a private registry, likely GitHub packages. Then some would create a scope for their customer or org and the customer should get access to all the adapters (packages) inside this scope. Hence, scoped packages are the way to go.

On the customer you would just need to put an .npmrc file in home/iobroker/ with a token with read access to the scope. Then if the customer has configured a repo containing this adapter it will show up in admin and will be installable.

Minimal Example: https://www.moritz-heusinger.de/static/repositories/fleck.json see packetName attribute.

In general this feature should never be used in the official stable and beta repository as there is no necessarity for scoped packages!

How?

We could allow e.g. a packetName attribute in the repository which represents the real package name (with scope) andon install simply alias it to the normal package name.

Downsides:

mcm1957 commented 4 days ago

This will introduce a problem with naming scope.

Currently ioBroker.myadapter package name guarantees that exactly one adapter named myadapter can exist due to naming rules on github. Inventing scoped names we will run into the situation that

ioBroker.shelly @foxriver76/ioBroker.shelly @mypersonal/ioBroker.shelly

might exist at npm. No idea how to handle this situation. Maybe we would need to create some registration database or something like this.

In addition all tools / checkers must be extended to handle scoped packages. (But thats not a problem only work to be planned and done)

foxriver76 commented 4 days ago

It is really a vendor-specific feature, these repos cannot be checked as they are likely not be publicly available and probably are for one single user or company. Naming issues in general yes, but on repo level one will be the applied one (multi repo feature). We will refine this ticket in the next core meeting so lets see.

mcm1957 commented 4 days ago

One solution without changes could eventualkly be to use a normal adapter environment BUT to put the real code into a dependent scoped package. This way no changes to ioBroker would be required but user could not install the adapter unless they have access to the scoped package. main.js in standard could simply do nothing but log a message and / or call into the scoped and hence protected pacakge.

Eventually io-package.json could be extended to allow admin / js-controlelr to check and output a clear messages instead of crashing due to insufficiengt access righgts to dependent package.

mcm1957 commented 4 days ago

Naming issues in general yes, but on repo level one will be the applied one (multi repo feature). We will refine this ticket in the next core meeting so lets see.

As long as iob install @foxriver76/ioBroker.shelly or something like this as possible users will use it to fork variants and this will be suggested at forum for sure. We should consider this and eventually restrict in some way.

Maybe we could / should enforce that the scope name is part of the adapter name?

In general I see the usages and I understand that this is required for a commercial environement.

foxriver76 commented 4 days ago

Scoped packages are not meant for users, no scoped package should ever be in an official beta or stable repo see initial post.

In general this feature should never be used in the official stable and beta repository as there is no necessarity for scoped packages!

This is a very specific case. In general, the feature is not a feature anyone would care about except from someone who writes an adapters which is meant for a single company. I would not allow to set packetName in the official repo which users are using!

As long as iob install @foxriver76/ioBroker.shelly

it won't be possible! See https://github.com/ioBroker/ioBroker.js-controller/pull/2943/files as a proposed implementation, it only works if the packetName is specified, as long as we do not allow this to be set in official repos all good.