hi all, if I want to test making plugins as a package, is that code in the master branch on github?
baudehlo
yes. I haven't tried it though so you're in a bit of a no mans land.
bmonty
that’s fine
I’m planning on replacing my current private mail setup with haraka and I’m working on a plugin to do auth against mongo
cek has quit
cek joined the channel
so, haraka can’t load a plugin if the module is installed in the directory created with “haraka -i”
baudehlo
There may be bugs around that.
You may be best off waiting for ultimatt to arrive - he's the one who updated the plugin code to allow for node_modules to work.
(he's US west coast)
bmonty
sounds good
I’m taking a look at making a patch, but if it’s already done I can wait
dopesong_ has quit
EyePulp joined the channel
well, I made it work…but it’s a real hack job
bmonty has quit
DoubleMalt has quit
bmonty joined the channel
ultimatt joined the channel
teknix_ joined the channel
JinOz has quit
JinOz joined the channel
EyePulp
yo ho ho
quick question on access.domains - how does the parsing work if I have a few blank lines, some # comments, a few lines of domain rules and then repeat the pattern a few times? Does it care about the blanks/comments in the middle of the file (my read of the source says it doesn't)
ultimatt
no, it doesn't
care about blank / empty lines
EyePulp
danke
ultimatt
bitte
bmonty joined the channel
bmonty
ultimatt: are you working on anything to load plugins from modules stored in the node_modules folder of a haraka config directory?
ultimatt
bmonty: no
dopesong joined the channel
that could be interesting...rather than stuffing modules into plugin dir
and ~haraka/plugins
bmonty
that’s what I was thinking
baudehlo mentioned you may have been working on it
ultimatt
what I've added is making haraka/plugins a bit more like npm
in that now haraka/plugins/plugin_name can be a dir instead of a file
ie, haraka/plugins/plugin_name/index.js
and there's an open PR to increase that support, to also look for a package.json file and follow it's directives
so that plugins could be "npm installed"
which I think works better than having Haraka depend on globally installed modules
well, the goal here is to make our plugin logic simpler
so that ./plugins or ../node_modules/ will load a npm module
and obey the *same* rules as npm module
bmonty
the code at the top of plugins._load_and_compile_plugin is the problem I think
ultimatt
which means that within a npm package, we'll honor dir/index.js, or dir/bin.js, or whatever package.json points to
bmonty
it only looks for a .js file
ultimatt
right, but what if my npm package is foo/bar.js?
bmonty
I think it could be modified to try for the package.json instead of .js
require knows how to read the package.json
loading the module isn’t really the issue…it’s getting haraka to think the module exists :)
ultimatt
actually, both are issues
if _get_plugin_paths() is modified to add ../node_modules
then the only issue remaining is making sure we follow npm semantics
_smf_
bmonty/ultimatt: I just checked; bmonty is right. If you do a: var foo = require('./foo') and 'foo' is a directory containing index.js then it reads index.js
ultimatt
_smf_, I know, I made that change.
but what about when the file isn't named index.js, and isn't named package/package.js?
that's when npm module loading will fail
and that's when we want to read package.json and follow the 'bin' directive
or 'main'
basically, obey the same semantics as 'read-package-json'
_smf_
ultimatt: it's main, not bin.
bin is what npm installes in the bin directory
ultimatt
right
_smf_
Ok - bmonty is right; require() honours package.json
I've just tried it.
If you create foo/package.json and add main: 'lib/foo.js'
bmonty
I was just looking for the reference on that
I know I read it earlier today
_smf_
Then create the necessary directories and file; doing a require('./foo') will read package.json, find main and then load lib/foo.js