Skip to content

Commit

Permalink
Merge pull request #1 from MichMich/develop
Browse files Browse the repository at this point in the history
Catching up on 19th Sep 2020
  • Loading branch information
ashishtank authored Sep 19, 2020
2 parents 9d14d3e + fd4576b commit 94162f1
Show file tree
Hide file tree
Showing 37 changed files with 1,028 additions and 479 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"plugins": ["prettier"],
"extends": ["eslint:recommended", "plugin:prettier/recommended", "plugin:jsdoc/recommended"],
"plugins": ["prettier", "jsdoc"],
"env": {
"browser": true,
"es6": true,
Expand Down
17 changes: 15 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,44 @@ This project adheres to [Semantic Versioning](https://semver.org/).

❤️ **Donate:** Enjoying MagicMirror²? [Please consider a donation!](https://magicmirror.builders/donate) With your help we can continue to improve the MagicMirror²

### fixed

- 2110, 2111, 2118 recurring full day events should not use timezone adjustment. just compare month/day

## [2.13.0] - Unreleased (Develop Branch - Please add your contributions to this release.)

_This release is scheduled to be released on 2020-10-01._

### Added

- `--dry-run` option adde in fetch call within updatenotification node_helper. This is to prevent
MagicMirror from consuming any fetch result. Causes conflict with MMPM when attempting to check
for updates to MagicMirror and/or MagicMirror modules.
- Test coverage with Istanbul, run it with `npm run test:coverage`.
- Add lithuanian language.
- Added support in weatherforecast for OpenWeather onecall API.
- Added config option to calendar-icons for recurring- and fullday-events
- Added current, hourly (max 48), and daily (max 7) weather forecasts to weather module via OpenWeatherMap One Call API
- Added eslint-plugin for jsdoc comments

### Updated

- Change incorrect weather.js default properties.
- Cleaned up newsfeed module.
- Cleaned up jsdoc comments.
- Cleaned up clock tests.

### Deleted

### Fixed

- Fix backward compatibility issues for Safari < 11. [#1985](https://github.com/MichMich/MagicMirror/issues/1985)
- Fix backward compatibility issues for Safari < 11.
- Fix the use of "maxNumberOfDays" in the module "weatherforecast depending on the endpoint (forecast/daily or forecast)". [#2018](https://github.com/MichMich/MagicMirror/issues/2018)
- Fix calendar display. Account for current timezone. [#2068](https://github.com/MichMich/MagicMirror/issues/2068)
- Fix logLevel being set before loading config.
- Fix incorrect namespace links in svg clockfaces. [#2072](https://github.com/MichMich/MagicMirror/issues/2072)
- Fix weather/providers/weathergov for API guidelines [#2045]
- Fix weather/providers/weathergov for API guidelines. [#2045](https://github.com/MichMich/MagicMirror/issues/2045)
- Fix "undefined" in weather modules header. [#1985](https://github.com/MichMich/MagicMirror/issues/1985)

## [2.12.0] - 2020-07-01

Expand Down Expand Up @@ -70,6 +82,7 @@ Special thanks to the following contributors: @AndreKoepke, @andrezibaia, @bryan
- Throw error when check_config fails. [#1928](https://github.com/MichMich/MagicMirror/issues/1928)
- Bug fix related to 'maxEntries' not displaying Calendar events. [#2050](https://github.com/MichMich/MagicMirror/issues/2050)
- Updated ical library to latest version. [#1926](https://github.com/MichMich/MagicMirror/issues/1926)
- Fix config check after merge of prettier [#2109](https://github.com/MichMich/MagicMirror/issues/2109)

## [2.11.0] - 2020-04-01

Expand Down
30 changes: 26 additions & 4 deletions clientonly/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@
(function () {
var config = {};

// Helper function to get server address/hostname from either the commandline or env
/**
* Helper function to get server address/hostname from either the commandline or env
*/
function getServerAddress() {
// Helper function to get command line parameters
// Assumes that a cmdline parameter is defined with `--key [value]`
/**
* Get command line parameters
* Assumes that a cmdline parameter is defined with `--key [value]`
*
* @param {string} key key to look for at the command line
* @param {string} defaultValue value if no key is given at the command line
*
* @returns {string} the value of the parameter
*/
function getCommandLineParameter(key, defaultValue = undefined) {
var index = process.argv.indexOf(`--${key}`);
var value = index > -1 ? process.argv[index + 1] : undefined;
Expand All @@ -23,10 +32,17 @@
config["tls"] = process.argv.indexOf("--use-tls") > 0;
}

/**
* Gets the config from the specified server url
*
* @param {string} url location where the server is running.
*
* @returns {Promise} the config
*/
function getServerConfig(url) {
// Return new pending promise
return new Promise((resolve, reject) => {
// Select http or https module, depending on reqested url
// Select http or https module, depending on requested url
const lib = url.startsWith("https") ? require("https") : require("http");
const request = lib.get(url, (response) => {
var configData = "";
Expand All @@ -47,6 +63,12 @@
});
}

/**
* Print a message to the console in case of errors
*
* @param {string} [message] error message to print
* @param {number} code error code for the exit call
*/
function fail(message, code = 1) {
if (message !== undefined && typeof message === "string") {
console.log(message);
Expand Down
63 changes: 41 additions & 22 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,19 @@ process.on("uncaughtException", function (err) {
Log.error("If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues");
});

/* App - The core app.
/**
* The core app.
*
* @class
*/
var App = function () {
var nodeHelpers = [];

/* loadConfig(callback)
* Loads the config file. combines it with the defaults,
* and runs the callback with the found config as argument.
/**
* Loads the config file. Combines it with the defaults, and runs the
* callback with the found config as argument.
*
* argument callback function - The callback function.
* @param {Function} callback Function to be called after loading the config
*/
var loadConfig = function (callback) {
Log.log("Loading config ...");
Expand Down Expand Up @@ -80,6 +83,12 @@ var App = function () {
}
};

/**
* Checks the config for deprecated options and throws a warning in the logs
* if it encounters one option from the deprecated.js list
*
* @param {object} userConfig The user config
*/
var checkDeprecatedOptions = function (userConfig) {
var deprecated = require(global.root_path + "/js/deprecated.js");
var deprecatedOptions = deprecated.configs;
Expand All @@ -96,10 +105,11 @@ var App = function () {
}
};

/* loadModule(module)
/**
* Loads a specific module.
*
* argument module string - The name of the module (including subpath).
* @param {string} module The name of the module (including subpath).
* @param {Function} callback Function to be called after loading
*/
var loadModule = function (module, callback) {
var elements = module.split("/");
Expand Down Expand Up @@ -144,10 +154,11 @@ var App = function () {
}
};

/* loadModules(modules)
/**
* Loads all modules.
*
* argument module string - The name of the module (including subpath).
* @param {Module[]} modules All modules to be loaded
* @param {Function} callback Function to be called after loading
*/
var loadModules = function (modules, callback) {
Log.log("Loading module helpers ...");
Expand All @@ -169,11 +180,14 @@ var App = function () {
loadNextModule();
};

/* cmpVersions(a,b)
/**
* Compare two semantic version numbers and return the difference.
*
* argument a string - Version number a.
* argument a string - Version number b.
* @param {string} a Version number a.
* @param {string} b Version number b.
*
* @returns {number} A positive number if a is larger than b, a negative
* number if a is smaller and 0 if they are the same
*/
function cmpVersions(a, b) {
var i, diff;
Expand All @@ -191,12 +205,13 @@ var App = function () {
return segmentsA.length - segmentsB.length;
}

/* start(callback)
* This methods starts the core app.
* It loads the config, then it loads all modules.
* When it's done it executes the callback with the config as argument.
/**
* Start the core app.
*
* It loads the config, then it loads all modules. When it's done it
* executes the callback with the config as argument.
*
* argument callback function - The callback function.
* @param {Function} callback Function to be called after start
*/
this.start = function (callback) {
loadConfig(function (c) {
Expand Down Expand Up @@ -234,9 +249,10 @@ var App = function () {
});
};

/* stop()
* This methods stops the core app.
* This calls each node_helper's STOP() function, if it exists.
/**
* Stops the core app. This calls each node_helper's STOP() function, if it
* exists.
*
* Added to fix #1056
*/
this.stop = function () {
Expand All @@ -248,7 +264,8 @@ var App = function () {
}
};

/* Listen for SIGINT signal and call stop() function.
/**
* Listen for SIGINT signal and call stop() function.
*
* Added to fix #1056
* Note: this is only used if running `server-only`. Otherwise
Expand All @@ -263,7 +280,9 @@ var App = function () {
process.exit(0);
});

/* We also need to listen to SIGTERM signals so we stop everything when we are asked to stop by the OS.
/**
* Listen to SIGTERM signals so we can stop everything when we
* are asked to stop by the OS.
*/
process.on("SIGTERM", () => {
Log.log("[SIGTERM] Received. Shutting down server...");
Expand Down
21 changes: 12 additions & 9 deletions js/check_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ const path = require("path");
const fs = require("fs");

const rootPath = path.resolve(__dirname + "/../");
const config = require(rootPath + "/.eslintrc.json");
const Log = require(rootPath + "/js/logger.js");
const Utils = require(rootPath + "/js/utils.js");

/* getConfigFile()
* Return string with path of configuration file
/**
* Returns a string with path of configuration file.
* Check if set by environment variable MM_CONFIG_FILE
*
* @returns {string} path and filename of the config file
*/
function getConfigFile() {
// FIXME: This function should be in core. Do you want refactor me ;) ?, be good!
Expand All @@ -29,6 +30,9 @@ function getConfigFile() {
return configFileName;
}

/**
* Checks the config file using eslint.
*/
function checkConfigFile() {
const configFileName = getConfigFile();

Expand All @@ -38,7 +42,7 @@ function checkConfigFile() {
throw new Error("No config file present!");
}

// check permission
// Check permission
try {
fs.accessSync(configFileName, fs.F_OK);
} catch (e) {
Expand All @@ -54,16 +58,15 @@ function checkConfigFile() {
if (err) {
throw err;
}
const messages = linter.verify(data, config);
const messages = linter.verify(data);
if (messages.length === 0) {
Log.log("Your configuration file doesn't contain syntax errors :)");
return true;
Log.info(Utils.colors.pass("Your configuration file doesn't contain syntax errors :)"));
} else {
Log.error(Utils.colors.error("Your configuration file contains syntax errors :("));
// In case the there errors show messages and return
messages.forEach((error) => {
Log.log("Line", error.line, "col", error.column, error.message);
Log.error("Line", error.line, "col", error.column, error.message);
});
throw new Error("Wrong syntax in config file!");
}
});
}
Expand Down
13 changes: 10 additions & 3 deletions js/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
: prop[name];
}

// The dummy class constructor
/**
* The dummy class constructor
*/
function Class() {
// All construction is actually done in the init method
if (!initializing && this.init) {
Expand All @@ -78,8 +80,13 @@
};
})();

//Define the clone method for later use.
//Helper Method
/**
* Define the clone method for later use. Helper Method.
*
* @param {object} obj Object to be cloned
*
* @returns {object} the cloned object
*/
function cloneObject(obj) {
if (obj === null || typeof obj !== "object") {
return obj;
Expand Down
3 changes: 3 additions & 0 deletions js/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const BrowserWindow = electron.BrowserWindow;
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;

/**
*
*/
function createWindow() {
app.commandLine.appendSwitch("autoplay-policy", "no-user-gesture-required");
var electronOptionsDefaults = {
Expand Down
Loading

0 comments on commit 94162f1

Please sign in to comment.