Skip to main content

Plugin rules

BetaThe plugin SDK and these pages are new. They change with each release, as developers use them and tell us what works.View as Markdown

Every Volumio plugin follows these rules. Each rule names the check that enforces it. Checks whose id starts with G1, G2 or G3 run in volumio-plugin check and on every pull request. The others belong to gates that do not run yet, so a moderator checks those rules in review. From pull request to store describes the gates.

Draft

These rules are a draft. Tell us what is wrong, missing or unclear in the Plugins forum.

Principles​

Every rule comes from one of these principles.

PrincipleWhat it means
One plugin per functionA device never runs two plugins that do the same job. When a plugin for your function exists, improve it. Volumio does not enforce this rule yet.
Propose before you buildA new plugin starts with a short proposal in the forum: what it does, its function, the services it calls. You can build while the proposal is discussed.
Volumio stays upA plugin never crashes Volumio, even when its service stops working or the network is not ready. It reports the error, retries when the network is back, and stops cleanly.
Only add, never modifyA plugin adds files and packages of its own. It never changes what ships in the Volumio image, nor another plugin's files. Uninstall removes exactly what install added.
Everything in the packageDependencies ship inside the plugin, built for each architecture. System packages come only from APT.
Declare what you doEvery host, system package, service, file outside the plugin folder and permission is listed in volumio-plugin.json.
Built by VolumioThe package users install is built by Volumio's CI from your pull request. Installing by hand or over SSH is for development only.
Checks, not opinionsEvery rule has a check that says how to fix it. A plugin cannot switch a check off.
Plain for usersEvery text the user sees is translatable, with English first. Settings use Volumio's settings page.

Manifest​

RuleCheckRuns today
The plugin has a volumio-plugin.json that matches the schema, with no other fieldsG1.schemaYes
function is an entry of the function registry. A function outside it is a warningG1.functionYes
engines.volumio is a semver range, and engines.api is "1"G1.engines, G1.schemaYes
package.json sets no name, version or volumio_info. The build writes them from the manifestG1.package-jsonYes
The plugin has a README and a LICENSE fileG1.file.readme, G1.file.licenseYes
The built package has main set to index.js, and an i18n/strings_en.jsonG1.main, G1.file.i18nYes
Every host the plugin connects to, streams included, is listed in networkG4No
version (semver) goes up with each releaseReviewYes

Code​

RuleCheckRuns today
Log with this.logger, never console.logG2.js.console-logYes
Run a program with execFile or spawn and its arguments as a list. No exec, no shell: true. A value from the settings never reaches a shellG2.js.shellYes
No blocking calls: no execSync, execFileSync or spawnSync, no synchronous network calls. They freeze playback and the UIG2.js.sync-exec; network calls: G8Yes
No process.exit, and no process-wide uncaughtException or unhandledRejection handlersG2.js.process-exit, G2.js.global-handlerYes
Never replace a Volumio method (this.commandRouter.something = ...)G2.js.command-router-overrideYes
No private key or service token in any file. A key the service needs is typed by the user in the settingsG2.secretYes
Inline eslint-disable comments, # shellcheck disable directives and .shellcheckrc are ignoredAll gatesYes
A long-running program runs as a systemd unit the plugin declares in system.services, never as a child process of the pluginG8No
No password piped into sudo (echo volumio | sudo -S)G8No

install.sh​

RuleCheckRuns today
POSIX sh, because Volumio runs it with dash: set -e, no pipefail, no || true, no ShellCheck warningsG2.shell.*, G2.shellcheck.*Yes
System packages only as apt-get install -y <package>, each named in full and listed in system.apt. No npm, pip, dpkg or local .debG2.shell.package-managerYes
Every download is checked with sha256sum -cG2.shell.downloadYes
Never write a sudoers ruleG2.shell.sudoersYes
Never change, overwrite or remove a file or package that ships in the Volumio image (/boot, /etc/asound.conf, mpd.conf and the like), nor another plugin's filesG4No
Uninstall removes exactly what install added, and nothing elseG4No

Dependencies​

RuleCheckRuns today
package-lock.json is committedG3.lockfileYes
No high or critical npm audit advisory in the production dependenciesG2.auditYes
Every production dependency has a licence. GPL-family and unknown licences are flaggedG2.licence.*Yes
Dependencies ship inside the package. Native modules are built for every architecture in archG3.native-archYes
Nothing is downloaded at runtime without a pinned version and a checksumG4, G8No

Plugin API​

RuleCheckRuns today
Every method Volumio calls returns a kew promise: no async method, no native PromiseG7No
onVolumioStart and onStart resolve within seconds and do long work afterwards. At boot Volumio waits 30 seconds for all pluginsG5No
The plugin acts only between onStart and onStop. onStop releases everything: timers, sockets, child processes, Browse entriesG5No
Call only the command router methods the plugin API lists, and never require Volumio's own filesG8No
Every text the user sees is an i18n key, with English always present. No placeholder title, description or READMEG8No
A music_service's URIs start with music_service/<id>. search never rejects and puts a time limit on each requestG7No
The plugin does not depend on the network being ready at start. A login retries when the network is backG5No

Audio​

RuleCheckRuns today
A plugin that changes the audio path passes Volumio's audio test with Fusion DSP on, in every audio formatG6No
A plugin that shows a spectrum or a VU meter uses Volumio's analyzer module, once Volumio publishes itReviewNo

Behaviour on a device​

RuleCheckRuns today
Installing the plugin changes on the device only what the manifest declares: packages, files, services, hostsG4No
The plugin survives a lost network or a service that stops answering, without taking Volumio down. No process is left after stopG5No
An audio plugin plays audio correctlyG6No
The plugin installs, plays, updates and uninstalls on each Volumio product familyG7No
The plugin reaches the quality score for its code, error handling, settings page, network use and disk useG8No

Publishing​

RuleCheckRuns today
Every release goes through a pull request to the sources repository. Volumio's CI builds it and Volumio publishes itCINo
A plugin that needs an account or a token comes with test credentials, sent privatelyReviewYes

Plugins already in the store​

A plugin published before these rules gets warnings, not errors, for the problems it had when the rules arrived. Any new problem is an error. A plugin with only a package.json gets warnings where a plugin with volumio-plugin.json gets errors.

Was this page helpful?