Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

yanpm

1.2.0 • Public • Published

yanpm - Yet Another Node Plugin/Package Manager

Build Status Coverage Status License

Dependency Status devDependency Status NPM

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",   "stumpy@0.6.x")
    .add("template", "ejs",        "yanpm-ejs")
    .add("template", "handlebars", "yanpm-handlebars");
 
plugin
    .add([{
         "name": "logger",
         "group": "util",
         "package": "stumpy@0.6.x",
         "factory": function (Stumpy) { return new Stumpy(); }
     }]);

Other Supported Formats:

plugin
     .add("lodash") // get latest
    
     .add("lodash@3.5.0") // get specific version
    
     .add("_", "lodash@3.5.0")
    
     .add("util", "_", "lodash@3.5.0")
    
     .add("util", ["lodash", "moment"])
     .add("util", [{
         "name": "logger1",
         "package": "stumpy@0.6.x",
         "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": "stumpy@0.6.x",
            "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": "stumpy@0.6.x",
        "factory": function (Stumpy) { return new Stumpy(); }
    },
    'lodash.json', // load file data
    './stumpy.js'  // load file data
    ]);

Install

npm i yanpm

DownloadsWeekly Downloads

3

Version

1.2.0

License

MIT

Unpacked Size

64.4 kB

Total Files

28

Last publish

Collaborators

  • avatar