move default modules from /modules/default to /defaultmodules (#4019)

Since the project's inception, I've missed a clear separation between
default and third-party modules.

This increases complexity within the project (exclude `modules`, but not
`modules/default`), but the mixed use is particularly problematic in
Docker setups.

Therefore, with this pull request, I'm moving the default modules to a
different directory.

~~I've chosen `default/modules`, but I'm not bothered about it;
`defaultmodules` or something similar would work just as well.~~

Changed to `defaultmodules`.

Let me know if there's a majority in favor of this change.
This commit is contained in:
Karsten Hassel
2026-01-27 08:37:52 +01:00
committed by GitHub
parent 5e0cd28980
commit d44db6ea10
113 changed files with 59 additions and 40 deletions

3
.gitignore vendored
View File

@@ -54,9 +54,8 @@ Temporary Items
.directory
.Trash-*
# Ignore all modules except the default modules.
# Ignore all modules
/modules/*
!/modules/default
# Ignore changes to the custom css files but keep the sample and main.
/css/*

View File

@@ -343,11 +343,11 @@
"ignorePaths": [
"css/roboto.css",
"node_modules/**",
"modules/!(default)/**",
"modules/default/**/translations/!(en).json",
"modules/default/calendar/windowsZones.json",
"modules/default/clock/faces/*.svg",
"modules/default/weather/providers/yr.js",
"modules/**",
"defaultmodules/**/translations/!(en).json",
"defaultmodules/calendar/windowsZones.json",
"defaultmodules/clock/faces/*.svg",
"defaultmodules/weather/providers/yr.js",
"tests/mocks/**",
"tests/e2e/modules/clock_es_spec.js",
"translations/**"

View File

@@ -4,7 +4,7 @@
* of starting the MagicMirror² core. Adjust the values below to your desire.
*/
// Load internal alias resolver
require("../../../js/alias-resolver");
require("../../js/alias-resolver");
const Log = require("logger");
const CalendarFetcher = require("./calendarfetcher");

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

@@ -2,7 +2,7 @@ const fs = require("node:fs");
const path = require("node:path");
const NodeHelper = require("node_helper");
const defaultModules = require(`${global.root_path}/modules/default/defaultmodules`);
const defaultModules = require(`${global.root_path}/${global.defaultModulesDir}/defaultmodules`);
const GitHelper = require("./git_helper");
const UpdateHelper = require("./update_helper");

View File

@@ -9,7 +9,7 @@ import stylistic from "@stylistic/eslint-plugin";
import vitest from "@vitest/eslint-plugin";
export default defineConfig([
globalIgnores(["config/**", "modules/**/*", "!modules/default/**", "js/positions.js"]),
globalIgnores(["config/**", "modules/**/*", "js/positions.js"]),
{
files: ["**/*.js"],
languageOptions: {

View File

@@ -46,8 +46,8 @@
<script type="text/javascript" src="js/defaults.js"></script>
<script type="text/javascript" src="#CONFIG_FILE#"></script>
<script type="text/javascript" src="js/vendor.js"></script>
<script type="text/javascript" src="modules/default/defaultmodules.js"></script>
<script type="text/javascript" src="modules/default/utils.js"></script>
<script type="text/javascript" src="defaultmodules/defaultmodules.js"></script>
<script type="text/javascript" src="defaultmodules/utils.js"></script>
<script type="text/javascript" src="js/logger.js"></script>
<script type="text/javascript" src="translations/translations.js"></script>
<script type="text/javascript" src="js/translator.js"></script>

View File

@@ -31,7 +31,7 @@ const config = {
collectCoverageFrom: [
"<rootDir>/clientonly/**/*.js",
"<rootDir>/js/**/*.js",
"<rootDir>/modules/default/**/*.js",
"<rootDir>/defaultmodules/**/*.js",
"<rootDir>/serveronly/**/*.js"
],
coverageReporters: ["lcov", "text"],

View File

@@ -13,7 +13,6 @@ global.root_path = path.resolve(`${__dirname}/../`);
const Server = require(`${__dirname}/server`);
const Utils = require(`${__dirname}/utils`);
const defaultModules = require(`${global.root_path}/modules/default/defaultmodules`);
// used to control fetch timeout for node_helpers
const { setGlobalDispatcher, Agent } = require("undici");
const { getEnvVarsAsObj, getConfigFilePath } = require("#server_functions");
@@ -57,6 +56,7 @@ process.on("uncaughtException", function (err) {
function App () {
let nodeHelpers = [];
let httpServer;
let defaultModules;
/**
* Loads the config file. Combines it with the defaults and returns the config
@@ -185,7 +185,7 @@ function App () {
let moduleFolder = path.resolve(`${global.root_path}/${env.modulesDir}`, module);
if (defaultModules.includes(moduleName)) {
const defaultModuleFolder = path.resolve(`${global.root_path}/modules/default/`, module);
const defaultModuleFolder = path.resolve(`${global.root_path}/${global.defaultModulesDir}/`, module);
if (!global.mmTestMode) {
moduleFolder = defaultModuleFolder;
} else {
@@ -291,6 +291,9 @@ function App () {
this.start = async function () {
config = await loadConfig();
global.defaultModulesDir = config.defaultModulesDir;
defaultModules = require(`${global.root_path}/${global.defaultModulesDir}/defaultmodules`);
Log.setLogLevel(config.logLevel);
// get the used module positions

View File

@@ -20,6 +20,7 @@ const defaults = {
zoom: 1,
customCss: "css/custom.css",
foreignModulesDir: "modules",
defaultModulesDir: "defaultmodules",
// httpHeaders used by helmet, see https://helmetjs.github.io/. You can add other/more object values by overriding this in config.js,
// e.g. you need to add `frameguard: false` for embedding MagicMirror in another website, see https://github.com/MagicMirrorOrg/MagicMirror/issues/2847
httpHeaders: { contentSecurityPolicy: false, crossOriginOpenerPolicy: false, crossOriginEmbedderPolicy: false, crossOriginResourcePolicy: false, originAgentCluster: false },

View File

@@ -17,6 +17,7 @@ const Loader = (function () {
const getEnvVarsFromConfig = function () {
return {
modulesDir: config.foreignModulesDir || "modules",
defaultModulesDir: config.defaultModulesDir || "defaultmodules",
customCss: config.customCss || "css/custom.css"
};
};
@@ -103,7 +104,7 @@ const Loader = (function () {
let moduleFolder = `${envVars.modulesDir}/${module}`;
if (defaultModules.indexOf(moduleName) !== -1) {
const defaultModuleFolder = `modules/default/${module}`;
const defaultModuleFolder = `${envVars.defaultModulesDir}/${module}`;
if (window.name !== "jsdom") {
moduleFolder = defaultModuleFolder;
} else {

View File

@@ -89,7 +89,7 @@ function Server (config) {
app.use(helmet(config.httpHeaders));
app.use("/js", express.static(__dirname));
let directories = ["/config", "/css", "/favicon.svg", "/modules", "/node_modules/animate.css", "/node_modules/@fontsource", "/node_modules/@fortawesome", "/translations", "/tests/configs", "/tests/mocks"];
let directories = ["/config", "/css", "/favicon.svg", "/defaultmodules", "/modules", "/node_modules/animate.css", "/node_modules/@fontsource", "/node_modules/@fortawesome", "/translations", "/tests/configs", "/tests/mocks"];
for (const [key, value] of Object.entries(vendor)) {
const dirArr = value.split("/");
if (dirArr[0] === "node_modules") directories.push(`/${dirArr[0]}/${dirArr[1]}`);

View File

@@ -162,7 +162,7 @@ function getUserAgent () {
* @returns {object} environment variables key: values
*/
function getEnvVarsAsObj () {
const obj = { modulesDir: `${config.foreignModulesDir}`, customCss: `${config.customCss}` };
const obj = { modulesDir: `${config.foreignModulesDir}`, defaultModulesDir: `${config.defaultModulesDir}`, customCss: `${config.customCss}` };
if (process.env.MM_MODULES_DIR) {
obj.modulesDir = process.env.MM_MODULES_DIR.replace(`${global.root_path}/`, "");
}

Some files were not shown because too many files have changed in this diff Show More