Closed benfrancis closed 1 year ago
I don't think this change was actually intentional, comments in the code imply that extension add-ons should not require an exec
member.
Error reported after manual install of square theme add-on:
022-12-07 08:35:45.430 ERROR : Failed to load add-on square-theme: Error: Error found in manifest for add-on square-theme: Manifest is missing: gateway_specific_settings.webthings.exec
at loadManifestJson (/home/pi/webthings/gateway/build/addon-utils.js:219:15)
at Object.loadManifest (/home/pi/webthings/gateway/build/addon-utils.js:278:16)
at AddonManager.loadAddon (/home/pi/webthings/gateway/build/addon-manager.js:547:44)
at fs_1.default.readdir (/home/pi/webthings/gateway/build/addon-manager.js:635:22)
at FSReqWrap.args [as oncomplete] (fs.js:140:20)
2022-12-07 08:35:45.611 INFO : Checking for add-on updates...
This error appears to be reported by this line of addon-utils.ts https://github.com/WebThingsIO/gateway/blob/master/src/addon-utils.ts#L69
Assuming this isn't due to manual installation, this may be a bug.
This regression may have been caused by https://github.com/WebThingsIO/gateway/pull/2755/files#diff-f39bb9687c1b1ec0a90ab3a5817fc488415f9a94305f1dd32ff76f0df77d2f40R92
It adds the exec
member to manifestTemplate
, which all manifests are checked against.
The value is set to '' if it doesn't exist, but only if the primary type of the add-on is not "extension", which in this case it is.
Note to self: If I revert the added line in the object literal which defines exec: ''
I get an error:
src/addon-utils.ts:125:58 - error TS2339: Property 'exec' does not exist on type '{ primary_type: string; }'.
If I comment out line 125:
manifestTemplate.gateway_specific_settings.webthings.exec = '';
then the square theme add-on will install successfully, but presumably that will break validation for add-ons which aren't extensions.
In the TypeScript re-write for 1.1 a change was made that made the exec member of add-on manifests mandatory.
This means it's no longer possible to create an extension add-on which is just CSS and JavaScript content with no back end executable.
We should consider making exec optional again to allow extension add-ons (e.g the square theme).