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

View File

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