Skip to content

Instantly share code, notes, and snippets.

@jonnor
Created November 6, 2014 17:46
Show Gist options
  • Save jonnor/6d8f2f3fee946a6c3104 to your computer and use it in GitHub Desktop.
Save jonnor/6d8f2f3fee946a6c3104 to your computer and use it in GitHub Desktop.
NoFlo list components and metadata
var noflo = require('noflo');
var rootdir = './';
var loader = new noflo.ComponentLoader(rootdir);
loader.listComponents(function() {
console.log(loader.components);
Object.keys(loader.components).forEach(function(name) {
loader.load(name, function(component) {
console.log(name);
console.log(component.description);
// for each port, should look at the .options key
// it has "description, type, datatype etc"
console.log(component.inPorts);
console.log(component.outPorts);
});
});
});
@nahoskins
Copy link

Returns the following from noflo-core

{ Graph: '/home/nahoskins/noflo/components/noflo-core/node_modules/noflo/src/components/Graph.coffee',
  'core/Callback': '/home/nahoskins/noflo/components/noflo-core/components/Callback.coffee',
  'core/Copy': '/home/nahoskins/noflo/components/noflo-core/components/Copy.coffee',
  'core/DisconnectAfterPacket': '/home/nahoskins/noflo/components/noflo-core/components/DisconnectAfterPacket.coffee',
  'core/Drop': '/home/nahoskins/noflo/components/noflo-core/components/Drop.coffee',
  'core/Group': '/home/nahoskins/noflo/components/noflo-core/components/Group.coffee',
  'core/Kick': '/home/nahoskins/noflo/components/noflo-core/components/Kick.coffee',
  'core/MakeFunction': '/home/nahoskins/noflo/components/noflo-core/components/MakeFunction.coffee',
  'core/Merge': '/home/nahoskins/noflo/components/noflo-core/components/Merge.coffee',
  'core/Output': '/home/nahoskins/noflo/components/noflo-core/components/Output.coffee',
  'core/ReadEnv': '/home/nahoskins/noflo/components/noflo-core/components/ReadEnv.coffee',
  'core/ReadGlobal': '/home/nahoskins/noflo/components/noflo-core/components/ReadGlobal.coffee',
  'core/Repeat': '/home/nahoskins/noflo/components/noflo-core/components/Repeat.coffee',
  'core/RepeatAsync': '/home/nahoskins/noflo/components/noflo-core/components/RepeatAsync.coffee',
  'core/RepeatDelayed': '/home/nahoskins/noflo/components/noflo-core/components/RepeatDelayed.coffee',
  'core/RunInterval': '/home/nahoskins/noflo/components/noflo-core/components/RunInterval.coffee',
  'core/RunTimeout': '/home/nahoskins/noflo/components/noflo-core/components/RunTimeout.coffee',
  'core/SendNext': '/home/nahoskins/noflo/components/noflo-core/components/SendNext.coffee',
  'core/Split': '/home/nahoskins/noflo/components/noflo-core/components/Split.coffee' }
Graph

@nahoskins
Copy link

I gather I am noding wrong.

@jonnor
Copy link
Author

jonnor commented Nov 7, 2014

@nahoskins that is the printout of the components. Some time later (depending on how fast your harddrive is) you should get info per component

@jonnor
Copy link
Author

jonnor commented Nov 7, 2014

you seem to be running it from NoFlo itself, could be that the "Graph" there is causing a problem?

@JamesHagerman
Copy link

Here's an updated version. Apparently, the load() method's first parameter is returned as null... no idea why that changed but whatever:

var rootdir = './';
var loader = new noflo.ComponentLoader(rootdir);
loader.listComponents(function() {
  console.log(loader.components);

  Object.keys(loader.components).forEach(function(name) {
    loader.load(name, function(derp, component) {
      console.log(name);
      console.log(component.description);

      // for each port, should look at the .options key
      // it has "description, type, datatype etc"
      console.log(component.inPorts);
      console.log(component.outPorts);
    });
  });

});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment