Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

Build your Plugin

frankrousseau edited this page Oct 6, 2014 · 2 revisions

NB: To write your own plugin, the best way is to start from an already existing one.

Description

A plugin is a simple node.js lib that modifies the Cozy Light main server configuration and save data to the configuration file.

Available functions

Mandatory

  • configure(options, config, program): It's the function loaded when Cozy Light starts. There you can save parameters given by the Cozy Light platform.
    • options contains one field: config_path that give the path of the configuration file.
    • config is the Cozy Light config file values.
    • program is the Commander instance use to manage the command lines parameters.

Optional

  • configureAppServer(app, config, routes, callback): Allows the plugin to modify the main Express server that handles proxying and dashboard rendering.

    • app is the Express application.
    • config is the Cozy Light config file values.
    • routes is the routing table of the proxy that links a name to a port.
    • callback function to call to end the configuration.
  • getTemplate(): Return plugin data to display in the Cozy Light main dashboard.

  • onExit(options, config, callback): This function is called on the Cozy Light termination and requires the callback to be called.

    • options contains one field: config_path that give the path of the configuration file.
    • config is the Cozy Light config file values.

Manifest

A plungin requires an app-like manifest (the only difference is the type which is set to "plugin"):

{
  "name": "cozy-light-html5-apps",
  "type": "plugin",
  "version": "0.1.0",
  "displayName": "HTML5 support for Cozy Light",
  "description": "Allow to deploy apps only made of static files.",
  "author": "Cozy Cloud <contact@cozycloud.cc> (http://cozycloud.cc)",
  "licenses": [
    {
      "type": "AGPL v3",
      "url": "http://www.gnu.org/licenses/agpl-3.0.html"
    }
  ],
  "main": "index.js",
  "repository": {
    "type": "git",
    "url": "https://github.com/cozy-labs/cozy-light-html5-apps.git"
  },
  "dependencies": {
    "express": "^4.9.0"
  }
}
Clone this wiki locally