Meteor run standalone command, library sharing

Django has a notion of building commands that can be run with the django harness/shell, so you could make a command that would have access to all the django framework, and run via the command line. I’ve looked at the meteor shell but can’t see a way to clearly do something like

% meteor shell run_this_script.js

And “run_this_script.js” would look like any server side meteor js.

Apologies for such an open ended question , but am looking for ways to import, ingest, analyze data in the app, “outside” of the actual app in separate etl like app.

Also, is there a standard design practice on how to design a node library/module that can be shared across running as a regular “node” script and used in meteor? Given the “require” differences, it has been tripping me up how to share existing libraries and design new ones well that can be used by different projects.

This might be similar to what I want to do. I’d like to get info about the app during app-build-time to perform some build steps (you might perform something else), before anything runs for the actual server and client sides. When I find out how to accomplish what I want, it’ll be in the rocket:module package.

yeah, so basically building out a bunch of meteor “server” call methods, but these methods should be part of a library that i’d like to be able to use with other node applications.

so how would one do something like this, assuming we have a “foo” module with this terrible implementation, how would one expose the “getting_foo()” method, to both Meteor apps And a node run_foo.js that wanted to share that implementation. Now I’m stuck building a “pure node” library and a Meteor one and just copying code and it sucks (and I do for doing it ;-))

var something_else = Meteor.npmRequire(‘other_lib’);

function getting_foo(){
return “doing something foo-ish”;;
}

Meteor.methods({
get_foo:function(){ return getting_foo() }
})

That’s exactly what I aim to solve with rocket:module! Here’s more info in this post.

The basic idea would that you write your library in a normal node type way (f.e. using CommonJS modules) then rocket:module will let you import it from npm into your Meteor project. This is good because then you can do

var something_else = require('other_lib');

instead of

var something_else = Meteor.npmRequire('other_lib');

in your library code, so it’s more portable, and not limited to the Meteor ecosystem.

1 Like

joe,

sounds good, i’d use it as well…will check it out. this seems like a requirement, and non-starter for projects that rely on node, but aren’t all web/meteor based, and need to share code/libraries easily.

rich

1 Like