Merge branch 'develop' into patch-1

This commit is contained in:
Christopher Fenner 2022-01-12 20:39:09 +01:00 committed by GitHub
commit 9e4997aa81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 1157 additions and 1084 deletions

View File

@ -33,6 +33,4 @@ jobs:
npm run test:prettier
npm run test:js
npm run test:css
npm run test:unit
npm run test:e2e
npm run test:electron
npm run test

View File

@ -11,8 +11,14 @@ _This release is scheduled to be released on 2022-04-01._
### Added
- Added a config option under the weather module, absoluteDates, providing an option to format weather forecast date output with either absolute or relative dates.
- Added test for new weather forecast absoluteDates porperty.
- The modules get a class hidden added/removed if they get hidden/shown
### Updated
- deprecated roboto fonts package `roboto-fontface-bower` replaced with `fontsource`.
- update `helmet` to v5.
- updates Font Awesome css class to new default style (fixes #2768)
### Fixed

View File

@ -40,7 +40,7 @@ Contributions of all kinds are welcome, not only in the form of code but also wi
- documentation
- translations
For the full contribution guidelines, check out: [https://docs.magicmirror.builders/getting-started/contributing.html](https://docs.magicmirror.builders/getting-started/contributing.html)
For the full contribution guidelines, check out: [https://docs.magicmirror.builders/about/contributing.html](https://docs.magicmirror.builders/about/contributing.html)
## Enjoying MagicMirror? Consider a donation!

View File

@ -7,20 +7,31 @@
"name": "magicmirror-fonts",
"license": "MIT",
"dependencies": {
"roboto-fontface": "^0.10.0"
"@fontsource/roboto": "^4.5.1",
"@fontsource/roboto-condensed": "^4.5.0"
}
},
"node_modules/roboto-fontface": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/roboto-fontface/-/roboto-fontface-0.10.0.tgz",
"integrity": "sha512-OlwfYEgA2RdboZohpldlvJ1xngOins5d7ejqnIBWr9KaMxsnBqotpptRXTyfNRLnFpqzX6sTDt+X+a+6udnU8g=="
"node_modules/@fontsource/roboto": {
"version": "4.5.1",
"resolved": "https://registry.npmjs.org/@fontsource/roboto/-/roboto-4.5.1.tgz",
"integrity": "sha512-3mhfL+eNPG/woMNqwD/OHaW5qMpeGEBsDwzmhFmjB1yUV+M+M9P0NhP/AyHvnGz3DrqkvZ7CPzNMa+UkVLeELg=="
},
"node_modules/@fontsource/roboto-condensed": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/@fontsource/roboto-condensed/-/roboto-condensed-4.5.0.tgz",
"integrity": "sha512-P5On1DdWxWvBHC0kfinxGWOHveAS3wEHKpgfBidl6mzJI/nJyzcPxf5p5k0oT6uY0WzUCPPfsfgCmKMMULAXGg=="
}
},
"dependencies": {
"roboto-fontface": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/roboto-fontface/-/roboto-fontface-0.10.0.tgz",
"integrity": "sha512-OlwfYEgA2RdboZohpldlvJ1xngOins5d7ejqnIBWr9KaMxsnBqotpptRXTyfNRLnFpqzX6sTDt+X+a+6udnU8g=="
"@fontsource/roboto": {
"version": "4.5.1",
"resolved": "https://registry.npmjs.org/@fontsource/roboto/-/roboto-4.5.1.tgz",
"integrity": "sha512-3mhfL+eNPG/woMNqwD/OHaW5qMpeGEBsDwzmhFmjB1yUV+M+M9P0NhP/AyHvnGz3DrqkvZ7CPzNMa+UkVLeELg=="
},
"@fontsource/roboto-condensed": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/@fontsource/roboto-condensed/-/roboto-condensed-4.5.0.tgz",
"integrity": "sha512-P5On1DdWxWvBHC0kfinxGWOHveAS3wEHKpgfBidl6mzJI/nJyzcPxf5p5k0oT6uY0WzUCPPfsfgCmKMMULAXGg=="
}
}
}

View File

@ -10,6 +10,7 @@
"url": "https://github.com/MichMich/MagicMirror/issues"
},
"dependencies": {
"roboto-fontface": "^0.10.0"
"@fontsource/roboto": "^4.5.1",
"@fontsource/roboto-condensed": "^4.5.0"
}
}

View File

@ -2,57 +2,57 @@
font-family: Roboto;
font-style: normal;
font-weight: 100;
src: local("Roboto Thin"), local("Roboto-Thin"), url("node_modules/roboto-fontface/fonts/roboto/Roboto-Thin.woff2") format("woff2"), url("node_modules/roboto-fontface/fonts/roboto/Roboto-Thin.woff") format("woff");
src: local("Roboto Thin"), local("Roboto-Thin"), url("node_modules/@fontsource/roboto/files/roboto-latin-100-normal.woff2") format("woff2"), url("node_modules/@fontsource/roboto/files/roboto-latin-100-normal.woff") format("woff");
}
@font-face {
font-family: "Roboto Condensed";
font-style: normal;
font-weight: 300;
src: local("Roboto Condensed Light"), local("RobotoCondensed-Light"), url("node_modules/roboto-fontface/fonts/roboto-condensed/Roboto-Condensed-Light.woff2") format("woff2"),
url("node_modules/roboto-fontface/fonts/roboto-condensed/Roboto-Condensed-Light.woff") format("woff");
src: local("Roboto Condensed Light"), local("RobotoCondensed-Light"), url("node_modules/@fontsource/roboto-condensed/files/roboto-condensed-latin-300-normal.woff2") format("woff2"),
url("node_modules/@fontsource/roboto-condensed/files/roboto-condensed-latin-300-normal.woff") format("woff");
}
@font-face {
font-family: "Roboto Condensed";
font-style: normal;
font-weight: 400;
src: local("Roboto Condensed"), local("RobotoCondensed-Regular"), url("node_modules/roboto-fontface/fonts/roboto-condensed/Roboto-Condensed-Regular.woff2") format("woff2"),
url("node_modules/roboto-fontface/fonts/roboto-condensed/Roboto-Condensed-Regular.woff") format("woff");
src: local("Roboto Condensed"), local("RobotoCondensed-Regular"), url("node_modules/@fontsource/roboto-condensed/files/roboto-condensed-latin-400-normal.woff2") format("woff2"),
url("node_modules/@fontsource/roboto-condensed/files/roboto-condensed-latin-400-normal.woff") format("woff");
}
@font-face {
font-family: "Roboto Condensed";
font-style: normal;
font-weight: 700;
src: local("Roboto Condensed Bold"), local("RobotoCondensed-Bold"), url("node_modules/roboto-fontface/fonts/roboto-condensed/Roboto-Condensed-Bold.woff2") format("woff2"),
url("node_modules/roboto-fontface/fonts/roboto-condensed/Roboto-Condensed-Bold.woff") format("woff");
src: local("Roboto Condensed Bold"), local("RobotoCondensed-Bold"), url("node_modules/@fontsource/roboto-condensed/files/roboto-condensed-latin-700-normal.woff2") format("woff2"),
url("node_modules/@fontsource/roboto-condensed/files/roboto-condensed-latin-700-normal.woff") format("woff");
}
@font-face {
font-family: Roboto;
font-style: normal;
font-weight: 400;
src: local("Roboto"), local("Roboto-Regular"), url("node_modules/roboto-fontface/fonts/roboto/Roboto-Regular.woff2") format("woff2"), url("node_modules/roboto-fontface/fonts/roboto/Roboto-Regular.woff") format("woff");
src: local("Roboto"), local("Roboto-Regular"), url("node_modules/@fontsource/roboto/files/roboto-latin-400-normal.woff2") format("woff2"), url("node_modules/@fontsource/roboto/files/roboto-latin-400-normal.woff") format("woff");
}
@font-face {
font-family: Roboto;
font-style: normal;
font-weight: 500;
src: local("Roboto Medium"), local("Roboto-Medium"), url("node_modules/roboto-fontface/fonts/roboto/Roboto-Medium.woff2") format("woff2"), url("node_modules/roboto-fontface/fonts/roboto/Roboto-Medium.woff") format("woff");
src: local("Roboto Medium"), local("Roboto-Medium"), url("node_modules/@fontsource/roboto/files/roboto-latin-500-normal.woff2") format("woff2"), url("node_modules/@fontsource/roboto/files/roboto-latin-500-normal.woff") format("woff");
}
@font-face {
font-family: Roboto;
font-style: normal;
font-weight: 700;
src: local("Roboto Bold"), local("Roboto-Bold"), url("node_modules/roboto-fontface/fonts/roboto/Roboto-Bold.woff2") format("woff2"), url("node_modules/roboto-fontface/fonts/roboto/Roboto-Bold.woff") format("woff");
src: local("Roboto Bold"), local("Roboto-Bold"), url("node_modules/@fontsource/roboto/files/roboto-latin-700-normal.woff2") format("woff2"), url("node_modules/@fontsource/roboto/files/roboto-latin-700-normal.woff") format("woff");
}
@font-face {
font-family: Roboto;
font-style: normal;
font-weight: 300;
src: local("Roboto Light"), local("Roboto-Light"), url("node_modules/roboto-fontface/fonts/roboto/Roboto-Light.woff2") format("woff2"), url("node_modules/roboto-fontface/fonts/roboto/Roboto-Light.woff") format("woff");
src: local("Roboto Light"), local("Roboto-Light"), url("node_modules/@fontsource/roboto/files/roboto-latin-300-normal.woff2") format("woff2"), url("node_modules/@fontsource/roboto/files/roboto-latin-300-normal.woff") format("woff");
}

View File

@ -245,6 +245,7 @@ const MM = (function () {
if (moduleWrapper !== null) {
moduleWrapper.style.transition = "opacity " + speed / 1000 + "s";
moduleWrapper.style.opacity = 0;
moduleWrapper.classList.add("hidden");
clearTimeout(module.showHideTimer);
module.showHideTimer = setTimeout(function () {
@ -310,6 +311,7 @@ const MM = (function () {
moduleWrapper.style.transition = "opacity " + speed / 1000 + "s";
// Restore the position. See hideModule() for more info.
moduleWrapper.style.position = "static";
moduleWrapper.classList.remove("hidden");
updateWrapperStates();

View File

@ -67,7 +67,7 @@ function Server(config, callback) {
res.status(403).send("This device is not allowed to access your mirror. <br> Please check your config.js or config.js.sample to change this.");
});
});
app.use(helmet({ contentSecurityPolicy: false }));
app.use(helmet({ contentSecurityPolicy: false, crossOriginOpenerPolicy: false }));
app.use("/js", express.static(__dirname));

View File

@ -9,6 +9,8 @@
*
* Copyright 2014, Codrops
* https://tympanus.net/codrops/
*
* @param {object} window The window object
*/
(function (window) {
/**

View File

@ -8,9 +8,9 @@
{% set forecast = forecast.slice(0, numSteps) %}
{% for f in forecast %}
<tr {% if config.colored %}class="colored"{% endif %} {% if config.fade %}style="opacity: {{ currentStep | opacity(numSteps) }};"{% endif %}>
{% if (currentStep == 0) and config.ignoreToday == false %}
{% if (currentStep == 0) and config.ignoreToday == false and config.absoluteDates == false %}
<td class="day">{{ "TODAY" | translate }}</td>
{% elif (currentStep == 1) and config.ignoreToday == false %}
{% elif (currentStep == 1) and config.ignoreToday == false and config.absoluteDates == false %}
<td class="day">{{ "TOMORROW" | translate }}</td>
{% else %}
<td class="day">{{ f.date.format('ddd') }}</td>

View File

@ -43,7 +43,8 @@ Module.register("weather", {
onlyTemp: false,
showPrecipitationAmount: false,
colored: false,
showFeelsLike: true
showFeelsLike: true,
absoluteDates: false
},
// Module properties.

2034
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -47,12 +47,12 @@
"homepage": "https://magicmirror.builders",
"devDependencies": {
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-jest": "^25.3.0",
"eslint-plugin-jsdoc": "^37.4.0",
"eslint-plugin-jest": "^25.3.4",
"eslint-plugin-jsdoc": "^37.6.1",
"eslint-plugin-prettier": "^4.0.0",
"express-basic-auth": "^1.2.1",
"husky": "^7.0.4",
"jest": "^27.4.5",
"jest": "^27.4.7",
"jsdom": "^19.0.0",
"lodash": "^4.17.21",
"nyc": "^15.1.0",
@ -67,23 +67,23 @@
"suncalc": "^1.8.0"
},
"optionalDependencies": {
"electron": "^16.0.5"
"electron": "^16.0.6"
},
"dependencies": {
"colors": "^1.4.0",
"console-stamp": "^3.0.3",
"digest-fetch": "^1.2.1",
"eslint": "^8.5.0",
"eslint": "^8.6.0",
"express": "^4.17.2",
"express-ipfilter": "^1.2.0",
"feedme": "^2.0.2",
"helmet": "^4.6.0",
"helmet": "^5.0.1",
"iconv-lite": "^0.6.3",
"module-alias": "^2.2.2",
"moment": "^2.29.1",
"node-fetch": "^2.6.6",
"node-ical": "^0.13.0",
"socket.io": "^4.4.0"
"socket.io": "^4.4.1"
},
"_moduleAliases": {
"node_helper": "js/node_helper.js",
@ -94,7 +94,8 @@
},
"jest": {
"verbose": true,
"testTimeout": 10000,
"testTimeout": 15000,
"testSequencer": "<rootDir>/tests/configs/test_sequencer.js",
"projects": [
{
"displayName": "unit",

View File

@ -0,0 +1,27 @@
/* Magic Mirror Test config default weather
*
* By fewieden https://github.com/fewieden
* MIT Licensed.
*/
let config = {
timeFormat: 12,
modules: [
{
module: "weather",
position: "bottom_bar",
config: {
type: "forecast",
location: "Munich",
mockData: '"#####WEATHERDATA#####"',
weatherEndpoint: "/forecast/daily",
absoluteDates: true
}
}
]
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {
module.exports = config;
}

View File

@ -0,0 +1,26 @@
const TestSequencer = require("@jest/test-sequencer").default;
class CustomSequencer extends TestSequencer {
sort(tests) {
const orderPath = ["unit", "e2e", "electron"];
return tests.sort((testA, testB) => {
let indexA = -1;
let indexB = -1;
const reg = ".*/tests/([^/]*).*";
let matchA = new RegExp(reg, "g").exec(testA.path);
if (matchA.length > 0) indexA = orderPath.indexOf(matchA[1]);
let matchB = new RegExp(reg, "g").exec(testB.path);
if (matchB.length > 0) indexB = orderPath.indexOf(matchB[1]);
if (indexA === indexB) return 0;
if (indexA === -1) return 1;
if (indexB === -1) return -1;
return indexA < indexB ? -1 : 1;
});
}
}
module.exports = CustomSequencer;

View File

@ -1,5 +1,6 @@
const helpers = require("../global-setup");
const serverBasicAuth = require("./basic-auth.js");
const testDelay = 4000;
describe("Calendar module", function () {
/**
@ -24,7 +25,7 @@ describe("Calendar module", function () {
describe("Default configuration", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/calendar/default.js");
helpers.getDocument(done, 3000);
helpers.getDocument(done, testDelay);
});
it("should show the default maximumEntries of 10", () => {
@ -39,7 +40,7 @@ describe("Calendar module", function () {
describe("Custom configuration", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/calendar/custom.js");
helpers.getDocument(done, 3000);
helpers.getDocument(done, testDelay);
});
it("should show the custom maximumEntries of 4", () => {
@ -62,7 +63,7 @@ describe("Calendar module", function () {
describe("Recurring event", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/calendar/recurring.js");
helpers.getDocument(done, 3000);
helpers.getDocument(done, testDelay);
});
it("should show the recurring birthday event 6 times", () => {
@ -78,7 +79,7 @@ describe("Calendar module", function () {
return i * 60;
};
helpers.startApplication("tests/configs/modules/calendar/recurring.js");
helpers.getDocument(done, 3000);
helpers.getDocument(done, testDelay);
});
it('should contain text "Mar 25th" in timezone UTC ' + -i, () => {
@ -93,7 +94,7 @@ describe("Calendar module", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/calendar/changed-port.js");
serverBasicAuth.listen(8010);
helpers.getDocument(done, 3000);
helpers.getDocument(done, testDelay);
});
afterAll(function (done) {
@ -108,7 +109,7 @@ describe("Calendar module", function () {
describe("Basic auth", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/calendar/basic-auth.js");
helpers.getDocument(done, 3000);
helpers.getDocument(done, testDelay);
});
it("should return TestEvents", function () {
@ -119,7 +120,7 @@ describe("Calendar module", function () {
describe("Basic auth by default", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/calendar/auth-default.js");
helpers.getDocument(done, 3000);
helpers.getDocument(done, testDelay);
});
it("should return TestEvents", function () {
@ -130,7 +131,7 @@ describe("Calendar module", function () {
describe("Basic auth backward compatibility configuration: DEPRECATED", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/calendar/old-basic-auth.js");
helpers.getDocument(done, 3000);
helpers.getDocument(done, testDelay);
});
it("should return TestEvents", function () {
@ -142,7 +143,7 @@ describe("Calendar module", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/calendar/fail-basic-auth.js");
serverBasicAuth.listen(8020);
helpers.getDocument(done, 3000);
helpers.getDocument(done, testDelay);
});
afterAll(function (done) {

View File

@ -1,4 +1,5 @@
const helpers = require("../global-setup");
const testDelay = 4000;
describe("Newsfeed module", function () {
afterAll(function () {
@ -8,7 +9,7 @@ describe("Newsfeed module", function () {
describe("Default configuration", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/newsfeed/default.js");
helpers.getDocument(done, 3000);
helpers.getDocument(done, testDelay);
});
it("should show the newsfeed title", function () {
@ -32,7 +33,7 @@ describe("Newsfeed module", function () {
describe("Custom configuration", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/newsfeed/prohibited_words.js");
helpers.getDocument(done, 3000);
helpers.getDocument(done, testDelay);
});
it("should not show articles with prohibited words", function () {
@ -51,7 +52,7 @@ describe("Newsfeed module", function () {
describe("Invalid configuration", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/newsfeed/incorrect_url.js");
helpers.getDocument(done, 3000);
helpers.getDocument(done, testDelay);
});
it("should show malformed url warning", function () {
@ -64,7 +65,7 @@ describe("Newsfeed module", function () {
describe("Ignore items", function () {
beforeAll(function (done) {
helpers.startApplication("tests/configs/modules/newsfeed/ignore_items.js");
helpers.getDocument(done, 3000);
helpers.getDocument(done, testDelay);
});
it("should show empty items info message", function () {

View File

@ -210,6 +210,20 @@ describe("Weather module", function () {
});
});
describe("Absolute configuration", function () {
beforeAll(function (done) {
startApp("tests/configs/modules/weather/forecastweather_absolute.js", {}, done);
});
it("should render days", function () {
const days = ["Fri", "Sat", "Sun", "Mon", "Tue"];
for (const [index, day] of days.entries()) {
getText(`.weather table.small tr:nth-child(${index + 1}) td:nth-child(1)`, day);
}
});
});
describe("Configuration Options", function () {
beforeAll(function (done) {
startApp("tests/configs/modules/weather/forecastweather_options.js", {}, done);

14
vendor/package-lock.json generated vendored
View File

@ -9,7 +9,7 @@
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.4",
"moment": "^2.29.1",
"moment-timezone": "^0.5.33",
"moment-timezone": "^0.5.34",
"nunjucks": "^3.2.3",
"suncalc": "^1.8.0",
"weathericons": "^2.1.0"
@ -51,9 +51,9 @@
}
},
"node_modules/moment-timezone": {
"version": "0.5.33",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.33.tgz",
"integrity": "sha512-PTc2vcT8K9J5/9rDEPe5czSIKgLoGsH8UNpA4qZTVw0Vd/Uz19geE9abbIOQKaAQFcnQ3v5YEXrbSc5BpshH+w==",
"version": "0.5.34",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.34.tgz",
"integrity": "sha512-3zAEHh2hKUs3EXLESx/wsgw6IQdusOT8Bxm3D9UrHPQR7zlMmzwybC8zHEM1tQ4LJwP7fcxrWr8tuBg05fFCbg==",
"dependencies": {
"moment": ">= 2.9.0"
},
@ -123,9 +123,9 @@
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
},
"moment-timezone": {
"version": "0.5.33",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.33.tgz",
"integrity": "sha512-PTc2vcT8K9J5/9rDEPe5czSIKgLoGsH8UNpA4qZTVw0Vd/Uz19geE9abbIOQKaAQFcnQ3v5YEXrbSc5BpshH+w==",
"version": "0.5.34",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.34.tgz",
"integrity": "sha512-3zAEHh2hKUs3EXLESx/wsgw6IQdusOT8Bxm3D9UrHPQR7zlMmzwybC8zHEM1tQ4LJwP7fcxrWr8tuBg05fFCbg==",
"requires": {
"moment": ">= 2.9.0"
}

2
vendor/package.json vendored
View File

@ -12,7 +12,7 @@
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.4",
"moment": "^2.29.1",
"moment-timezone": "^0.5.33",
"moment-timezone": "^0.5.34",
"nunjucks": "^3.2.3",
"suncalc": "^1.8.0",
"weathericons": "^2.1.0"