Merge pull request #1827 from sdetweil/fix_helper

Fix helper being erased accidentally
This commit is contained in:
Michael Teeuw 2019-12-28 21:44:10 +01:00 committed by GitHub
commit 9cc702241d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 128 deletions

View File

@ -1,7 +1,11 @@
dist: trusty
language: node_js
node_js:
- "10"
- "10
before_install:
- npm i -g npm
before_script:
- yarn danger ci

View File

@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
### Added
- move node_helper module to dedicated github repo, to prevent being erased accidentally
- new upgrade script to help users consume regular updates installers/upgrade-script.sh
- new script to help setup pm2, without install installers/fixuppm2.sh

View File

@ -1,125 +0,0 @@
/* Magic Mirror
* Node Helper Superclass
*
* By Michael Teeuw http://michaelteeuw.nl
* MIT Licensed.
*/
var Class = require("../../../js/class.js");
var express = require("express");
var path = require("path");
NodeHelper = Class.extend({
init: function() {
console.log("Initializing new module helper ...");
},
loaded: function(callback) {
console.log("Module helper loaded: " + this.name);
callback();
},
start: function() {
console.log("Starting module helper: " + this.name);
},
/* stop()
* Called when the MagicMirror server receives a `SIGINT`
* Close any open connections, stop any sub-processes and
* gracefully exit the module.
*
*/
stop: function() {
console.log("Stopping module helper: " + this.name);
},
/* socketNotificationReceived(notification, payload)
* This method is called when a socket notification arrives.
*
* argument notification string - The identifier of the notification.
* argument payload mixed - The payload of the notification.
*/
socketNotificationReceived: function(notification, payload) {
console.log(this.name + " received a socket notification: " + notification + " - Payload: " + payload);
},
/* setName(name)
* Set the module name.
*
* argument name string - Module name.
*/
setName: function(name) {
this.name = name;
},
/* setPath(path)
* Set the module path.
*
* argument path string - Module path.
*/
setPath: function(path) {
this.path = path;
},
/* sendSocketNotification(notification, payload)
* Send a socket notification to the node helper.
*
* argument notification string - The identifier of the notification.
* argument payload mixed - The payload of the notification.
*/
sendSocketNotification: function(notification, payload) {
this.io.of(this.name).emit(notification, payload);
},
/* setExpressApp(app)
* Sets the express app object for this module.
* This allows you to host files from the created webserver.
*
* argument app Express app - The Express app object.
*/
setExpressApp: function(app) {
this.expressApp = app;
var publicPath = this.path + "/public";
app.use("/" + this.name, express.static(publicPath));
},
/* setSocketIO(io)
* Sets the socket io object for this module.
* Binds message receiver.
*
* argument io Socket.io - The Socket io object.
*/
setSocketIO: function(io) {
var self = this;
self.io = io;
console.log("Connecting socket for: " + this.name);
var namespace = this.name;
io.of(namespace).on("connection", function(socket) {
// add a catch all event.
var onevent = socket.onevent;
socket.onevent = function(packet) {
var args = packet.data || [];
onevent.call(this, packet); // original call
packet.data = ["*"].concat(args);
onevent.call(this, packet); // additional call to catch-all
};
// register catch all.
socket.on("*", function(notification, payload) {
if (notification !== "*") {
//console.log('received message in namespace: ' + namespace);
self.socketNotificationReceived(notification, payload);
}
});
});
}
});
NodeHelper.create = function(moduleDefinition) {
return NodeHelper.extend(moduleDefinition);
};
module.exports = NodeHelper;

21
package-lock.json generated
View File

@ -408,6 +408,12 @@
"integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==",
"dev": true
},
"@types/parse-json": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz",
"integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==",
"dev": true
},
"@types/unist": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.3.tgz",
@ -2375,6 +2381,7 @@
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/electron-download/-/electron-download-4.1.1.tgz",
"integrity": "sha512-FjEWG9Jb/ppK/2zToP+U5dds114fM1ZOJqMAR4aXXL5CvyPE9fiqBK/9YcwC9poIFQTEJk/EM/zyRwziziRZrg==",
"optional": true,
"requires": {
"debug": "^3.0.0",
"env-paths": "^1.0.0",
@ -2391,6 +2398,7 @@
"version": "3.2.6",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",
"integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==",
"optional": true,
"requires": {
"ms": "^2.1.1"
}
@ -2403,7 +2411,8 @@
"path-exists": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
"integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU="
"integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=",
"optional": true
}
}
},
@ -3450,6 +3459,7 @@
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz",
"integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==",
"optional": true,
"requires": {
"graceful-fs": "^4.1.2",
"jsonfile": "^4.0.0",
@ -3460,6 +3470,7 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
"optional": true,
"requires": {
"graceful-fs": "^4.1.6"
}
@ -5782,6 +5793,10 @@
}
}
},
"node_helper": {
"version": "git://github.com/sdetweil/nodehelper.git#c01ad10b38c81938a9ba3e55ab72ffd81d4bc0d4",
"from": "git://github.com/sdetweil/nodehelper.git"
},
"nopt": {
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz",
@ -8136,6 +8151,7 @@
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-2.0.2.tgz",
"integrity": "sha1-D0LBDl0F2l1C7qPlbDOZo31sWz4=",
"optional": true,
"requires": {
"debug": "^2.2.0"
}
@ -8694,7 +8710,8 @@
"universalify": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg=="
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==",
"optional": true
},
"unix-crypt-td-js": {
"version": "1.0.0",

View File

@ -68,6 +68,7 @@
"iconv-lite": "latest",
"lodash": "^4.17.11",
"moment": "latest",
"node_helper": "git://github.com/sdetweil/nodehelper.git",
"request": "^2.88.0",
"rrule": "^2.6.2",
"rrule-alt": "^2.2.8",