Research of existing Node.js plugin systems used by various modules.
https://hexo.io/docs/plugins.html
Place file in scripts
folder.
or
Module name must be prefixed with hexo-
.
package.json should include version and dependencies:
// package.json
{
"name":"my-app",
"version": "0.x",
"dependencies": {
"ghost-app": "0.0.2"
}
}
// index.js
var App = require('ghost-app'), MyApp
MyApp = App.extend({
install: function () {},
uninstall: function () {},
activate: function () {},
deactivate: function () {}
})
module.exports = MyApp
# Export Plugin
module.exports = (BasePlugin) ->
# Define Plugin
class YourpluginnamePlugin extends BasePlugin
# Plugin name
name: 'yourpluginname'
grunt.registerTask(taskName, [description, ] taskList)
https://www.npmjs.com/package/gulp-load-plugins
gulpLoadPlugins({
pattern: ['gulp-*', 'gulp.*'], // the glob(s) to search for
config: 'package.json', // where to find the plugins, by default searched up from process.cwd()
scope: ['dependencies', 'devDependencies', 'peerDependencies'], // which keys in the config to look within
replaceString: /^gulp(-|\.)/, // what to remove from the name of the module when adding it to the context
camelize: true, // if true, transforms hyphenated plugins names to camel case
lazy: true, // whether the plugins should be lazy loaded on demand
rename: {} // a mapping of plugins to rename
})
https://github.com/scottcorgan/nash
Example of registering a plugin:
var nash = require('nash');
var myPlugin = require('my-plugin');
var cli = nash();
cli.register([{
register: myPlugin,
options: {
key: 'value'
}
}], function (err) {
// Done loading plugins
});
Example plugin:
module.exports = function (cli, options, done) {
cli.command('something')
.handler(function (data, flags, done) {
// Do something here
done();
});
done();
};
this.sandbox.on('cats.update', this.render, this)
components.afterAppStart
emit
off
on
once
start
stopListening
import Bar from 'bar'
@Inject(Bar)
class Foo {
constructor(bar) {
}
}
@Provide(Bar)
class BarMock {
}
// atom/package-generator
MyPackageView = require './my-package-view'
module.exports =
myPackageView: null
activate: (state) ->
@myPackageView = new MyPackageView(state.myPackageViewState)
deactivate: ->
@myPackageView.destroy()
serialize: ->
myPackageViewState: @myPackageView.serialize()