Skip to content

Commit 0300ce0

Browse files
MichMichkhasselSkySailsrejasveeck
authored
Release 2.22.0 (#2983)
## [2.22.0] - 2023-01-01 Thanks to: @angeldeejay, @buxxi, @dariom, @dWoolridge, @KristjanESPERANTO, @MagMar94, @naveensrinivasan, @retroflex, @SkySails and @tom. Special thanks to @khassel, @rejas and @sdetweil for taking over most (if not all) of the work on this release as project collaborators. This version would not be there without their effort. Thank you! ### Added - Added test for remoteFile option in compliments module - Added hourlyWeather functionality to Weather.gov weather provider - Removed weatherEndpoint definition from weathergov.js (not used) - Added css class names "today" and "tomorrow" for default calendar - Added Collaboration.md - Added new github action for dependency review (#2862) - Added a WeatherProvider for Open-Meteo - Added Yr as a weather provider - Added config options "ignoreXOriginHeader" and "ignoreContentSecurityPolicy" ### Removed - Removed usage of internal fetch function of node until it is more stable ### Updated - Cleaned up test directory (#2937) and jest config (#2959) - Wait for all modules to start before declaring the system ready (#2487) - Updated e2e tests (moved `done()` in helper functions) and use es6 syntax in all tests - Updated da translation - Rework weather module - Make sure smhi provider api only gets a maximum of 6 digits coordinates (#2955) - Use fetch instead of XMLHttpRequest in weatherprovider (#2935) - Reworked how weatherproviders handle units (#2849) - Use unix() method for parsing times, fix suntimes on the way (#2950) - Refactor conversion functions into utils class (#2958) - The `cors`-method in `server.js` now supports sending and recieving HTTP headers - Replace `&hellip;` by `…` - Cleanup compliments module - Updated dependencies including electron to v22 (#2903) ### Fixed - Correctly show apparent temperature in SMHI weather provider - Ensure updatenotification module isn't shown when local is _ahead_ of remote - Handle node_helper errors during startup (#2944) - Possibility to change FontAwesome class in calendar, so icons like `fab fa-facebook-square` works. - Fix cors problems with newsfeed articles (as far as possible), allow disabling cors per feed with option `useCorsProxy: false` (#2840) - Tests not waiting for the application to start and stop before starting the next test - Fix electron tests failing sometimes in github workflow - Fixed gap in clock module when displayed on the left side with displayType=digital - Fixed playwright issue by upgrading to v1.29.1 (#2969) Signed-off-by: naveen <[email protected]> Co-authored-by: Karsten Hassel <[email protected]> Co-authored-by: Malte Hallström <[email protected]> Co-authored-by: Veeck <[email protected]> Co-authored-by: veeck <[email protected]> Co-authored-by: dWoolridge <[email protected]> Co-authored-by: Johan <[email protected]> Co-authored-by: Dario Mratovich <[email protected]> Co-authored-by: Dario Mratovich <[email protected]> Co-authored-by: Magnus <[email protected]> Co-authored-by: Naveen <[email protected]> Co-authored-by: buxxi <[email protected]> Co-authored-by: Thomas Hirschberger <[email protected]> Co-authored-by: Kristjan ESPERANTO <[email protected]> Co-authored-by: Andrés Vanegas Jiménez <[email protected]>
1 parent 9e02930 commit 0300ce0

File tree

151 files changed

+5895
-4954
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+5895
-4954
lines changed

.github/workflows/depsreview.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: "Dependency Review"
2+
on: [pull_request]
3+
4+
permissions:
5+
contents: read
6+
7+
jobs:
8+
dependency-review:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: "Checkout Repository"
12+
uses: actions/checkout@v3
13+
- name: "Dependency Review"
14+
uses: actions/dependency-review-action@v2

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ vendor/node_modules/**/*
1616
jspm_modules
1717
.npm
1818
.node_repl_history
19-
.nyc_output/
2019

2120
# Visual Studio Code ignoramuses.
2221
.vscode/

.prettierignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
/config
22
/coverage
3-
.nyc_output
43
package-lock.json

CHANGELOG.md

Lines changed: 62 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,82 @@ This project adheres to [Semantic Versioning](https://semver.org/).
55

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

8+
## [2.22.0] - 2023-01-01
9+
10+
Thanks to: @angeldeejay, @buxxi, @dariom, @dWoolridge, @KristjanESPERANTO, @MagMar94, @naveensrinivasan, @retroflex, @SkySails and @Tom.
11+
12+
Special thanks to @khassel, @rejas and @sdetweil for taking over most (if not all) of the work on this release as project collaborators. This version would not be there without their effort. Thank you!
13+
14+
### Added
15+
16+
- Added test for remoteFile option in compliments module
17+
- Added hourlyWeather functionality to Weather.gov weather provider
18+
- Removed weatherEndpoint definition from weathergov.js (not used)
19+
- Added css class names "today" and "tomorrow" for default calendar
20+
- Added Collaboration.md
21+
- Added new github action for dependency review (#2862)
22+
- Added a WeatherProvider for Open-Meteo
23+
- Added Yr as a weather provider
24+
- Added config options "ignoreXOriginHeader" and "ignoreContentSecurityPolicy"
25+
26+
### Removed
27+
28+
- Removed usage of internal fetch function of node until it is more stable
29+
30+
### Updated
31+
32+
- Cleaned up test directory (#2937) and jest config (#2959)
33+
- Wait for all modules to start before declaring the system ready (#2487)
34+
- Updated e2e tests (moved `done()` in helper functions) and use es6 syntax in all tests
35+
- Updated da translation
36+
- Rework weather module
37+
- Make sure smhi provider api only gets a maximum of 6 digits coordinates (#2955)
38+
- Use fetch instead of XMLHttpRequest in weatherprovider (#2935)
39+
- Reworked how weatherproviders handle units (#2849)
40+
- Use unix() method for parsing times, fix suntimes on the way (#2950)
41+
- Refactor conversion functions into utils class (#2958)
42+
- The `cors`-method in `server.js` now supports sending and recieving HTTP headers
43+
- Replace `&hellip;` by ``
44+
- Cleanup compliments module
45+
- Updated dependencies including electron to v22 (#2903)
46+
47+
### Fixed
48+
49+
- Correctly show apparent temperature in SMHI weather provider
50+
- Ensure updatenotification module isn't shown when local is _ahead_ of remote
51+
- Handle node_helper errors during startup (#2944)
52+
- Possibility to change FontAwesome class in calendar, so icons like `fab fa-facebook-square` works.
53+
- Fix cors problems with newsfeed articles (as far as possible), allow disabling cors per feed with option `useCorsProxy: false` (#2840)
54+
- Tests not waiting for the application to start and stop before starting the next test
55+
- Fix electron tests failing sometimes in github workflow
56+
- Fixed gap in clock module when displayed on the left side with displayType=digital
57+
- Fixed playwright issue by upgrading to v1.29.1 (#2969)
58+
859
## [2.21.0] - 2022-10-01
960

1061
Special thanks to: @BKeyport, @buxxi, @davide125, @khassel, @kolbyjack, @krukle, @MikeBishop, @rejas, @sdetweil, @SkySails and @veeck
1162

12-
## Added
63+
### Added
1364

14-
- Possibility to fetch calendars through socket notifications.
65+
- Added possibility to fetch calendars through socket notifications.
1566
- New scripts `install-mm` (and `install-mm:dev`) for simplifying mm installation (now: `npm run install-mm`) and adding params `--no-audit --no-fund --no-update-notifier` for less noise.
1667
- New `showTimeToday` option in calendar module shows time for current-day events even if `timeFormat` is `"relative"`.
17-
- Add hourly forecasts, apparent temperature & custom location name to SMHI weather provider.
68+
- Added hourly forecasts, apparent temperature & custom location name to SMHI weather provider.
69+
- Added new electron tests for calendar and moved some compliments tests from `e2e` to `electron` because of date mocking, removed mock stuff from compliments module.
1870

19-
## Removed
71+
### Removed
2072

21-
- Old weather deprecated modules `currentweather` and `weatherforecast`.
73+
- Removed old and deprecated weather modules `currentweather` and `weatherforecast`.
74+
- Removed `DAYAFTERTOMORROW` from English.
2275

23-
## Updated
76+
### Updated
2477

25-
- Removed `DAYAFTERTOMORROW` from English.
26-
- Update dependencies.
78+
- Updated dependencies.
2779
- Updated jsdoc.
28-
- Updated font tree to use variables consistantly.
80+
- Updated font tree to use variables consistently.
2981
- Removed deprecated Docker Repository from issue template.
3082

31-
## Fixed
83+
### Fixed
3284

3385
- Broadcast all calendar events while still honoring global and per-calendar maximumEntries.
3486
- Respect rss ttl provided by newsfeed (#2883).

Collaboration.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
This document describes how collaborators of this repository should work together.
2+
3+
## Pull Requests
4+
5+
- never merge your own PR's
6+
- never merge without someone having approved (approving and merging from same person is allowed)
7+
- wait for all approvals requested (or the author decides something different in the comments)
8+
9+
## Issues
10+
11+
- "real" Issues are closed if the problem is solved and the fix is released
12+
- unrelated Issues (e.g. related to a foreign module) are closed immediately with a comment to open an issue in the module repository or to discuss this further in the forum or discord

jest.config.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module.exports = async () => {
2+
return {
3+
verbose: true,
4+
testTimeout: 20000,
5+
testSequencer: "<rootDir>/tests/configs/test_sequencer.js",
6+
projects: [
7+
{
8+
displayName: "unit",
9+
moduleNameMapper: {
10+
logger: "<rootDir>/js/logger.js"
11+
},
12+
testMatch: ["**/tests/unit/**/*.[jt]s?(x)"],
13+
testPathIgnorePatterns: ["<rootDir>/tests/unit/mocks"]
14+
},
15+
{
16+
displayName: "electron",
17+
testMatch: ["**/tests/electron/**/*.[jt]s?(x)"],
18+
testPathIgnorePatterns: ["<rootDir>/tests/electron/helpers/"]
19+
},
20+
{
21+
displayName: "e2e",
22+
setupFilesAfterEnv: ["<rootDir>/tests/e2e/helpers/mock-console.js"],
23+
testMatch: ["**/tests/e2e/**/*.[jt]s?(x)"],
24+
modulePaths: ["<rootDir>/js/"],
25+
testPathIgnorePatterns: ["<rootDir>/tests/e2e/helpers/", "<rootDir>/tests/e2e/mocks"]
26+
}
27+
],
28+
collectCoverageFrom: ["./clientonly/**/*.js", "./js/**/*.js", "./modules/**/*.js", "./serveronly/**/*.js"],
29+
coverageReporters: ["lcov", "text"],
30+
coverageProvider: "v8"
31+
};
32+
};

js/app.js

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,33 @@ function App() {
222222
}
223223
}
224224

225-
loadModules(modules, function () {
226-
httpServer = new Server(config, function (app, io) {
227-
Log.log("Server started ...");
228-
229-
for (let nodeHelper of nodeHelpers) {
230-
nodeHelper.setExpressApp(app);
231-
nodeHelper.setSocketIO(io);
232-
nodeHelper.start();
225+
loadModules(modules, async function () {
226+
httpServer = new Server(config);
227+
const { app, io } = await httpServer.open();
228+
Log.log("Server started ...");
229+
230+
const nodePromises = [];
231+
for (let nodeHelper of nodeHelpers) {
232+
nodeHelper.setExpressApp(app);
233+
nodeHelper.setSocketIO(io);
234+
235+
try {
236+
nodePromises.push(nodeHelper.start());
237+
} catch (error) {
238+
Log.error(`Error when starting node_helper for module ${nodeHelper.name}:`);
239+
Log.error(error);
233240
}
241+
}
234242

235-
Log.log("Sockets connected & modules started ...");
243+
Promise.allSettled(nodePromises).then((results) => {
244+
// Log errors that happened during async node_helper startup
245+
results.forEach((result) => {
246+
if (result.status === "rejected") {
247+
Log.error(result.reason);
248+
}
249+
});
236250

251+
Log.log("Sockets connected & modules started ...");
237252
if (typeof callback === "function") {
238253
callback(config);
239254
}
@@ -247,14 +262,16 @@ function App() {
247262
* exists.
248263
*
249264
* Added to fix #1056
265+
*
266+
* @param {Function} callback Function to be called after the app has stopped
250267
*/
251-
this.stop = function () {
268+
this.stop = function (callback) {
252269
for (const nodeHelper of nodeHelpers) {
253270
if (typeof nodeHelper.stop === "function") {
254271
nodeHelper.stop();
255272
}
256273
}
257-
httpServer.close();
274+
httpServer.close().then(callback);
258275
};
259276

260277
/**

js/electron.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ function createWindow() {
103103
}, 1000);
104104
});
105105
}
106+
107+
//remove response headers that prevent sites of being embedded into iframes if configured
108+
mainWindow.webContents.session.webRequest.onHeadersReceived((details, callback) => {
109+
let curHeaders = details.responseHeaders;
110+
if (config["ignoreXOriginHeader"] || false) {
111+
curHeaders = Object.fromEntries(Object.entries(curHeaders).filter((header) => !/x-frame-options/i.test(header[0])));
112+
}
113+
114+
if (config["ignoreContentSecurityPolicy"] || false) {
115+
curHeaders = Object.fromEntries(Object.entries(curHeaders).filter((header) => !/content-security-policy/i.test(header[0])));
116+
}
117+
118+
callback({ responseHeaders: curHeaders });
119+
});
106120
}
107121

108122
// This method will be called when Electron has finished

js/fetch.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
/**
2-
* fetch
2+
* Helper class to provide either third party fetch library or (if node >= 18)
3+
* return internal node fetch implementation.
34
*
5+
* Attention: After some discussion we always return the third party
6+
* implementation until the node implementation is stable and more tested
7+
*
8+
* @see https://github.com/MichMich/MagicMirror/pull/2952
9+
* @see https://github.com/MichMich/MagicMirror/issues/2649
410
* @param {string} url to be fetched
511
* @param {object} options object e.g. for headers
612
* @class
713
*/
8-
async function fetch(url, options) {
9-
const nodeVersion = process.version.match(/^v(\d+)\.*/)[1];
10-
if (nodeVersion >= 18) {
11-
// node version >= 18
12-
return global.fetch(url, options);
13-
} else {
14-
// node version < 18
15-
const nodefetch = require("node-fetch");
16-
return nodefetch(url, options);
17-
}
14+
async function fetch(url, options = {}) {
15+
// const nodeVersion = process.version.match(/^v(\d+)\.*/)[1];
16+
// if (nodeVersion >= 18) {
17+
// // node version >= 18
18+
// return global.fetch(url, options);
19+
// } else {
20+
// // node version < 18
21+
// const nodefetch = require("node-fetch");
22+
// return nodefetch(url, options);
23+
// }
24+
const nodefetch = require("node-fetch");
25+
return nodefetch(url, options);
1826
}
1927

2028
module.exports = fetch;

js/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const MM = (function () {
7070
* Select the wrapper dom object for a specific position.
7171
*
7272
* @param {string} position The name of the position.
73-
* @returns {HTMLElement} the wrapper element
73+
* @returns {HTMLElement | void} the wrapper element
7474
*/
7575
const selectWrapper = function (position) {
7676
const classes = position.replace("_", " ");

0 commit comments

Comments
 (0)