@volumio/plugin-sdk 0.0.0-stage → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +125 -2
- package/bin/volumio-plugin.js +190 -0
- package/package.json +31 -4
- package/registry/functions.json +93 -0
- package/registry/g2-baseline.json +485 -0
- package/schema/manifest.schema.json +95 -0
- package/src/audit.js +46 -0
- package/src/check.js +114 -0
- package/src/deploy.js +183 -0
- package/src/fromV1.js +54 -0
- package/src/g2/baseline.js +31 -0
- package/src/g2/gitleaks.toml +4 -0
- package/src/g2/index.js +18 -0
- package/src/g2/js.js +63 -0
- package/src/g2/rule.js +94 -0
- package/src/g2/secrets.js +85 -0
- package/src/g2/shell.js +145 -0
- package/src/index.js +3 -0
- package/src/init.js +60 -0
- package/src/licence.js +88 -0
- package/src/manifest.js +36 -0
- package/src/package.js +170 -0
- package/src/sign.js +59 -0
- package/src/socketio.js +76 -0
- package/templates/generic/AGENTS.md +60 -0
- package/templates/generic/CLAUDE.md +2 -0
- package/templates/generic/LICENSE +21 -0
- package/templates/generic/README.md +13 -0
- package/templates/generic/UIConfig.json +23 -0
- package/templates/generic/VOLUMIO_API.md +91 -0
- package/templates/generic/config.json +3 -0
- package/templates/generic/gitignore +2 -0
- package/templates/generic/i18n/strings_en.json +8 -0
- package/templates/generic/index.js +81 -0
- package/templates/generic/install.sh +4 -0
- package/templates/generic/package.json +17 -0
- package/templates/generic/test/plugin.test.js +24 -0
- package/templates/generic/test/volumio.js +29 -0
- package/templates/generic/uninstall.sh +4 -0
- package/templates/generic/volumio-plugin.json +13 -0
- package/templates/music_service/UIConfig.json +23 -0
- package/templates/music_service/catalog.json +4 -0
- package/templates/music_service/config.json +3 -0
- package/templates/music_service/i18n/strings_en.json +8 -0
- package/templates/music_service/index.js +135 -0
- package/templates/music_service/test/music.test.js +52 -0
- package/templates/music_service/test/plugin.test.js +29 -0
- package/templates/music_service/volumio-plugin.json +13 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Volumio SRL
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,126 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @volumio/plugin-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Volumio plugin manifest v2 (`volumio-plugin.json`), its JSON Schema, and the `volumio-plugin` CLI.
|
|
4
|
+
|
|
5
|
+
## A new plugin
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx --package=@volumio/plugin-sdk volumio-plugin init <dir> --id <id> --type <type> --function <function> --title <title> --description <text>
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`init` writes a plugin that runs on today's Volumio and passes every check: `volumio-plugin.json`, `index.js` (the lifecycle methods Volumio calls, each returning a kew promise), a settings page (`UIConfig.json`, `config.json`, `i18n/`), `install.sh`, tests against a fake Volumio (`npm test`), README and LICENSE (MIT). A `music_service` plugin also gets Browse, play and search: `catalog.json` holds placeholder tracks for the developer to replace with their service, `explodeUri` hands each stream URL to MPD, which then handles pause, stop and seek. Its settings page sets the name shown in Browse, and it declares the `browse-source` and `playback` permissions. Then `init` runs `npm install`, which writes the `package-lock.json` the build needs (`--skip-install` to leave it out).
|
|
12
|
+
|
|
13
|
+
### Coding agents
|
|
14
|
+
|
|
15
|
+
Every new plugin carries instructions for coding agents, so that someone who does not write code can build a plugin by asking one:
|
|
16
|
+
|
|
17
|
+
- `AGENTS.md`: the files, the commands to run after each change (`npm test`, `check`), the rules the gates enforce, what to ask the person before doing. Codex, Cursor and Copilot read it; `CLAUDE.md` loads it for Claude Code.
|
|
18
|
+
- `VOLUMIO_API.md`: the plugin API Volumio runs today (`engines.api` `"1"`): the lifecycle, kew promises, settings, the calls into Volumio, and Browse, play and search for a `music_service`.
|
|
19
|
+
|
|
20
|
+
`AGENTS.md` stays the same across plugin APIs. `VOLUMIO_API.md` is the one file that changes with the API: a test fails when the schema's `engines.api` and the file's title disagree.
|
|
21
|
+
|
|
22
|
+
The developer edits only `volumio-plugin.json`: `package` writes `name`, `version`, `description`, `license`, `engines.volumio` and `volumio_info` into the `package.json` that ships, which is what Volumio reads today. `engines.api` is `"1"`: the code follows the plugin API Volumio runs today; `"2"` is kept for framework v2.
|
|
23
|
+
|
|
24
|
+
## Checks
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npx --package=@volumio/plugin-sdk volumio-plugin check [plugin-dir ...] [--built] [--json]
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`check` runs gate G1 and exits 1 when any error is found. `--built` checks the package CI built rather than the source: a TypeScript source may keep `main` and i18n in a build folder, the built package may not. A folder without `volumio-plugin.json` is read through the v1 shim (`package.json` → `volumio_info`): the v2-only fields (`function`, `permissions`) show as `todo`, not as errors.
|
|
31
|
+
|
|
32
|
+
| Rule | Checks |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| `G1.schema` | The manifest against `schema/manifest.schema.json`. `gpio-buttons` and `volumio-stream-watchdog` were published with a hyphen in their id: for them that error is a warning |
|
|
35
|
+
| `G1.function` | `function` is in `registry/functions.json`, the closed registry moderators curate |
|
|
36
|
+
| `G1.engines` | `engines.volumio` is a semver range |
|
|
37
|
+
| `G1.file.readme` | A README exists |
|
|
38
|
+
| `G1.package-json` | A v2 source's `package.json` sets no `name`, `version` or `volumio_info`: `package` generates them from the manifest |
|
|
39
|
+
| `G1.file.license` | A LICENSE file exists; a warning for v1 plugins, which state the licence in `package.json` |
|
|
40
|
+
| `G1.main` (`--built`) | `package.json` `main` is `index.js`, as the crypter needs |
|
|
41
|
+
| `G1.file.i18n` (`--built`) | `i18n/strings_en.json` exists |
|
|
42
|
+
|
|
43
|
+
## Deploy to a device
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npx --package=@volumio/plugin-sdk volumio-plugin deploy <device> [plugin-dir] [--zip <zip>]
|
|
47
|
+
npx --package=@volumio/plugin-sdk volumio-plugin logs <device> [--seconds <n>]
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`deploy` installs a plugin on a Volumio of the local network and starts it, as the web UI would: no SSH. It builds the package as `package` does (a plugin with native modules is built for the device with `scripts/build.sh` and passed with `--zip`), serves it from this machine at an unguessable URL on the interface that reaches the device, and asks the device to install it from there. The device's live log is on while the plugin starts, and `deploy` prints it, then exits 1 if the plugin did not start.
|
|
51
|
+
|
|
52
|
+
A plugin already on the device is updated, keeping its settings. Then the device reboots: Volumio keeps running the code of a plugin it loaded once until its backend restarts, through updates and even an uninstall. `logs` prints the device's log as it is written, until Ctrl-C or `--seconds`. Both need Node 22 or later, for its built-in WebSocket; the rest of the CLI runs on Node 20.
|
|
53
|
+
|
|
54
|
+
## Function registry
|
|
55
|
+
|
|
56
|
+
`registry/functions.json` lists one entry per function: `id`, `title`, the one `plugin` kept, and the `duplicates` that move to Deprecated. `plugin: null` means Volumio has not picked one yet.
|
|
57
|
+
|
|
58
|
+
## G2: static checks
|
|
59
|
+
|
|
60
|
+
`check` also runs G2 on every JavaScript file (tests and `node_modules` excluded) and on `install.sh`.
|
|
61
|
+
|
|
62
|
+
| Rule | Checks |
|
|
63
|
+
| --- | --- |
|
|
64
|
+
| `G2.js.sync-exec` | No `execSync`, `execFileSync`, `spawnSync` |
|
|
65
|
+
| `G2.js.shell` | No `exec`, no `shell: true`: commands only as an argument list |
|
|
66
|
+
| `G2.js.process-exit`, `G2.js.global-handler` | No `process.exit` and no process-wide `uncaughtException`/`unhandledRejection` handlers, except in executables (shebang) |
|
|
67
|
+
| `G2.js.command-router-override` | No replacing `commandRouter` methods |
|
|
68
|
+
| `G2.js.console-log` | No `console.log` |
|
|
69
|
+
| `G2.shell.*` | `set -e` in the script; no `pipefail`; no `\|\| true`; no package managers, except `apt-get install` of the packages `system.apt` declares, named one by one (no variables, no local `.deb`); no download without a `sha256sum` check; no sudoers. Volumio runs `install.sh` with `sh` (dash): the shebang is ignored, so a `-e` there does not count, and dash has no `pipefail` |
|
|
70
|
+
| `G2.shellcheck.SC*` | ShellCheck warnings and errors, checked as dash, when `shellcheck` is installed (CI always has it) |
|
|
71
|
+
| `G2.secret` | No private key or service token (AWS, GitHub, Slack, Google API, Stripe) in the plugin's files; the finding names the kind, never the secret |
|
|
72
|
+
| `G2.secret.*` | gitleaks' default rules on the lines the built-in patterns did not flag, when `gitleaks` is installed (CI always has it). The plugin's `.gitleaks.toml`, `.gitleaksignore` and `gitleaks:allow` comments are ignored |
|
|
73
|
+
| `G2.audit` (`package`) | No high or critical `npm audit` advisory on the production dependencies; a warning for v1, and a warning when the audit cannot run |
|
|
74
|
+
| `G2.licence` (`package`) | Every production dependency has a licence: none, `UNLICENSED` or `SEE LICENSE IN` is an error (a warning for v1); copyleft (GPL, LGPL, AGPL) and unrecognised licences are warnings |
|
|
75
|
+
|
|
76
|
+
Inline `eslint-disable` comments, `# shellcheck` directives and `.shellcheckrc` are ignored: a plugin cannot switch a check off. `registry/g2-baseline.json` holds the violations each published plugin has today: they show as one warning per rule and file, and any new one blocks. A v1 plugin with no baseline gets warnings; a v2 plugin gets errors. Regenerate it with `node scripts/g2-baseline.js <plugins-dir>`, in the build container, which has the ShellCheck and gitleaks versions CI pins (`scripts/install-tools.sh`).
|
|
77
|
+
|
|
78
|
+
## Build
|
|
79
|
+
|
|
80
|
+
A plugin repository builds its release with the reusable workflow:
|
|
81
|
+
|
|
82
|
+
```yaml
|
|
83
|
+
jobs:
|
|
84
|
+
build:
|
|
85
|
+
uses: VolumioTeam/volumio-plugin-sdk/.github/workflows/build.yml@v0.3.1
|
|
86
|
+
with:
|
|
87
|
+
path: . # plugin folder inside the repository
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
It runs one build per architecture the manifest declares (`volumio-plugin arch`), each through `scripts/build.sh`, in the Volumio build container: Debian Bookworm, Node 20, ShellCheck from Bookworm, gitleaks pinned by version and sha256, under QEMU for ARM. The gate findings also go to the run summary, and the zips are uploaded as `<artifact>-<arch>` (`artifact` defaults to `plugin`). With `report-only: true`, gate errors are reported without failing the build; a build that cannot run still fails. Run the same build locally with Docker:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
[REPORT_ONLY=true] scripts/build.sh <plugin-dir> <armhf|amd64|arm64> [out-dir]
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
A repository with one plugin per top-level folder, like `volumio-plugins-sources-bookworm`, builds only the plugins a pull request changes: `scripts/changed-plugins.sh <base> <head>` prints them as a JSON array for a job matrix (`all` prints every plugin folder), and each one calls the workflow with its own `path` and `artifact`.
|
|
97
|
+
|
|
98
|
+
`volumio-plugin package` copies the plugin without `.git`, `.github`, `node_modules` and test folders, installs the production dependencies (after `npm run build` when the plugin has one), runs G1 `--built` and G2 on the result, and writes:
|
|
99
|
+
|
|
100
|
+
- `<id>-<version>-<arch>.zip`: files at the root, sorted, one mtime (the commit time, or `SOURCE_DATE_EPOCH`), so the same commit gives the same bytes
|
|
101
|
+
- `<zip>.sha256`
|
|
102
|
+
- `<id>-<version>-<arch>.provenance.json`: source repository and commit, workflow run, SDK version, every gate finding
|
|
103
|
+
|
|
104
|
+
It prints the findings, the zip and its sha256 on stdout (npm's output goes to stderr), and exits 1 when a gate finds an error, unless `--report-only` is given. A build that cannot run (a failing `npm install` or `npm run build`) exits 1 either way.
|
|
105
|
+
|
|
106
|
+
| Rule | Checks |
|
|
107
|
+
| --- | --- |
|
|
108
|
+
| `G3.native-arch` | Every package with `.node` modules has one built for the target architecture, and its `build/` ones all are |
|
|
109
|
+
| `G3.lockfile` | `package-lock.json` is committed; a warning for v1 plugins |
|
|
110
|
+
|
|
111
|
+
## Signing
|
|
112
|
+
|
|
113
|
+
The store signs each release it accepts: `<zip>.sig` is a [DSSE](https://github.com/secure-systems-lab/dsse) envelope whose payload (`volumio.plugin.release/v1`) binds the zip's sha256 to the plugin id, version, architecture and source commit, signed with Ed25519. The device trusts two keys, the active one and the next, so rotating the key needs no device update. `src/sign.js` (`@volumio/plugin-sdk/sign`) uses only Node's `crypto`; the device verifier follows it and is tested against envelopes it signs. Key ids use letters, digits, dot, dash and underscore.
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
volumio-plugin sign <zip> --key <private.pem> --key-id <id> # development key; the store signs with its KMS key
|
|
117
|
+
volumio-plugin verify <zip> --key <id>=<public.pem> [--key ...]
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Releasing
|
|
121
|
+
|
|
122
|
+
Bump `version` in `package.json` and the `sdk-ref` default in `.github/workflows/build.yml` together (a test fails otherwise), merge, then tag `v<version>` on `main`. Release tags cannot be moved or deleted. Plugin repositories call the workflow at a tag, never at `main`; actions are pinned by commit and the build image by digest.
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
npm test
|
|
126
|
+
```
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
4
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import { setTimeout as sleep } from 'node:timers/promises';
|
|
8
|
+
import { parseArgs } from 'node:util';
|
|
9
|
+
import { check, load } from '../src/check.js';
|
|
10
|
+
import { deploy, followLog } from '../src/deploy.js';
|
|
11
|
+
import { initPlugin } from '../src/init.js';
|
|
12
|
+
import { declaredArches, packagePlugin } from '../src/package.js';
|
|
13
|
+
import { localSigner, releaseStatement, signRelease, verifyRelease } from '../src/sign.js';
|
|
14
|
+
|
|
15
|
+
const USAGE = `Usage:
|
|
16
|
+
volumio-plugin init <dir> --id <id> --type <type> --function <function> --title <title> --description <text> [--author <name>] [--skip-install]
|
|
17
|
+
volumio-plugin check [plugin-dir ...] [--built] [--json]
|
|
18
|
+
volumio-plugin package [plugin-dir] [--out <dir>] [--report-only]
|
|
19
|
+
volumio-plugin arch [plugin-dir]
|
|
20
|
+
volumio-plugin deploy <device> [plugin-dir] [--zip <zip>]
|
|
21
|
+
volumio-plugin logs <device> [--seconds <n>]
|
|
22
|
+
volumio-plugin sign <zip> --key <private.pem> --key-id <id>
|
|
23
|
+
volumio-plugin verify <zip> --key <id>=<public.pem> [--key ...]
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
const print = (result) => {
|
|
27
|
+
const errors = result.findings.filter((f) => f.severity === 'error').length;
|
|
28
|
+
const head = `${errors ? '✖' : '✔'} ${result.id ?? result.dir}${result.source ? ` (${result.source})` : ''}`;
|
|
29
|
+
const lines = result.findings.flatMap((f) => [
|
|
30
|
+
` ${f.severity.padEnd(7)} ${f.rule} ${f.file ? `${f.file}${f.line ? `:${f.line}` : ''} ` : ''}${f.message}`,
|
|
31
|
+
...(f.fix ? [` fix: ${f.fix}`] : []),
|
|
32
|
+
]);
|
|
33
|
+
return [head, ...lines].join('\n') + '\n';
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Strict: an unknown option, or an option whose value looks like another option, is a usage error.
|
|
37
|
+
const parse = (args, options = {}) => parseArgs({ args, options, allowPositionals: true });
|
|
38
|
+
const usage = () => {
|
|
39
|
+
process.stderr.write(USAGE);
|
|
40
|
+
return 2;
|
|
41
|
+
};
|
|
42
|
+
const sha256Of = (file) => createHash('sha256').update(readFileSync(file)).digest('hex');
|
|
43
|
+
// <id>=<public.pem>
|
|
44
|
+
const trustedKey = (arg) => {
|
|
45
|
+
const i = arg.indexOf('=');
|
|
46
|
+
if (i < 1) throw new Error(`--key takes <key-id>=<public-key.pem>, got ${arg}`);
|
|
47
|
+
return [arg.slice(0, i), readFileSync(arg.slice(i + 1), 'utf8')];
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// The commit time keeps the zip reproducible; CI may set SOURCE_DATE_EPOCH instead.
|
|
51
|
+
const epochOf = (dir) => {
|
|
52
|
+
if (process.env.SOURCE_DATE_EPOCH) return Number(process.env.SOURCE_DATE_EPOCH);
|
|
53
|
+
const git = spawnSync('git', ['-C', dir, 'log', '-1', '--format=%ct'], { encoding: 'utf8' });
|
|
54
|
+
const epoch = Number(git.stdout?.trim());
|
|
55
|
+
if (!epoch) throw new Error('No commit time: run inside a git checkout or set SOURCE_DATE_EPOCH');
|
|
56
|
+
return epoch;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const env = process.env;
|
|
60
|
+
const meta = {
|
|
61
|
+
repository: env.GITHUB_REPOSITORY,
|
|
62
|
+
commit: env.GITHUB_SHA,
|
|
63
|
+
ref: env.GITHUB_REF,
|
|
64
|
+
runId: env.GITHUB_RUN_ID,
|
|
65
|
+
runAttempt: env.GITHUB_RUN_ATTEMPT,
|
|
66
|
+
workflowRef: env.GITHUB_WORKFLOW_REF,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// A reader that stops early (volumio-plugin logs | head) closes stdout: not a failure.
|
|
70
|
+
const stdoutClosed = new Promise((resolve) => {
|
|
71
|
+
process.stdout.on('error', (e) => {
|
|
72
|
+
if (e.code !== 'EPIPE' && e.code !== 'ERR_STREAM_DESTROYED') throw e;
|
|
73
|
+
resolve();
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const INIT_REQUIRED = ['id', 'type', 'function', 'title', 'description'];
|
|
78
|
+
|
|
79
|
+
const commands = {
|
|
80
|
+
init(args) {
|
|
81
|
+
const options = Object.fromEntries([...INIT_REQUIRED, 'author'].map((k) => [k, { type: 'string' }]));
|
|
82
|
+
const { values, positionals: [dir] } = parse(args, { ...options, 'skip-install': { type: 'boolean' } });
|
|
83
|
+
const missing = INIT_REQUIRED.filter((k) => !values[k]);
|
|
84
|
+
if (!dir || missing.length) {
|
|
85
|
+
if (missing.length) process.stderr.write(`Missing ${missing.map((k) => `--${k}`).join(', ')}. --function is an id from registry/functions.json\n`);
|
|
86
|
+
return usage();
|
|
87
|
+
}
|
|
88
|
+
const written = initPlugin(dir, values);
|
|
89
|
+
process.stdout.write(written.map((f) => ` ${f}\n`).join(''));
|
|
90
|
+
if (!values['skip-install']) {
|
|
91
|
+
// Writes package-lock.json, which the build needs.
|
|
92
|
+
// npm is a .cmd shim on Windows, which only a shell runs.
|
|
93
|
+
const npm = spawnSync('npm', ['install', '--no-audit', '--no-fund'], { cwd: dir, stdio: 'inherit', shell: process.platform === 'win32' });
|
|
94
|
+
if (npm.status !== 0) return 1;
|
|
95
|
+
}
|
|
96
|
+
process.stdout.write(`✔ ${values.id} in ${dir}: edit volumio-plugin.json and index.js, then npm test and volumio-plugin check\n`);
|
|
97
|
+
return 0;
|
|
98
|
+
},
|
|
99
|
+
check(args) {
|
|
100
|
+
const { values, positionals: dirs } = parse(args, { built: { type: 'boolean' }, json: { type: 'boolean' } });
|
|
101
|
+
const results = (dirs.length ? dirs : ['.']).map((dir) => check(dir, { built: values.built }));
|
|
102
|
+
process.stdout.write(values.json ? `${JSON.stringify(results, null, 2)}\n` : results.map(print).join(''));
|
|
103
|
+
return results.some((r) => r.findings.some((f) => f.severity === 'error')) ? 1 : 0;
|
|
104
|
+
},
|
|
105
|
+
package(args) {
|
|
106
|
+
const { values, positionals } = parse(args, { out: { type: 'string', default: 'dist-plugin' }, 'report-only': { type: 'boolean' } });
|
|
107
|
+
const dir = positionals[0] ?? '.';
|
|
108
|
+
const result = packagePlugin(dir, { out: values.out, epoch: epochOf(dir), meta });
|
|
109
|
+
process.stdout.write(print({ id: result.provenance.id, findings: result.provenance.gates.findings }));
|
|
110
|
+
process.stdout.write(`${result.zip}\nsha256 ${result.sha256}\n`);
|
|
111
|
+
// --report-only: gate errors are reported, not fatal; a build that cannot run still exits 1.
|
|
112
|
+
return result.ok || values['report-only'] ? 0 : 1;
|
|
113
|
+
},
|
|
114
|
+
// Installs on a device of the local network, starts the plugin, prints what it logged.
|
|
115
|
+
async deploy(args) {
|
|
116
|
+
const { values, positionals: [host, dir = '.'] } = parse(args, { zip: { type: 'string' } });
|
|
117
|
+
if (!host) return usage();
|
|
118
|
+
const loaded = load(dir);
|
|
119
|
+
if (loaded.failure) throw new Error(loaded.failure.message);
|
|
120
|
+
const plugin = { id: loaded.manifest.id, type: loaded.manifest.type };
|
|
121
|
+
// Built here, unless --zip: a plugin with native modules is built for the device by scripts/build.sh.
|
|
122
|
+
const out = values.zip ? undefined : mkdtempSync(join(tmpdir(), 'volumio-deploy-'));
|
|
123
|
+
let result;
|
|
124
|
+
try {
|
|
125
|
+
let zip = values.zip;
|
|
126
|
+
if (out) {
|
|
127
|
+
const built = packagePlugin(dir, { out, epoch: Math.floor(Date.now() / 1000) });
|
|
128
|
+
process.stdout.write(print({ id: plugin.id, findings: built.provenance.gates.findings }));
|
|
129
|
+
if (!built.ok) return 1;
|
|
130
|
+
zip = built.zip;
|
|
131
|
+
}
|
|
132
|
+
result = await deploy(host, plugin, zip, { progress: (line) => process.stdout.write(`${line}\n`) });
|
|
133
|
+
} finally {
|
|
134
|
+
if (out) rmSync(out, { recursive: true, force: true });
|
|
135
|
+
}
|
|
136
|
+
process.stdout.write(result.log);
|
|
137
|
+
process.stdout.write(result.started
|
|
138
|
+
? `✔ ${plugin.id} is running on ${host}\n`
|
|
139
|
+
: `✖ ${plugin.id} did not start on ${host}: the log above says why\n`);
|
|
140
|
+
return result.started ? 0 : 1;
|
|
141
|
+
},
|
|
142
|
+
// The device's log as it is written, until Ctrl-C or --seconds.
|
|
143
|
+
async logs(args) {
|
|
144
|
+
const { values, positionals: [host] } = parse(args, { seconds: { type: 'string' } });
|
|
145
|
+
const seconds = values.seconds === undefined ? undefined : Number(values.seconds);
|
|
146
|
+
if (!host || (seconds !== undefined && !(seconds > 0))) return usage();
|
|
147
|
+
// Ctrl-C ends it in both modes, so the device's live log is switched off again.
|
|
148
|
+
const interrupted = new Promise((resolve) => process.once('SIGINT', resolve));
|
|
149
|
+
const until = Promise.race([...(seconds ? [sleep(seconds * 1000)] : []), interrupted, stdoutClosed]);
|
|
150
|
+
await followLog(host, (text) => process.stdout.write(text), until);
|
|
151
|
+
return 0;
|
|
152
|
+
},
|
|
153
|
+
arch(args) {
|
|
154
|
+
process.stdout.write(`${JSON.stringify(declaredArches(parse(args).positionals[0] ?? '.'))}\n`);
|
|
155
|
+
return 0;
|
|
156
|
+
},
|
|
157
|
+
// A development key: the store signs releases with its KMS key.
|
|
158
|
+
sign(args) {
|
|
159
|
+
const { values, positionals: [zip] } = parse(args, { key: { type: 'string' }, 'key-id': { type: 'string' } });
|
|
160
|
+
const { key, 'key-id': keyId } = values;
|
|
161
|
+
if (!zip || !key || !keyId) return usage();
|
|
162
|
+
const provenance = JSON.parse(readFileSync(zip.replace(/\.zip$/, '.provenance.json'), 'utf8'));
|
|
163
|
+
const statement = releaseStatement({ ...provenance, sha256: sha256Of(zip) });
|
|
164
|
+
const envelope = signRelease(statement, { keyId, sign: localSigner(readFileSync(key, 'utf8')) });
|
|
165
|
+
writeFileSync(`${zip}.sig`, `${JSON.stringify(envelope, null, 2)}\n`);
|
|
166
|
+
process.stdout.write(`${zip}.sig\n`);
|
|
167
|
+
return 0;
|
|
168
|
+
},
|
|
169
|
+
verify(args) {
|
|
170
|
+
const { values, positionals: [zip] } = parse(args, { key: { type: 'string', multiple: true, default: [] } });
|
|
171
|
+
const keys = Object.fromEntries(values.key.map(trustedKey));
|
|
172
|
+
if (!zip || !Object.keys(keys).length) return usage();
|
|
173
|
+
const envelope = JSON.parse(readFileSync(`${zip}.sig`, 'utf8'));
|
|
174
|
+
const statement = verifyRelease(envelope, { keys, sha256: sha256Of(zip) });
|
|
175
|
+
process.stdout.write(`✔ ${statement.id} ${statement.version} ${statement.arch} signed by a trusted key\n`);
|
|
176
|
+
return 0;
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const [command, ...args] = process.argv.slice(2);
|
|
181
|
+
if (!commands[command]) {
|
|
182
|
+
process.exitCode = usage();
|
|
183
|
+
} else {
|
|
184
|
+
try {
|
|
185
|
+
process.exitCode = await commands[command](args);
|
|
186
|
+
} catch (e) {
|
|
187
|
+
process.stderr.write(`${e instanceof Error ? e.message : String(e)}\n`);
|
|
188
|
+
process.exitCode = String(e?.code).startsWith('ERR_PARSE_ARGS') ? usage() : 1;
|
|
189
|
+
}
|
|
190
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volumio/plugin-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "Volumio plugin manifest v2: schema, v1 shim and the volumio-plugin CLI",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"volumio-plugin": "bin/volumio-plugin.js"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./src/index.js",
|
|
11
|
+
"./schema": "./schema/manifest.schema.json",
|
|
12
|
+
"./sign": "./src/sign.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"bin",
|
|
16
|
+
"src",
|
|
17
|
+
"schema",
|
|
18
|
+
"registry",
|
|
19
|
+
"templates"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "node --test test/*.test.js"
|
|
23
|
+
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=20"
|
|
26
|
+
},
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"ajv": "^8.20.0",
|
|
30
|
+
"eslint": "^9.39.5",
|
|
31
|
+
"semver": "^7.8.6"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
[
|
|
2
|
+
{"id":"spotify-connect","title":"Spotify Connect","plugin":"spotifyconnect","duplicates":["spop","soloist_connect"]},
|
|
3
|
+
{"id":"airplay","title":"AirPlay","plugin":"airplay_emulation"},
|
|
4
|
+
{"id":"tidal","title":"TIDAL","plugin":"tidal"},
|
|
5
|
+
{"id":"tidal-connect","title":"TIDAL Connect","plugin":"tidalconnect"},
|
|
6
|
+
{"id":"qobuz","title":"Qobuz","plugin":"qobuz"},
|
|
7
|
+
{"id":"qobuz-connect","title":"Qobuz Connect","plugin":"qobuzconnect"},
|
|
8
|
+
{"id":"hi-res-audio","title":"HighResAudio","plugin":"hi_res_audio"},
|
|
9
|
+
{"id":"bluetooth-audio","title":"Bluetooth audio input","plugin":"bluetooth"},
|
|
10
|
+
{"id":"multiroom","title":"Multiroom","plugin":"multiroom"},
|
|
11
|
+
{"id":"cd-playback","title":"CD playback and ripping","plugin":"cd_controller"},
|
|
12
|
+
{"id":"roon-endpoint","title":"Roon endpoint","plugin":null,"duplicates":["raat","RoonBridge","metaroon"]},
|
|
13
|
+
{"id":"upnp-renderer","title":"UPnP renderer","plugin":"upnp"},
|
|
14
|
+
{"id":"upnp-browser","title":"UPnP and DLNA browser","plugin":"upnp_browser"},
|
|
15
|
+
{"id":"web-radio","title":"Web radio","plugin":"webradio"},
|
|
16
|
+
{"id":"alarm-clock","title":"Alarm clock and sleep timer","plugin":"alarm-clock","duplicates":["SleepWakePlugin","korean_radio_alarm"]},
|
|
17
|
+
{"id":"80s80s-radio","title":"80s80s Radio","plugin":"80s80s"},
|
|
18
|
+
{"id":"bandcamp","title":"Bandcamp","plugin":"bandcamp"},
|
|
19
|
+
{"id":"calm-radio","title":"Calm Radio","plugin":"calmradio"},
|
|
20
|
+
{"id":"controradio","title":"Controradio","plugin":"controradio"},
|
|
21
|
+
{"id":"dmd2-music","title":"DMD2 Music","plugin":null,"duplicates":["my_dmd2_music","dmd2_music"]},
|
|
22
|
+
{"id":"fm-dab-radio","title":"FM and DAB radio (RTL-SDR)","plugin":"rtlsdr_radio"},
|
|
23
|
+
{"id":"jellyfin","title":"Jellyfin","plugin":"jellyfin"},
|
|
24
|
+
{"id":"jellyfin-server","title":"Jellyfin server","plugin":"jellyfin_server"},
|
|
25
|
+
{"id":"jp-radio","title":"Japanese radio","plugin":"jp_radio"},
|
|
26
|
+
{"id":"korean-radio","title":"Korean radio","plugin":"personal_radio"},
|
|
27
|
+
{"id":"lyrion-server","title":"Lyrion Music Server","plugin":"lyrion"},
|
|
28
|
+
{"id":"dlna-server","title":"DLNA server","plugin":"minidlna"},
|
|
29
|
+
{"id":"mixcloud","title":"Mixcloud","plugin":"mixcloud"},
|
|
30
|
+
{"id":"moosbox","title":"Moosbox","plugin":"moosbox"},
|
|
31
|
+
{"id":"music-your-brand","title":"Music Your Brand","plugin":"myb"},
|
|
32
|
+
{"id":"mother-earth-radio","title":"Mother Earth Radio","plugin":"motherearthradio"},
|
|
33
|
+
{"id":"pandora","title":"Pandora","plugin":"pandora"},
|
|
34
|
+
{"id":"plex","title":"Plex","plugin":"plex"},
|
|
35
|
+
{"id":"podcasts","title":"Podcasts","plugin":"podcast"},
|
|
36
|
+
{"id":"radio-357","title":"Radio 357","plugin":"rad357pl"},
|
|
37
|
+
{"id":"radio-browser","title":"Radio Browser","plugin":"radio_browser"},
|
|
38
|
+
{"id":"radio-france","title":"Radio France","plugin":null,"duplicates":["radio_france","radio_fip"]},
|
|
39
|
+
{"id":"radio-paradise","title":"Radio Paradise","plugin":null,"duplicates":["radio_paradise","rp2"]},
|
|
40
|
+
{"id":"recently-added","title":"Recently added","plugin":"recently_added"},
|
|
41
|
+
{"id":"soundcloud","title":"SoundCloud","plugin":"soundcloud"},
|
|
42
|
+
{"id":"squeezelite","title":"Squeezelite player","plugin":"squeezelite_mc"},
|
|
43
|
+
{"id":"subsonic","title":"Subsonic","plugin":"volusonic"},
|
|
44
|
+
{"id":"youtube","title":"YouTube","plugin":"youtube2"},
|
|
45
|
+
{"id":"youtube-music","title":"YouTube Music","plugin":"ytmusic"},
|
|
46
|
+
{"id":"youtube-cast","title":"YouTube Cast receiver","plugin":"ytcr"},
|
|
47
|
+
{"id":"audio-keepalive","title":"Audio keepalive","plugin":"audio_keepalive"},
|
|
48
|
+
{"id":"dsp","title":"DSP and equaliser","plugin":"fusiondsp"},
|
|
49
|
+
{"id":"stream-out","title":"HTTP and Icecast stream output","plugin":null,"duplicates":["mpdoutput","outcast"]},
|
|
50
|
+
{"id":"cpu-shield","title":"CPU shield for audio services","plugin":"music_services_shield"},
|
|
51
|
+
{"id":"now-playing-screen","title":"Now playing screen","plugin":null,"duplicates":["now_playing","artwork_one","stylish_player"]},
|
|
52
|
+
{"id":"local-ui","title":"Volumio UI on a local screen","plugin":"touch_display"},
|
|
53
|
+
{"id":"display-setup","title":"Screen setup","plugin":null,"duplicates":["pi_screen_setup","display_configuration"]},
|
|
54
|
+
{"id":"vu-meter","title":"VU meter","plugin":"peppymeterbasic"},
|
|
55
|
+
{"id":"spectrum-meter","title":"Spectrum meter","plugin":"peppyspectrum"},
|
|
56
|
+
{"id":"oled-display","title":"Small OLED display","plugin":null,"duplicates":["just_oled","mpd_oled","oled_display_ssd1309"]},
|
|
57
|
+
{"id":"pirate-audio","title":"Pirate Audio board","plugin":null,"duplicates":["pirateaudio","pirate_audio_screensaver"]},
|
|
58
|
+
{"id":"lcd1602-display","title":"LCD1602 display","plugin":"lcd1602_vumeter"},
|
|
59
|
+
{"id":"evo-sabre-display","title":"Audiophonics EVO Sabre display","plugin":"audiophonics_evo_sabre"},
|
|
60
|
+
{"id":"raspdac-mini-display","title":"RaspDac Mini display","plugin":"raspdac_mini_lcd"},
|
|
61
|
+
{"id":"waveshare-28-panel","title":"Waveshare 2.8 inch SPI panel","plugin":"waveshare28"},
|
|
62
|
+
{"id":"system-info","title":"System information","plugin":"Systeminfo"},
|
|
63
|
+
{"id":"lastfm-scrobbler","title":"Last.fm scrobbler","plugin":"lastfm"},
|
|
64
|
+
{"id":"random-play","title":"Random play","plugin":"randomizer"},
|
|
65
|
+
{"id":"http-caller","title":"HTTP caller","plugin":"httpcaller"},
|
|
66
|
+
{"id":"ferrum-fsct","title":"Ferrum Streaming Control Technology","plugin":"ferrum_streaming_control_technology"},
|
|
67
|
+
{"id":"bluetooth-remote","title":"Bluetooth remote","plugin":"Bluetoothremote"},
|
|
68
|
+
{"id":"allo-relay-attenuator","title":"Allo Relay Attenuator","plugin":"allo_relay_attenuator"},
|
|
69
|
+
{"id":"argon-one-up","title":"Argon ONE UP","plugin":"argon_one_up"},
|
|
70
|
+
{"id":"power-button","title":"Power button","plugin":null,"duplicates":["audiophonicsonoff","gpio_button_led"]},
|
|
71
|
+
{"id":"es9018k2m-control","title":"ES9018K2M DAC control","plugin":"es9018k2m"},
|
|
72
|
+
{"id":"gpio-buttons","title":"GPIO buttons","plugin":"gpio-buttons"},
|
|
73
|
+
{"id":"gpio-outputs","title":"GPIO outputs","plugin":"gpio_control"},
|
|
74
|
+
{"id":"ir-activity-led","title":"IR activity LED","plugin":"ir_activity_led"},
|
|
75
|
+
{"id":"status-led","title":"Player status LED","plugin":"player_status_led"},
|
|
76
|
+
{"id":"ir-remote","title":"IR remote","plugin":"ir_controller"},
|
|
77
|
+
{"id":"remotepi","title":"RemotePi","plugin":"remotepi"},
|
|
78
|
+
{"id":"roseaudiosys","title":"RoseAudioSys","plugin":"roseaudiosys"},
|
|
79
|
+
{"id":"rotary-encoder","title":"Rotary encoder","plugin":"rotaryencoder2"},
|
|
80
|
+
{"id":"serial-amp-control","title":"Serial amplifier control","plugin":"serialampcontroller"},
|
|
81
|
+
{"id":"storage-manager","title":"Storage manager","plugin":"storage_manager"},
|
|
82
|
+
{"id":"resume-on-boot","title":"Resume playback after boot","plugin":"autostart"},
|
|
83
|
+
{"id":"backup-restore","title":"Backup and restore","plugin":"backup_restore"},
|
|
84
|
+
{"id":"flight-mode","title":"Flight mode","plugin":"flightmode"},
|
|
85
|
+
{"id":"library-audit","title":"Library audit","plugin":"mpdantic"},
|
|
86
|
+
{"id":"mqtt","title":"MQTT","plugin":"mqtt_client"},
|
|
87
|
+
{"id":"rpi-eeprom-config","title":"Raspberry Pi EEPROM config","plugin":"rpi_eeprom_config"},
|
|
88
|
+
{"id":"rpi-eeprom-update","title":"Raspberry Pi EEPROM update","plugin":"rpi_eeprom_updater"},
|
|
89
|
+
{"id":"scheduled-restart","title":"Scheduled restart","plugin":"scheduledrestart"},
|
|
90
|
+
{"id":"triggerhappy-restart","title":"Triggerhappy restart","plugin":"unhappy_triggerhappy"},
|
|
91
|
+
{"id":"cpu-unspike","title":"CPU unspike (Pi 4, 32-bit kernel)","plugin":"unspike"},
|
|
92
|
+
{"id":"stream-watchdog","title":"Stream watchdog","plugin":"volumio-stream-watchdog"}
|
|
93
|
+
]
|