mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Initial plugin runtime api implementation
This commit is contained in:
@@ -220,33 +220,41 @@ function getModuleNodeFiles(module) {
|
||||
var moduleDir = module.dir;
|
||||
var pkg = module.package;
|
||||
|
||||
var nodes = pkg['node-red'].nodes||{};
|
||||
var results = [];
|
||||
var iconDirs = [];
|
||||
var iconList = [];
|
||||
for (var n in nodes) {
|
||||
/* istanbul ignore else */
|
||||
if (nodes.hasOwnProperty(n)) {
|
||||
var file = path.join(moduleDir,nodes[n]);
|
||||
results.push({
|
||||
file: file,
|
||||
module: pkg.name,
|
||||
name: n,
|
||||
version: pkg.version
|
||||
});
|
||||
var iconDir = path.join(moduleDir,path.dirname(nodes[n]),"icons");
|
||||
if (iconDirs.indexOf(iconDir) == -1) {
|
||||
try {
|
||||
fs.statSync(iconDir);
|
||||
var icons = scanIconDir(iconDir);
|
||||
iconList.push({path:iconDir,icons:icons});
|
||||
iconDirs.push(iconDir);
|
||||
} catch(err) {
|
||||
|
||||
function scanTypes(types) {
|
||||
const files = [];
|
||||
for (var n in types) {
|
||||
/* istanbul ignore else */
|
||||
if (types.hasOwnProperty(n)) {
|
||||
var file = path.join(moduleDir,types[n]);
|
||||
files.push({
|
||||
file: file,
|
||||
module: pkg.name,
|
||||
name: n,
|
||||
version: pkg.version
|
||||
});
|
||||
var iconDir = path.join(moduleDir,path.dirname(types[n]),"icons");
|
||||
if (iconDirs.indexOf(iconDir) == -1) {
|
||||
try {
|
||||
fs.statSync(iconDir);
|
||||
var icons = scanIconDir(iconDir);
|
||||
iconList.push({path:iconDir,icons:icons});
|
||||
iconDirs.push(iconDir);
|
||||
} catch(err) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
var result = {files:results,icons:iconList};
|
||||
|
||||
var result = {
|
||||
nodeFiles:scanTypes(pkg['node-red'].nodes||{}),
|
||||
pluginFiles:scanTypes(pkg['node-red'].plugins||{}),
|
||||
icons:iconList
|
||||
};
|
||||
|
||||
var examplesDir = path.join(moduleDir,"examples");
|
||||
try {
|
||||
@@ -396,6 +404,7 @@ function convertModuleFileListToObject(moduleFiles) {
|
||||
local: moduleFile.local||false,
|
||||
user: moduleFile.user||false,
|
||||
nodes: {},
|
||||
plugins: {},
|
||||
icons: nodeModuleFiles.icons,
|
||||
examples: nodeModuleFiles.examples
|
||||
};
|
||||
@@ -408,11 +417,14 @@ function convertModuleFileListToObject(moduleFiles) {
|
||||
if (moduleFile.usedBy) {
|
||||
nodeList[moduleFile.package.name].usedBy = moduleFile.usedBy;
|
||||
}
|
||||
nodeModuleFiles.files.forEach(function(node) {
|
||||
node.local = moduleFile.local||false;
|
||||
nodeModuleFiles.nodeFiles.forEach(function(node) {
|
||||
nodeList[moduleFile.package.name].nodes[node.name] = node;
|
||||
nodeList[moduleFile.package.name].nodes[node.name].local = moduleFile.local || false;
|
||||
});
|
||||
nodeModuleFiles.pluginFiles.forEach(function(plugin) {
|
||||
nodeList[moduleFile.package.name].plugins[plugin.name] = plugin;
|
||||
nodeList[moduleFile.package.name].plugins[plugin.name].local = moduleFile.local || false;
|
||||
});
|
||||
});
|
||||
return nodeList;
|
||||
}
|
||||
|
Reference in New Issue
Block a user