Record runtime-installed modules in .config.modules.json

This commit is contained in:
Nick O'Leary 2021-07-14 23:13:52 +01:00
parent 395b499856
commit ddb715d88d
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 9 additions and 7 deletions

View File

@ -125,8 +125,6 @@ function importModule(module) {
return import(moduleFile);
}
function parseModuleName(module) {
var match = /((?:@[^/]+\/)?[^/@]+)(?:@([\s\S]+))?/.exec(module);
if (match) {
@ -254,6 +252,9 @@ async function installModule(moduleDetails) {
return hooks.trigger("postInstall", triggerPayload)
}).then(() => {
log.info(log._("server.install.installed", { name: installSpec }));
const runtimeInstalledModules = settings.get("modules") || {};
runtimeInstalledModules[moduleDetails.module] = moduleDetails;
settings.set("modules",runtimeInstalledModules)
}).catch(result => {
var output = result.stderr || result.toString();
var e;
@ -275,10 +276,10 @@ async function installModule(moduleDetails) {
}
module.exports = {
init: init,
register: register,
registerSubflow: registerSubflow,
checkFlowDependencies: checkFlowDependencies,
init,
register,
registerSubflow,
checkFlowDependencies,
require: requireModule,
import: importModule
}

View File

@ -20,7 +20,7 @@ const fspath = require("path");
const log = require("@node-red/util").log;
const util = require("./util");
const configSections = ['nodes','users','projects'];
const configSections = ['nodes','users','projects','modules'];
const settingsCache = {};
@ -59,6 +59,7 @@ async function migrateToMultipleConfigFiles() {
* - .config.nodes.json - the node registry
* - .config.users.json - user specific settings (eg editor settings)
* - .config.projects.json - project settings, including the active project
* - .config.modules.json - external modules installed by the runtime
* - .config.runtime.json - everything else - most notable _credentialSecret
*/
function writeSettings(data) {