First pass at README update.

This commit is contained in:
Nick Farina
2015-11-02 15:30:29 -08:00
parent 15cc98217b
commit 52d3a9a96e
5 changed files with 80 additions and 95 deletions

View File

@@ -10,13 +10,6 @@ var log = require("./logger")._system;
module.exports = function() {
log.warn("_____________________________________________________________________");
log.warn("IMPORTANT: Homebridge is in the middle of some big changes.");
log.warn(" Read more about it here:");
log.warn(" https://github.com/nfarina/homebridge/wiki/Migration-Guide");
log.warn("_____________________________________________________________________");
log.warn("");
program
.version(version)
.option('-P, --plugin-path [path]', 'look for plugins installed at [path] as well as node_modules', function(p) { Plugin.addPluginPath(p); })

View File

@@ -17,7 +17,7 @@ module.exports = {
*/
function Plugin(pluginPath) {
this.pluginPath = pluginPath; // like "/usr/local/lib/node_modules/plugin-lockitron"
this.pluginPath = pluginPath; // like "/usr/local/lib/node_modules/homebridge-lockitron"
this.initializer; // exported function from the plugin that initializes it
}
@@ -35,7 +35,19 @@ Plugin.prototype.load = function(options) {
// attempt to load package.json
var pjson = Plugin.loadPackageJSON(this.pluginPath);
// make sure the name is prefixed with 'homebridge-'
if (!pjson.name || pjson.name.indexOf('homebridge-') != 0) {
throw new Error("Plugin " + this.pluginPath + " does not have a package name that begins with 'homebridge-'.");
}
// very temporary fix for first wave of plugins
if (pjson.peerDepdendencies && (!pjson.engines || !pjson.engines.homebridge)) {
var engines = pjson.engines || {}
engines.homebridge = pjson.peerDepdendencies.homebridge;
pjson.engines = engines;
}
// pluck out the HomeBridge version requirement
if (!pjson.engines || !pjson.engines.homebridge) {
throw new Error("Plugin " + this.pluginPath + " does not contain the 'homebridge' package in 'engines'.");

View File

@@ -59,6 +59,7 @@ Server.prototype._publish = function() {
Server.prototype._loadPlugins = function(accessories, platforms) {
var plugins = {};
var foundOnePlugin = false;
// load and validate plugins - check for valid package.json, etc.
Plugin.installed().forEach(function(plugin) {
@@ -75,17 +76,26 @@ Server.prototype._loadPlugins = function(accessories, platforms) {
plugin.loadError = err;
}
// add it to our dict for easy lookup later
plugins[plugin.name()] = plugin;
if (!plugin.loadError) {
// add it to our dict for easy lookup later
plugins[plugin.name()] = plugin;
log.info("Loaded plugin: " + plugin.name());
log.info("Loaded plugin: " + plugin.name());
// call the plugin's initializer and pass it our API instance
plugin.initializer(this._api);
// call the plugin's initializer and pass it our API instance
plugin.initializer(this._api);
log.info("---");
log.info("---");
foundOnePlugin = true;
}
}.bind(this));
// Complain if you don't have any plugins.
if (!foundOnePlugin) {
log.warn("No plugins found. See the README for information on installing plugins.")
}
return plugins;
}
@@ -97,7 +107,7 @@ Server.prototype._loadConfig = function() {
// Complain and exit if it doesn't exist yet
if (!fs.existsSync(configPath)) {
log.error("Couldn't find a config.json file in the same directory as app.js. Look at config-sample.json for examples of how to format your config.js and add your home accessories.");
log.error("Couldn't find a config.json file at '"+configPath+"'. Look at config-sample.json for examples of how to format your config.js and add your home accessories.");
process.exit(1);
}