568 Commits

Author SHA1 Message Date
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
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
Karsten Hassel
c8625ff506
simplify install and maintaining dependencies (#3795)
I was always unhappy when maintaining dependency updates to have 3
`package.json` files.

This PR moves all deps into the main `package.json` and removes the
folders `fonts` and `vendor`.

If accepted I will update the docs too.

---------

Co-authored-by: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com>
2025-06-01 17:03:11 +02:00
Kristjan ESPERANTO
e26aed927d
[refactor] Replace ansis with built-in function util.styleText (#3793)
> What does the pull request accomplish?

One external dependency less.
2025-05-27 22:36:02 +02:00
Kristjan ESPERANTO
85b4ece767
[refactor] Replace deprecated constants (#3789)
`fs.F_OK` and `fs.R_OK` are [deprecated since a while node
20.8.0](https://nodejs.org/api/deprecations.html#DEP0176).

Node 24 now complains about them when running server mode (`node --run
server`):

```bash
[2025-05-23 23:11:44.932] [ERROR] (node:37733) [DEP0176] DeprecationWarning: fs.F_OK is deprecated, use fs.constants.F_OK instead
(Use `node --trace-deprecation ...` to show where the warning was created) 
```

The replacements have been in place for a while, and this change should
work without any issues.
2025-05-23 23:57:50 +02:00
Kristjan ESPERANTO
554bb0ed5c
[feat] Add rule no-undef in config file validation (#3786)
This should solve the problem #3785.
2025-05-15 00:15:54 +02:00
Kristjan ESPERANTO
965e935881
[linter] Review linter setup (#3783)
- [2b395b9f] Fix command to lint markdown in `CONTRIBUTING.md`
- [fed4c86c] Re-activate JSDoc ESLint plugin and fix linting issues (As
far as I remember, we deactivated it when we upgraded to ESLint 9
because it was not compatible with it. But its now.)
- [a3d2064b] Refactor ESLint config to use `defineConfig` and
`globalIgnores` ([these are like new
defaults](https://eslint.org/blog/2025/03/flat-config-extends-define-config-global-ignores/))
- [a3d2064b] Replace `eslint-plugin-import` with
`eslint-plugin-import-x`
(https://github.com/es-tooling/module-replacements/blob/main/docs/modules/eslint-plugin-import.md)
- [86a185b6] Switch Stylelint config to flat format and simplify
Stylelint scripts (like we already did for ESLint and prettier)
  - [f5a2c541] Fix some typos
2025-05-12 23:40:05 +02:00
Bugsounet - Cédric
2831ae985c
[Feature Request] Allow to make an display order of module position in config (#3762)
My proposal for #3761 

* I use `flex` box for create region container
* I have moved `container` definition to `main.css` (for css tunning,
maybe it can be useful)
* I create `order` in module config for define module order display from
position

# Advantage:

We don't have to move module config in another place in array of modules

# Another advantage that i did'nt think:

We can change dynamicaly module order of a container:

- So, in this case, for a module config builder, (I won't mention the
name because otherwise I'll get angry...)
It can be usefull for a config preview (before saving config)
--> just change style css `order` module value for see preview

- Or, change `order` value in dev console for testing

# Disadvantages

I don't see any ;)
2025-05-08 10:15:02 +02:00
Kristjan ESPERANTO
b9d63d7252
Use "node --run" instead of "npm run" (#3764)
This has the advantage that the package manager is no longer involved
after the installation process.

However, previous start commands such as `npm run start` continue to
work. So we don't even have to adapt the documentation.
2025-05-06 20:33:42 +02:00
Kristjan ESPERANTO
e1a53ef2d5
[refactor] Simplify module loading process (#3766)
While debugging a 3rd party module, I looked at how modules are loaded
and realized that the `loadModules` method can be implemented much
simpler. This refactor makes the method easier to understand and
maintain.
2025-04-24 00:42:48 +02:00
sam detweiler
51d11bf26c
add support for digital clock time color (#3737)
see
https://forum.magicmirror.builders/topic/19440/digital-clock-minutes-darker

changelog added

question.. 

we have a config parm for seconds color, but not hour/minute
I have used css here.. is that too inconsistent?

---------

Co-authored-by: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com>
Co-authored-by: Veeck <github@veeck.de>
2025-03-16 15:33:27 +01:00
Kristjan ESPERANTO
a7f814d76b
Optimize systeminformation calls and output string (#3689)
Since we don't use the `raspberry` information, calling it in `si.get`
is useless.

I also made the string construction in the code a bit more readable. The
output remains the same.
2025-01-12 23:27:31 +01:00
sam detweiler
5e337f8b5f
fix #3267, CORRECTLY, add testcase, add testcase for #3279 (#3681)
fixes #3267 AGAIN, correctly, add testcase
add testcase for #3679 , broadcast clipping incorrectly

I added a test module (tests/testNotification) to catch the notification
and check the count. (one way to configure)
i put this module in the tests folder, and added /tests to the server
paths.
(can't have a module in a nested folder, like tests/modules/xxx)

but I have a problem. i can run the test config (MM_CONFIG_FILE), and
the two modules work correctly,
but in the spec runner, the calendar module times out on the broadcast
test.. there is only local ics file access, no outside hosts

I forced my system date to 1/1/24 (same as runner) and again the manual
testcase works fine

I added two test config.js,(configs/calendar) one works great (symbols)
, one fails (broadcast test)
I added additional delay in the calendarspec runner to try to debug the
module, but it still not long enough.. no messages of trouble when I get
into the browser.. BUT, this may be because of the log being turned
off... (just thought of this)

I created a special ICS (in mocks) that has 12 events, 1 for each
month.. (so I can check clipping and broadcast) the US holidays one is
sensitive to the current date, and I couldn't get it to work on
1/1/2024..

also, in general, is there a mechanism to run test:just_one_runner?
waiting thru the electron test to get to one testcase.. ugh..
2025-01-05 22:25:32 +01:00
Kristjan ESPERANTO
143dfd6b67
Add some ESLint rules + minor changes (#3665)
Main point was to enable ESLint `dot-notation` and `no-unneeded-ternary`
rules for more code consistency.

I took the occasion to add two minor commits:
- Fix a problem found by running `test:spelling
- Minor dependency update

It wouldn't be a problem if the PR didn't arrive in the next release,
the changes are cosmetic.
2024-12-30 12:24:51 +01:00
sam detweiler
93a0c24c22
fix #3662 line parse on windows with linux line ends (#3663)
line parse used os.EOL, which failed with linux line ends in index.html,
change to '\n'
2024-12-28 18:57:39 +01:00
sam detweiler
6a09bc4ec4
add support for fetch timeout control for node_helpers, fix timeouts on armv6l (#3660)
user reporting slow/no connection/timeout errors on armv6l for calendar,
and newsfeed

we can increase the timeout by adding calls to the undici lib, but it
requires node 20.18.1 or above.

this adds the support for timeout
(also environment variable to override if needed,, mmFetchTimeout
(default 30 seconds)

and updates the base node version
2024-12-26 00:28:16 +01:00
Bugsounet - Cédric
c485ff670d
path resolve and sub/sub folder module (#3653)
Fix:
 - use `path.resolve` for `moduleFolder` and `defaultModuleFolder` path
- Fix module path in case of sub/sub folder is used (sample
`module/test/test`)
 
---
case of module installation on `module/test/test`:

config will be:
```js
 {
    module: "test/test",
    ...
 }
```

module core will be:
```js
Module.register("test", {
...
```
`test.js` is used for module core (no change)

---

case of module installation on `module/test` (no change):
config will be:
```js
 {
    module: "test",
    ...
 }
```

module core will be:
```js
Module.register("test", {
...
```
so `test.js` is used for module core

---

In reality, with this patch, `module` config feature have 2
functionalites:
 -  determinate module path with more precision
 -  allow to use sub/sub folder in modules folder

---------

Co-authored-by: Veeck <github@veeck.de>
2024-12-18 22:07:09 +01:00
sam detweiler
24d9b70c4c
fix access denied fault error writing js/positions.js (#3652)
if the MagicMirror js folder is not writable (synology nas created by
different user than docker container) there is an uncaught throw

```
[ERROR] EACCES: permission denied, open 'js/positions.js' 
```

add try/catch, output new message, console.error
```text
unable to write js/positions.js with the discovered module positions
make the MagicMirror/js folder writeable by the user starting MagicMirror 
```

MM will start, but no modules will show, as no positions were discovered
this file is used to pass the list from the server side to the browser
side

fixes #3651
2024-12-18 17:37:51 +01:00
Kristjan ESPERANTO
5b3b40da66
Use project URL in fallback config (#3656) 2024-12-18 08:00:00 +01:00
sam detweiler
39ab651319
Show animations, fix export only on server side (#3649)
fix #3644 so only on server side
2024-12-08 16:24:39 +01:00
sam detweiler
63178eba72
Export animations (#3644)
I am adding the animateIn/Out support to MMM-Config, but I need the list
of animations..
but they are not visible in js/animateCSS.js (from require)

adding an export satisfies that

side issue, these would go in a dropdown list
what value can I use for the default behavior? none/default?
don't want an error produced..
should I add code to check for this value to prevent error?
2024-12-02 10:17:19 +01:00
sam detweiler
56cb536df1
add support for test mode detection in modulename.js via index.html (#3631)
in some cases the modulename.js may need to detect running in test mode
(compliments pr #3630)

window.name is not set  web mode

add a new field to the index.html 
window.intest 
and use the server_function to replace the hard coded string like we do
for window.mmversion=#VERSION#
then change the two  test helpers to set the env variable
app.js detects and sets global.intest=true
server func replace with value of global.intest

then module can use   if(window.intest)
2024-11-12 15:58:36 +01:00
Karsten Hassel
9114aefecc
fix missing basePath (#3620)
fixes #3613 

wanted to write a test for `basePath` but have no idea at the moment to
simulate this without a reverse proxy.

Here my test setup for documentation:
```yaml
networks:
  proxy:
    driver: bridge

services:
  socket-proxy:
    privileged: true
    image: tecnativa/docker-socket-proxy:edge
    container_name: socket-proxy
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    environment:
      CONTAINERS: 1
    ports:
      - "127.0.0.1:2375:2375"
    networks:
      - proxy

  traefik:
    image: traefik:latest
    container_name: traefik
    restart: unless-stopped
    user: 1000:1000
    command:
      - "--providers.docker=true"
      - "--providers.docker.network=traefik_proxy"
      - "--providers.docker.endpoint=tcp://socket-proxy:2375"
      - "--entryPoints.http.address=:80"
      - "--global.sendAnonymousUsage=false"
      - "--log.level=INFO"
      - "--api=true"
      - "--api.dashboard=true"
#      - "--accessLog=true"
#      - "--accesslog.fields.defaultmode=keep"
#      - "--accesslog.fields.headers.defaultmode=keep"
    networks:
      - proxy
    ports:
      - "80:80"

  magicmirror:
    image: karsten13/magicmirror:develop
    container_name: mm
    restart: unless-stopped
    entrypoint:
      - sleep
      - infinity
    networks:
      - proxy
    labels:
      - "traefik.http.services.karsten13.loadbalancer.server.port=8080"
      - "traefik.http.routers.k13-http.service=karsten13"
      - "traefik.http.routers.k13-http.entrypoints=http"
      - "traefik.http.routers.k13-http.rule=Host(`localhost`) && PathPrefix(`/testbasepath`)"
      - "traefik.http.middlewares.k13-stripprefix.stripprefix.prefixes=/testbasepath"
      - "traefik.http.routers.k13-http.middlewares=k13-stripprefix"
```
2024-11-02 08:22:27 +01:00
Karsten Hassel
cfa5c0d127
fix electron tests mocking dates (#3599)
fixes #3597 

Changes:
- electron tests: add mocking to `electron.js` for mocking the server
side, before only the browser side was mocked
- publish "/tests/configs" and "/tests/mocks" always in `server.js`,
this reverts a change done with latest release, we need this for
debugging (otherwise you get on the screen that your config has errors
but config check is successful ...)
- revert hotfix in
`tests/configs/modules/calendar/show-duplicates-in-calendar.js`
- fix `tests/configs/modules/calendar/custom.js` to allow events in the
past (~~I don't know how this could work before~~ when testing css
classes `yesterday` and `dayBeforeYesterday` --> it worked before
because the server side did not mock and therefore was not in the past)
2024-10-25 11:34:35 +02:00
Bugsounet - Cédric
961bae637c
[core] add try / catch on mode_helper loading (#3578)
When a library is missing on an 3rd party module, MM² stop loading and
display a black screen. (I'm sure it's happened to everyone.)

So, I have added a try/catch block and it's avoid black screen, display
errors and allow continue loading with next module
2024-10-05 15:23:36 +02:00
sam detweiler
d9eefff066
fix double load of positions now that check:config at startup is active (#3565)
after adding check:config to the MM startup process, #3450, we
accidentally discover module positions more than once, and write the
file each time..

add a check to see if we have done this work already
2024-09-28 15:52:09 +02:00
Kristjan ESPERANTO
d3187689f0
Switch to ESLint v9 and flat config (#3558)
Since PR #3551 was not yet complete, I made my own attempt.

1. Update to ESLint v9.
2. Replace deprecated `.eslintrc.json` and `.eslintignore` by flat
config `eslint.config.mjs`.
3. Adapt `check_config.js` to use flat config.
4. Since `eslint-plugin-import` still doesn't support ESLint v9 I
removed it. We can add it back when it does support v9.
5. Run tests `npm run check:js` and `npm run config:check`.
6. In order not to overload this PR, I have not yet activated more
additional rules - there are some useful ones in the new plugin
`@eslint/js`.

@bugsounet, please don't take it as an offence that I have created a
competing PR. The migration to ESLint v9 has been burning under my nails
for some time.
2024-09-25 21:05:11 +02:00
Karsten Hassel
08116b8e64
fixes for running tests for MM_MODULES_DIR (#3550)
and ignore `js/positions.js` when linting (because this file is
generated at runtime).
2024-09-24 22:38:00 +02:00
Ryan Williams
1823f5a130
Updated to new notification name DOM_OBJECTS_UPDATED -> MODULE_DOM_UPDATED (#3548)
This is an update to #3535. See #3534 for discussion and context. Fixes
#3534 (again).
2024-09-19 07:29:43 +02:00
Kristjan ESPERANTO
06f6fbf49b
Review config_check.js (#3545)
Only details changes. No functional changes.

- remove superfluous colors in Log.error
- invert negative if
- update ESLint env
- use camel case variable name
- optimize Log strings
2024-09-18 21:39:02 +02:00
Ryan Williams
c6e05c9fec
Added DOM_OBJECTS_UPDATED notification when the DOM is re-rendered via updateDom (#3535)
- [x] Base your pull requests against the `develop` branch.
- [x] Include these infos in the description:
> - Does the pull request solve a **related** issue?
Yes - solves #3534

> - If so, can you reference the issue like this `Fixes
#<issue_number>`?
Fixes #3534 (also mentioned in commit message)

> - What does the pull request accomplish? Use a list if needed.

> > - Adds a new notification (`DOM_OBJECTS_UPDATED`) when the DOM is
updated via `updateDom`

- [x] Please run `npm run lint:prettier` before submitting
- [x] Don't forget to add an entry about your changes to the
CHANGELOG.md file.

More info can be found in #3534, but as a summary:

The `updateDom` function is not synchronous - there is an undetermined
amount of time between when it completes and when the DOM has actually
been re-rendered and is ready for interaction. The existing notification
(`MODULE_DOM_CREATED`) only fires once on the initial DOM render. This
PR solves the issue of subsequent re-renders by adding a new
notification that fires whenever the DOM is ready after an update. This
notification falls within expected lifecycle notifications (very similar
to other libraries that provide DOM lifecycle notifications).
2024-09-18 19:40:46 +02:00
Kristjan ESPERANTO
866419eb95
Check config before starting MM (#3450)
I think it might be a good idea to check the config at every start.
2024-09-18 19:37:25 +02:00
Karsten Hassel
659e0c74cb
add new env vars MM_MODULES_DIR and MM_CUSTOMCSS_FILE … (#3530)
… for setting these things from outside (and overriding corresponding
config.js properties `config.foreignModulesDir` and `customCss`)

- remove elements from index.html when loading script or stylesheet
files fails
- removed `config.paths.vendor` (could never work because `vendor` is
hardcoded in `index.html`) and renamed `config.paths.modules` to
`config.foreignModulesDir`. The `config.paths. ...` properties were
implemented in the initial commit in `js/defaults.js` but were never
functional.
- fixes `app.js` which didn't respect `config.paths.modules` before
- as `modules/defaults` is directly set in many places in the source
code restrict `config.paths.modules` to foreign modules (it has never
worked for default modules), now renamed to `config.foreignModulesDir`
- adds new `/env` section in `server.js` for getting the new env vars in
the browser
- fixes TODO in `server.js` so test directories are now only published
when running tests

These changes allow changing some main paths from outside mm with the
new env vars. You now **can** put all user stuff into one directory,
e.g. the `config` dir:
- `config.js` as before
- `custom.css`
- foreign modules

This would simplify other setups e.g. the docker setup. At the moment we
have to deal with 3 directories where 2 of them (`modules` and `css`)
contains mixed stuff, which means mm owned files and user files. This
can now simplified and leads to cleaner setups (if wanted).
2024-09-18 19:10:46 +02:00
Kristjan ESPERANTO
d9f9f41e98
Add spell check (#3544)
I felt like adding a spell checker, but it's okay if you find it
superfluous. At least then we could fix the found spell issues.

What is still missing is an automatic integration so that the spell
checker does not have to be called manually. Would it perhaps make sense
to always do it before a release?
2024-09-18 07:37:09 +02:00
sam detweiler
2b97e0d26e
add support for custom regions, by detecting what is used in index.html (#3518)
read index.html to discover the regions used, make them the list checked
by app.js and check:config test

fixes #3504   supercedes #3506 

no config.js param required
2024-08-27 22:52:59 +02:00
Ryan Williams
cc1d4ab240
Improve duplicate module filtering. Update SocketIO catch-all API. (#3523)
- [x] Base your pull requests against the `develop` branch.
- [x] Include these infos in the description:
> - Does the pull request solve a **related** issue?
Yes - solves #3521

> - If so, can you reference the issue like this `Fixes
#<issue_number>`?
Fixes #3521 (also mentioned in commit message)

> - What does the pull request accomplish? Use a list if needed.

> > - Updates duplicate module filter method (upstream vs downstream -
see #3502)
> > - Updates socket io catchall functionality to new API
[[docs](https://socket.io/docs/v4/listening-to-events/)].

- [x] Please run `npm run lint:prettier` before submitting
- [x] Don't forget to add an entry about your changes to the
CHANGELOG.md file.
2024-08-18 09:25:01 +02:00
Veeck
976c8ae00a
Bump stylistic-eslint (#3520)
updates plugin and adjust docs and config for smooth cleaning :-D

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-08-12 22:52:43 +02:00
sam detweiler
780e4e2e06
Fix loading of multiple instances of node_helper when multiple instances of a module are in config.js (#3517)
adds a check for already loaded/loading for node helper of a each
module, only does once

fixes #3502
2024-08-04 21:28:20 +02:00
Karsten Hassel
76d8f98969
allow custom module positions by setting allowCustomModulePositions… (#3506)
… in `config.js`

fixes #3504, related to
https://github.com/MagicMirrorOrg/MagicMirror/pull/3445
2024-08-01 21:24:16 +02:00
Karsten Hassel
d22d0e1f87
remove raspberry object from systeminformation (#3507)
fixes #3505
2024-07-29 12:22:59 +02:00
Karsten Hassel
4aafa32875
fixes e2e tests running in docker container (#3485)
which needs `address: "0.0.0.0"`

fixes #3479
2024-06-27 10:38:29 +02:00
Bugsounet - Cédric
e95c144c3e
Fix crash possibility if module: <name> is not defined and on mistake position: <position> (#3445)
Fix #3442
2024-06-24 21:51:54 +02:00
Bugsounet - Cédric
d9926fad79
MM² Icon (#3407)
* Create `MM²` icon
 * Allow to change default electron icon to this icon
2024-03-28 12:37:18 +01:00
sam detweiler
08f8a5107a
add error message if config.js appears empty after loading w require() in app.js (#3383)
from forum,
https://forum.magicmirror.builders/topic/18493/node_helper-js-is-not-working
user created own config.js, did not copy the module exports line..

this caused the js/defaults.js list of modules to be processed for
node_helpers
but the physical config.js to be loaded for the web page (hard coded in
index.html)

so user modules needing node_helper didn't have that ..

this adds a warning message in npm start output to help user resolve..
took two days to debug without message
2024-02-13 08:02:02 +01:00
Karsten Hassel
27f3c86c41
remove all useless header comments (#3363)
see #3358

used command: `find ./ -type f -exec perl -i -0pe
's/\/\*\s*magicmirror.*?\*\/\s*//si' {} \;`

This is a first draft, I think we should preserve some of the comments.
2024-01-24 21:39:06 +01:00
Karsten Hassel
c09338ab80
changed log.debug to log.log in app.js (#3362)
where logLevel is not set because config is not loaded at this time, see
#3353
2024-01-18 19:18:58 +01:00
Kristjan ESPERANTO
6dbacbb773
Rework logging colors (#3350)
- Replacing old package `colors` by drop-in replacement `ansis`
- Rework `console-stamp` config to show all Log outputs in same color
(errors = red, warnings = yellow, debug = blue background (only for the
label), info = blue)
- This also fixes `npm run config:check` (broken since
6097547c103be1bc89c572e5bd2be50b342967fa)

Feel free to let me know if the PR is too big and you want me to do
individual PRs for the changes.

Before:

![before](https://github.com/MagicMirrorOrg/MagicMirror/assets/35647502/88e48ec3-102c-40f3-9e9b-5d14fe446a43)

After:

![after](https://github.com/MagicMirrorOrg/MagicMirror/assets/35647502/4c8c4bad-08c9-46a3-92c9-14b996c13a7d)

---------

Co-authored-by: Veeck <github@veeck.de>
2024-01-16 21:54:55 +01:00
Kristjan ESPERANTO
58bc14e8c0
Request only required information instead of all (#3338)
Hopefully this solves the problem with arm64 (reported in PR #3337).
2024-01-14 09:15:30 +01:00
Karsten Hassel
f890f14df7
ignore strange errors from systeminformation under aarch64 (#3349)
by excluding them from global error handling, see discussions in
https://github.com/MagicMirrorOrg/MagicMirror/pull/3337
2024-01-14 09:13:01 +01:00
Kristjan ESPERANTO
4bbd35fa6a
Use node prefix for build-in modules (#3340)
It is basically a cosmetic thing, but has the following advantages:

1. Consistency with the official node documentation. The prefix is used
there.
2. It is easier to recognize the build-in modules.
2024-01-08 17:45:54 +01:00