1.0.1 • Published 6 years ago

node-ark v1.0.1

Weekly downloads
4
License
GPL-3.0
Repository
github
Last release
6 years ago

node-ark

A Node application creator about plugin architecture approach.

Quick Example

Create your module with npm

mkdir -p plugins/myMainPackager
cd plugins/myMainPackager
npm init
touch index.js

Create a plugin plugins/myMainPackager/index.js

module.exports = function setup(imports, done) {
    imports.myValueExported = 123;

    done(); // call done when finish it
}

Your main.js script:

var ark = require('node-ark');

ark.create(["plugins/myMainPackager"], function (imports) {
    console.log("My application is running! All plugins are loaded");
})

Here is your package.json:

{
  "name": "myMainPackager",
  "version": "0.0.1",
  "description": "My Demo Application",
  "main": "index.js",
}

Dependencies

Edit the package.json from plugin that require the dependency.

{
    "name": "myMainPackager",
    "version": "0.0.1",
    "description": "My Demo Application",
    "main": "index.js",

    "plugin": {
      "requires": [
          "plugins/myAnotherPlugin"
      ]
    }
}

Create a new plugin

Create a new package.json:

{
    "name": "myAnotherPlugin",
    "version": "0.0.1",
    "description": "My Plugin",
    "main": "myPluginSetup.js"
}

Create the target plugin plugins/myAnotherPlugin/myPluginSetup.js:

module.exports = function setup(imports, done) {
    imports.shareThisObject = {
        name: "Amazing plugin system",
        run: function () {
            return this.name + " is running"
        }
    };

    done(); // call done when finish it
}

Then, from myMainPackager.js plugin you can do access the shared object:

module.exports = function setup(imports, done) {
    var sharedObject = imports.shareThisObject;

    console.log("Who is?", sharedObject.name);
    console.log("Do what?", sharedObject.run());

    done(); // call done when finish it
}
1.0.1

6 years ago

1.0.0

6 years ago

0.4.0

6 years ago

0.3.0

7 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.1

8 years ago