yanpm
v1.2.0
Published
Yet Another Node Plugin/Package Manager
Downloads
27
Maintainers
Readme
yanpm - Yet Another Node Plugin/Package Manager
Description
Gives your node app/server the "Ya!" that it needs!
Better Description
Config based Plugin manager to load dependencies at run time. This allows for frameworks (e.g. yanpm) to have default core plugins that swapped out later but without added bloat.
TODO
[ ] run sync mode
[?] better name
[ ] logo
[?] change to singleton
[ ] smart install, to prevent git repo from auto resintall every time it's ran
[ ] only require modules on .get
[ ] better Readme
[ ] move require remove cache utils to it's own project
[ ] website
v1.0.0 - Release
[x] npm 3+ support
[x] remove npm module as dependancy
[x] Hide/Handle NPM console message
[x] promise style return on .install (use to be .load)
[x] proper private repo support
using install
var yanpm = require('yanpm');
var plugin = new yanpm();
plugin
.install('lodash')
.then(function(){
console.log('Done loading plugins');
var _ = plugin.get('lodash');
console.log("lodash version:", _.VERSION);
});
using add
var yanpm = require('yanpm');
var plugin = new yanpm();
plugin
.add(['lodash', 'stumpy'])
.install()
.then(function(){
console.log('Done loading plugins');
var _ = plugin.get('lodash');
console.log("lodash version:", _.VERSION);
});
yanpm config
var yanpm = require('yanpm');
var stumpy = require('stumpy');
var plugin = new yanpm({
cwd: './', // current dir yanpm will use for the installs
logger: new stumpy()); // logger yanpm will use
});
// WARN!
// yanpm uses your current NPM under the hood
// in some cases when trying to install in a dir
// if "package.json" is missing npm will search up the tree
plugin
.install('_', 'lodash'])
.then(function(){
console.log('Done loading plugins');
var _ = plugin.get('_');
console.log("lodash version:", _.VERSION);
});
More complex usage:
plugin
.add("logger", "[email protected]")
.add("template", "ejs", "yanpm-ejs")
.add("template", "handlebars", "yanpm-handlebars");
plugin
.add([{
"name": "logger",
"group": "util",
"package": "[email protected]",
"factory": function (Stumpy) { return new Stumpy(); }
}]);
Other Supported Formats:
plugin
.add("lodash") // get latest
.add("[email protected]") // get specific version
.add("_", "[email protected]")
.add("util", "_", "[email protected]")
.add("util", ["lodash", "moment"])
.add("util", [{
"name": "logger1",
"package": "[email protected]",
"factory": function (Stumpy) { return new Stumpy(); }
}])
.add("util", { "logger2": {
"package": "stumpy",
"factory": function (Stumpy) { return new Stumpy(); },
"arguments": [
"Logger2",
{
showTrace: true,
showLogId: true,
showLogType: true
}
]
})
.add(["lodash", "moment"])
.add([
{
"group": "util",
"name": "logger1",
"package": "[email protected]",
"factory": function (Stumpy) { return new Stumpy(); }
}
])
.add({
"util": "lodash"
})
.add({
"util": [ "lodash" ]
})
.add({
"util": {
"logger2": {
"package": "stumpy",
"factory": function (Stumpy) { return new Stumpy(); },
"arguments": [
"Logger2",
{
showTrace: true,
showLogId: true,
showLogType: true
}
]
}
}
});
Even more examples:
plugin
.add([
{
"name": "logger",
"group": "util",
"package": "[email protected]",
"factory": function (Stumpy) { return new Stumpy(); }
},
'lodash.json', // load file data
'./stumpy.js' // load file data
]);