Commit Graph

1373 Commits

Author SHA1 Message Date
Kristjan ESPERANTO
d81386f3d9 chore: use prettier --write --ignore-unknown in lint-staged to avoid errors on unsupported files (#3888)
This prevents `prettier` from failing when `lint-staged` passes
unknown/binary files, making the pre-commit hook more robust.

In concrete terms this could happen, when we, for example, add a new PNG
file. Since we rarely do this, it has not been noticed so far.

This is recommended when using asterisk:
https://github.com/lint-staged/lint-staged#automatically-fix-code-style-with-prettier-for-any-format-prettier-supports

## before

```bash
$ npx lint-staged <-- after staging a new PNG file
✔ Backed up original state in git stash (c3247d4b)
✔ Hiding unstaged changes to partially staged files...
⚠ Running tasks for staged files...
  ❯ package.json — 2 files
    ❯ * — 2 files
      ✖ prettier --write [FAILED]
    ↓ *.js — no files
    ↓ *.css — no files
↓ Skipped because of errors from tasks.
↓ Skipped because of errors from tasks.
✔ Reverting to original state because of errors...
✔ Cleaning up temporary files...

✖ prettier --write:
[error] No parser could be inferred for file "~/MagicMirror/test.png".
...
```

## after

```bash
$ npx lint-staged <-- after staging a new PNG file
✔ Backed up original state in git stash (0c3fe285)
✔ Running tasks for staged files...
✔ Applying modifications from tasks...
✔ Cleaning up temporary files...
```
2025-09-11 18:34:08 +02:00
Veeck
08d29c3083 Add Prettier plugin for Nunjuck templates (#3887) 2025-09-11 13:10:53 +02:00
Karsten Hassel
3260b9dfe4 add test for config:check (#3886) 2025-09-11 13:08:56 +02:00
Karsten Hassel
2481bc621f revert changes breaking node --run config:check (#3885) 2025-09-10 07:55:05 +02:00
Karsten Hassel
b1865d8115 refactor: use global.root_path instead relative paths (#3883) 2025-09-09 08:09:45 +02:00
Veeck
31bafc3297 update default icon for calendars (#3879)
While looking at
https://github.com/MagicMirrorOrg/MagicMirror-Documentation/issues/114 I
noticed that the default icon is not named correctly.

`calendar-alt` should be called `calendar-days` which seems to be its
fallback anyways.

I also updated the link to the icon search

---------

Co-authored-by: veeck <gitkraken@veeck.de>
Co-authored-by: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com>
2025-09-08 14:42:13 +02:00
Veeck
d277a276e7 Bump github actions and dependencies (#3882)
as suggested by dependabot
[here](https://github.com/MagicMirrorOrg/MagicMirror/pull/3880) and
[here](https://github.com/MagicMirrorOrg/MagicMirror/pull/3881)
also bumped the dependencies while at it

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: veeck <gitkraken@veeck.de>
2025-09-08 14:29:06 +02:00
Karsten Hassel
be957af6a6 bump minimal node version to v22.18.0 (#3877)
electron uses node v22.18 in its [current
releases](https://releases.electronjs.org/), so we should go hand in
hand and use that as the minimal node version
2025-09-04 07:07:15 +02:00
Karsten Hassel
93d5df8d04 update electron to v38 (#3876) 2025-09-03 23:59:54 +02:00
Veeck
6f4eab9535 [core] bump dependencies into september (#3872)
nothing fancy in these though

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: veeck <gitkraken@veeck.de>
2025-09-01 21:23:24 +02:00
Veeck
25efe4204f Update feels_like temperature formula (#3869)
The current logic never showed any different temperature than the
current one, so I looked into a more "explained" formula and found one
in the HomeAssistant forums.
2025-09-01 15:12:52 +02:00
Veeck
f8679b6ba8 [weather] use 'apparent_temperature' in openmeteos data for feelsLike temperature (#3868) 2025-08-30 13:00:00 +02:00
Kristjan ESPERANTO
fad8bbaeb1 test: add alert module tests for different welcome_message configurations (#3867)
In this way, all options for `welcome_message` are tested.
2025-08-28 23:17:44 +02:00
Kristjan ESPERANTO
4c0a4689c3 [tests] refactor translation tests (#3866)
- Remove `sinon` dependency in favor of Jest native mocking
  - Unify test helper functions across translation test suites
- Rename `setupDOMEnvironment` to `createTranslationTestEnvironment` for
consistency
  - Simplify DOM setup by removing unnecessary Promise/async patterns
- Avoid potential port conflicts by using port 3001 for translator unit
tests
  - Improve test reliability and maintainability
2025-08-28 21:26:50 +02:00
sam detweiler
eb719429d4 fix for #3380, socket.io timeout closure (#3862)
socket.io times out and closes the client side socket without any
callback
sendSocntNotification() from the server side data is lost as the socket
is closed. but the client doesn't know

increase the timeout 

fixes #3380
2025-08-28 18:02:21 +02:00
sam detweiler
3387bf8db0 fix regression #3841 (#3865)
fixes #3841

this is a correction of the rewrite
2025-08-28 16:50:12 +02:00
sam detweiler
483d3cd4e6 Fix limitdays regression (#3863)
fixes #3840 

this is a rewrite

---------

Co-authored-by: veeck <gitkraken@veeck.de>
2025-08-28 16:13:29 +02:00
Karsten Hassel
787fbda85b tests: update jest snapshot url (#3861)
This is not a cosmetic change because jest errors when run with
`CI=true`.

I got this error when running unit tests in gitlab:

```bash
FAIL unit tests/unit/functions/updatenotification_spec.js
  ● Test suite failed to run
    Outdated guide link: The snapshot guide link is outdated.Please update all snapshots while upgrading of Jest
    Expected: https://jestjs.io/docs/snapshot-testing
    Received: https://goo.gl/fbAQLP
      at validateSnapshotHeader (node_modules/@jest/snapshot-utils/build/index.js:104:12)
      at getSnapshotData (node_modules/@jest/snapshot-utils/build/index.js:156:28)
```

If you run the test without `CI=true` jest will update the file.
2025-08-27 21:16:38 +02:00
Marcel
76da0aa55e Make User-Agent configurable (#3255)
Fixes #3253 

Adds a configuration option to overwrite the default `User-Agent` header
that is send at least by the calendar and news module. Allows other
modules to use the individual user agent as well.

The configuration accepts either a string or a function:
```
var config =
	{
		...
		userAgent: 'Mozilla/5.0 (My User Agent)',
		...
	}
```
or
```
var config =
	{
		...
		userAgent: () => 'Mozilla/5.0 (My User Agent)',
		...
	}
```

---------

Co-authored-by: Veeck <github@veeck.de>
Co-authored-by: veeck <gitkraken@veeck.de>
Co-authored-by: Karsten Hassel <hassel@gmx.de>
Co-authored-by: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com>
2025-08-27 13:50:37 +02:00
Kristjan ESPERANTO
83d15aaaaa tests: add setupDOMEnvironment helper function to eliminate repetitive JSDOM setup code (#3860)
The helper function allows to remove a lot of repetitive code, making
the tests clearer and easier to maintain.
2025-08-19 22:46:59 +02:00
Veeck
1b31cf19e9 Thoroughly check for precipitationAmount values in weathergov provider (#3859)
Fixes #3856

---------

Co-authored-by: veeck <gitkraken@veeck.de>
2025-08-16 20:56:52 +02:00
Veeck
0ca7d23b69 update github actions (#3858)
actions/checkout got updated last night

---------

Co-authored-by: veeck <gitkraken@veeck.de>
2025-08-12 21:14:41 +02:00
Veeck
839d074df1 Update dependencies (#3857)
Just some normal maintainance after the holidays

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: veeck <gitkraken@veeck.de>
2025-08-11 12:49:03 +02:00
Karsten Hassel
e34ef0cb6e update dependencies (#3849) 2025-07-22 22:09:29 +02:00
Karsten Hassel
3fa2b96054 cleanup and try to stabilize weather e2e tests (#3848)
The weather e2e tests are failing sometimes, failing is not really
reproducable.

After changing `updateDom(0)` to `updateDom(300)` in `weather.js` it
seems to work (we will se if it really works in the long term).

This PR contains some other weather e2e changes/cleanups/simplifying.
2025-07-20 08:23:52 +02:00
Karsten Hassel
e7b669af34 e2e: decrease stop app waitTime (#3847) 2025-07-16 23:54:02 +02:00
Karsten Hassel
54752f10e8 replace console with Log in calendar debug.js (#3846)
to avoid exception in eslint config.

Background: If someone has a copy of the `modules` folder in his setup
eslint fails because the file `debug.js` uses `console` statements. I
need the `modules` folder renamed in my docker setup so this test always
fails. I think this is a simple solution which has no impact.
2025-07-16 00:38:03 +02:00
Kristjan ESPERANTO
02e76da196 refactor: extract constants for weather electron tests (#3845)
I find the tests with clear variable names much easier to understand.
2025-07-15 00:27:35 +02:00
Kristjan ESPERANTO
7f8935a34c refactor: simplify jest config (#3844)
- changed export from async to sync function - this removes unnecessary
complexity
- reformatted `collectCoverageFrom` to use `<rootDir>` for each pattern
and switch to multi-line style - this is just harmonization
2025-07-13 21:32:58 +02:00
Kristjan ESPERANTO
931fe55022 refactor: optimize system information logging (#3843)
Additionally to #3839 did some rework on the system logging.

- feat: include MagicMirror version (like Sam suggested in #3839)
- refactor: use more variables to get the string array less complex
- refactor: get `installedNodeVersion` from si.versions (with that it
was possible to drop the import of `execSync`)
- fix: `used node` was always the same as the installed one. Since
Electron comes with its own node version, this can differ. This is now
shown correctly (again?) with the use of `process.version`.
- a bit formatting

I think these changes make the code easier to understand and therefore
easier to maintain. Except for showing the MM version there is no big
difference for the user.

## before

```bash
#####  System Information  #####
- SYSTEM:    manufacturer: Notebook; model: N650DU; virtual: false; timeZone: Europe/Berlin
- OS:        platform: linux; distro: Debian GNU/Linux; release: 12; arch: x64; kernel: 5.10.0-20-amd64
- VERSIONS:  electron: 36.3.2; used node: 22.15.0; installed node: 22.15.0; npm: 10.9.0; pm2: 6.0.6
- ENV:       XDG_SESSION_TYPE: wayland; MM_CONFIG_FILE: config/config_MMM-PublicTransportHafas.js;
             WAYLAND_DISPLAY:  wayland-0; DISPLAY: :0; ELECTRON_ENABLE_GPU: undefined
- RAM:       total: 15925.45 MB; free: 2716.90 MB; used: 13209.04 MB
- UPTIME:    259 minutes 
```

## after

```bash
####  System Information  ####
- SYSTEM:   manufacturer: Notebook; model: N650DU; virtual: false; MM: 2.33.0-develop
- OS:       platform: linux; distro: Debian GNU/Linux; release: 12; arch: x64; kernel: 5.10.0-20-amd64
- VERSIONS: electron: 36.3.2; used node: 22.15.1; installed node: 22.15.0; npm: 10.9.0; pm2: 6.0.6
- ENV:      XDG_SESSION_TYPE: wayland; MM_CONFIG_FILE: config/config_MMM-PublicTransportHafas.js
            WAYLAND_DISPLAY:  wayland-0; DISPLAY: :0; ELECTRON_ENABLE_GPU: undefined
- RAM:      total: 15925.45 MB; free: 2814.49 MB; used: 13110.96 MB
- OTHERS:   uptime: 260 minutes; timeZone: Europe/Berlin 
```
2025-07-12 08:24:09 +02:00
Karsten Hassel
a05eb23306 refactor default modules: move scheduleTimer to one place (#3837)
see #3819

---------

Co-authored-by: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com>
Co-authored-by: Veeck <github@veeck.de>
2025-07-10 08:12:09 +02:00
Kristjan ESPERANTO
e115475a9d feat: enhance system information logging format and include additional env and RAM details (#3839)
When we introduced the system information, I selected `###` as the
prefix for each line. While this doesn't cause any problems in the
terminal, when someone copies the output to an issue or the forum, every
line is formatted as a heading, which is not ideal. That's why I made
some rework and suggest these changes.

In addition to the formatting changes, I added some env and RAM details
plus the uptime. These are just suggestions – if you don't think they're
worth adding, I'm happy to remove them. We wanted to keep this block
compact.

@sdetweil, since you are often on the front line with the error messages
from users: Is there any information missing in the system block that
you often have to request additionally?

Feel free to request changes!

-----

## in the terminal

### before

```
[2025-07-09 21:58:36.943] [INFO]  System information:
### SYSTEM:   manufacturer: Notebook; model: N650DU; virtual: false
### OS:       platform: linux; distro: Debian GNU/Linux; release: 12; arch: x64; kernel: 5.10.0-20-amd64
### VERSIONS: electron: 36.3.2; used node: 24.2.0; installed node: 24.2.0; npm: 10.9.0; pm2: 6.0.6
### OTHER:    timeZone: Europe/Berlin; ELECTRON_ENABLE_GPU: undefined 
```

-----

### after

```
[2025-07-09 21:57:47.604] [INFO]  
#####  System Information  #####
- SYSTEM:    manufacturer: Notebook; model: N650DU; virtual: false; timeZone: Europe/Berlin
- OS:        platform: linux; distro: Debian GNU/Linux; release: 12; arch: x64; kernel: 5.10.0-20-amd64
- VERSIONS:  electron: 36.3.2; used node: 24.2.0; installed node: 24.2.0; npm: 10.9.0; pm2: 6.0.6
- ENV:       XDG_SESSION_TYPE: wayland; MM_CONFIG_FILE: undefined;
             WAYLAND_DISPLAY:  wayland-0; DISPLAY: :0; ELECTRON_ENABLE_GPU: undefined
- RAM:       total: 15925.45 MB; free: 967.75 MB; used: 14957.70 MB
- UPTIME:    172 minutes 
```

-----

## as markdown (in an issue or the forum)

### before

[2025-07-09 21:58:36.943] [INFO]  System information:
### SYSTEM:   manufacturer: Notebook; model: N650DU; virtual: false
### OS: platform: linux; distro: Debian GNU/Linux; release: 12; arch:
x64; kernel: 5.10.0-20-amd64
### VERSIONS: electron: 36.3.2; used node: 24.2.0; installed node:
24.2.0; npm: 10.9.0; pm2: 6.0.6
### OTHER:    timeZone: Europe/Berlin; ELECTRON_ENABLE_GPU: undefined 

-----

### after

[2025-07-09 21:57:47.604] [INFO]  
#####  System Information  #####
- SYSTEM: manufacturer: Notebook; model: N650DU; virtual: false;
timeZone: Europe/Berlin
- OS: platform: linux; distro: Debian GNU/Linux; release: 12; arch: x64;
kernel: 5.10.0-20-amd64
- VERSIONS: electron: 36.3.2; used node: 24.2.0; installed node: 24.2.0;
npm: 10.9.0; pm2: 6.0.6
- ENV:       XDG_SESSION_TYPE: wayland; MM_CONFIG_FILE: undefined;
WAYLAND_DISPLAY: wayland-0; DISPLAY: :0; ELECTRON_ENABLE_GPU: undefined
- RAM:       total: 15925.45 MB; free: 967.75 MB; used: 14957.70 MB
- UPTIME:    172 minutes
2025-07-10 07:39:23 +02:00
Veeck
e4ec8c3589 Fix missing icons in clock module (#3834)
Fixes #3818

---------

Co-authored-by: veeck <gitkraken@veeck.de>
2025-07-05 22:47:38 +02:00
Koen Konst
d9e2e0272f Fix calendar unit test so it uses 1 day more than a full year for yearly recurring events test (#3833) 2025-07-02 22:03:41 +02:00
dathbe
3a2a52c864 Add CSS to clock module to prevent line breaking of sunrise/sunset information (#3816)
1. Base your pull requests against the `develop` branch.
Done
2. Include these infos in the description:
- Does the pull request solve a **related** issue?
No
- If so, can you reference the issue like this `Fixes #<issue_number>`?
N/A
- What does the pull request accomplish? Use a list if needed.
With some combinations of sunrise and sunset times (usually when the
time till rise/set is >9:59), the information will break across multiple
lines. This prevents that by adding CSS.
- If it includes major visual changes please add screenshots.
I don't consider it major.
3. Please run `npm run lint:prettier` before submitting so that style
issues are fixed.
Done
4. Don't forget to add an entry about your changes to the CHANGELOG.md
file.
Done

---------

Co-authored-by: veeck <gitkraken@veeck.de>
2025-07-02 19:20:03 +02:00
Karsten Hassel
855b1d7cbf update dependencies incl. electron to v37, remove one failing unit test (#3831)
- see title and #3820
- remove failing unit calendar test until solved, see
https://github.com/MagicMirrorOrg/MagicMirror/issues/3830
2025-07-01 22:38:40 +02:00
Karsten Hassel
106b505f2c Prepare 2.33.0-develop 2025-07-01 00:22:16 +02:00
Karsten Hassel
26809725e5 Prepare Release 2.32.0 (#3825) 2025-06-30 23:52:58 +02:00
Karsten Hassel
5e506ea856 last dependency update before release (#3823) 2025-06-29 19:47:21 +02:00
Karsten Hassel
1e11d28224 fixes e2e tests (#3817)
- fix newsfeed and calendar e2e tests so they don't need `--forceExit`
anymore
- `--forceExit` should stay in test runs to avoid running until test
limit in case of errors
- remove mocking console, not needed anymore
- configFactory-stuff should not run in browser (otherwise we get errors
`[ReferenceError: exports is not defined]`)
2025-06-25 08:27:52 +02:00
Karsten Hassel
d2d4d7b37f update jest to v30 (#3815)
e2e:
- needed window.close(), otherwise the objects are not destroyed
- add missing `await` in clock test
- set maxListeners for all tests

remaining todo (comes with another PR if I find the problem):
- calendar e2e is now the only test which still needs `--forceExit`
2025-06-21 13:40:10 +02:00
Kristjan ESPERANTO
2809ed1750 [tests] Review and refactor translation tests (#3792)
I have refactored the translations tests, they should now be clearer and
easier to understand. There should be no functional impact.

I have discarded the original approach of also replacing
`XMLHttpRequest` with `fetch` in the file `js/translator.js`. I had
managed to get it to work functionally, but I couldn't get the tests to
work.
2025-06-21 00:37:15 +02:00
Bugsounet - Cédric
c7c0e67c1d review logger factory code part: use switch/case (#3812)
Styling code of `logger.js`:

Just use `switch/case` instead of `if/else if`

---------

Co-authored-by: Veeck <github@veeck.de>
2025-06-20 17:12:24 +02:00
Bugsounet - Cédric
9a3f4f098b Update package type to commonjs (#3814)
related to #3804 

added type to `commonjs` in package.json
2025-06-20 14:26:33 +02:00
Karsten Hassel
ee874836fe update deps and fix animateCSS_spec test (#3811)
- animateCSS_spec test did throw errors at least with newest
dependencies (running locally or on gitlab)
- dependency updates: New jest v30 breaks our tests so we have to stay
with v29 until fixed (will take a look)
2025-06-19 07:35:42 +02:00
Kristjan ESPERANTO
6501aabd2d [linter] Enable ESLint rule no-console (#3810)
In PR #3806 I noticed that ESLint did not complain about the use of
`console`. Then I realised that the rule `no-console` was not activated.
I have now changed this and replaced a few places where `console` was
used.

We can't apply the rule to all .js files because not all of them use our
logger. Therefore I had to add an extra config block for it.
2025-06-09 16:43:45 +02:00
Kristjan ESPERANTO
2194ffd929 [tests] Fix and refactor e2e test "Same keys" in "translations_spec.js" (#3809)
While working on the translations (in #3792 and #3794) I realised that
the e2e "Same keys" tests were not working entirely. There was also a
TODO entry for this in the test, as well as a try-catch-block
workaround. I therefore fixed and refactored it.

I also sorted the translations in `translations/translations.js`, so
that the test outputs are alphabetically.
2025-06-09 12:56:22 +02:00
Koen Konst
faf15ad211 Refactored calendarfetcherutils to fix many of the timezone and DST related issues and make debugging way easier (#3806)
Refactored calendarfetcherutils to remove as many of the date
conversions as possible and use moment tz when calculating recurring
events, this will make debugging a lot easier and fixes problems from
the past with offsets and DST not being handled properly. Also added
some tests to test the behavior of the refactored methodes to make sure
the correct event dates are returned.

Refactored calendar.js aswell to make sure the unix UTC start and end
date of events are properly converted to a local timezone and displayed
correctly for the user.

This PR relates to:
https://github.com/MagicMirrorOrg/MagicMirror/issues/3797

---------

Co-authored-by: Koen Konst <c.h.konst@avisi.nl>
Co-authored-by: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com>
2025-06-07 14:13:01 +02:00
Karsten Hassel
052ec1ca26 remove existing folders fonts and vendor from local installations (#3805)
see discussions
[here](https://github.com/MagicMirrorOrg/MagicMirror/pull/3795#issuecomment-2927804743).

The used command should work under windows too. I'm open to better
solutions.

Co-authored-by: Veeck <github@veeck.de>
2025-06-07 13:20:01 +02:00
Kristjan ESPERANTO
302b24c647 [l10n] Complete translations (#3794)
**Short description**: I completed the translations with the help of
translation tools.

**Long description**: I'm currently looking at the translation-tests and
I noticed the e2e-test `${language} should contain all base keys, ()`.
It is supposed to check whether all keys are present in each translation
file, but it doesn't actually work that way. When I fix it, a lot of
missing translations are reported. I have completed these translations
with the help of translation tools and packed them into this PR. I have
left out the modified test so that we can focus on the question if we
accept such amount of automatic translations or not.

rejas has already expressed in another PR
(https://github.com/MagicMirrorOrg/MagicMirror/pull/3775#discussion_r2083099252)
that he prefers human translators. I basically do too, but I don't see
how we can manage to have all translations completed by humans. And even
if a few translations are not correct, hopefully a user will get in
touch.

If we decide against the translations, we should at least remove the
test. If we go for the tranlsations, I'll add the test.

What do you think?

---------

Co-authored-by: Magnus <34011212+MagMar94@users.noreply.github.com>
2025-06-05 10:18:12 +02:00