@node-red/registry 4.1.1 → 4.1.2

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/lib/index.js CHANGED
@@ -316,6 +316,7 @@ module.exports = {
316
316
 
317
317
  registerPlugin: plugins.registerPlugin,
318
318
  getPlugin: plugins.getPlugin,
319
+ getPluginInfo: plugins.getPluginInfo,
319
320
  getPluginsByType: plugins.getPluginsByType,
320
321
  getPluginList: plugins.getPluginList,
321
322
  getPluginConfigs: plugins.getPluginConfigs,
package/lib/plugins.js CHANGED
@@ -77,8 +77,14 @@ function getPluginConfigs(lang) {
77
77
  function getPluginConfig(id, lang) {
78
78
  let result = '';
79
79
  let moduleConfigs = registry.getModuleList();
80
- if (moduleConfigs.hasOwnProperty(id)) {
81
- result = generateModulePluginConfig(moduleConfigs[id]);
80
+ const module = registry.getModuleFromSetId(id);
81
+ if (moduleConfigs.hasOwnProperty(module)) {
82
+ const name = registry.getNodeFromSetId(id);
83
+ const config = moduleConfigs[module].plugins[name];
84
+ if (config && config.enabled && !config.err && config.config) {
85
+ result += "\n<!-- --- [red-plugin:" + config.id + "] --- -->\n";
86
+ result += config.config;
87
+ }
82
88
  }
83
89
  return result;
84
90
  }
@@ -98,6 +104,34 @@ function generateModulePluginConfig(module) {
98
104
  return result;
99
105
  }
100
106
 
107
+ function getPluginInfo(typeOrId) {
108
+ let id = typeOrId;
109
+ if (pluginToId.hasOwnProperty(typeOrId)) {
110
+ id = pluginToId[typeOrId];
111
+ }
112
+
113
+ if (id) {
114
+ const moduleConfigs = registry.getModuleList();
115
+ const module = moduleConfigs[registry.getModuleFromSetId(id)];
116
+ if (module) {
117
+ const config = module.plugins[registry.getNodeFromSetId(id)];
118
+ if (config) {
119
+ const info = registry.filterNodeInfo(config);
120
+ if (config.hasOwnProperty("loaded")) {
121
+ info.loaded = config.loaded;
122
+ }
123
+ if (module.pending_version) {
124
+ info.pending_version = module.pending_version;
125
+ }
126
+
127
+ info.version = module.version;
128
+ return info;
129
+ }
130
+ }
131
+ }
132
+ return null;
133
+ }
134
+
101
135
  function getPluginList() {
102
136
  var list = [];
103
137
  var moduleConfigs = registry.getModuleList();
@@ -203,6 +237,7 @@ module.exports = {
203
237
  init,
204
238
  registerPlugin,
205
239
  getPlugin,
240
+ getPluginInfo,
206
241
  getPluginsByType,
207
242
  getPluginConfigs,
208
243
  getPluginConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-red/registry",
3
- "version": "4.1.1",
3
+ "version": "4.1.2",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./lib/index.js",
6
6
  "repository": {
@@ -16,7 +16,7 @@
16
16
  }
17
17
  ],
18
18
  "dependencies": {
19
- "@node-red/util": "4.1.1",
19
+ "@node-red/util": "4.1.2",
20
20
  "clone": "2.1.2",
21
21
  "fs-extra": "11.3.0",
22
22
  "semver": "7.7.1",