Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CodeQL

on:
push:
branches: [develop, master]
pull_request:
branches: [develop]
schedule:
- cron: "0 4 * * 1"

jobs:
analyze:
name: Analyze (${{ matrix.language }})
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [actions, javascript-typescript]

steps:
- uses: actions/checkout@v6

- uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
queries: security-and-quality

- uses: github/codeql-action/autobuild@v4

- uses: github/codeql-action/analyze@v4
with:
category: "/language:${{ matrix.language }}"
3 changes: 3 additions & 0 deletions .github/workflows/electron-rebuild.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: "Electron Rebuild Testing"

permissions:
contents: read

on: [pull_request]

jobs:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/enforce-pullrequest-rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

name: "Enforce Pull-Request Rules"

permissions:
contents: read

on:
pull_request:
push:
Expand Down
19 changes: 19 additions & 0 deletions cspell.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
"armv",
"ashishtank",
"autoplay",
"avghumidity",
"avgtemp",
"Autorestart",
"beada",
"Behaviour",
"Beschreibung",
"Binney",
"bluemanos",
"bnitkin",
Expand Down Expand Up @@ -111,6 +114,7 @@
"flopp",
"fontawesome",
"fontface",
"forecastday",
"forecastweather",
"fortawesome",
"frameguard",
Expand Down Expand Up @@ -186,14 +190,18 @@
"luxon",
"lxsession",
"magicmirror",
"mapbox",
"martingron",
"marvai",
"mastermerge",
"matchtype",
"maxentries",
"maxtemp",
"maxwind",
"Meteo",
"michaelteeuw",
"michmich",
"mintemp",
"Midori",
"mirontoli",
"MISSINGLANG",
Expand All @@ -212,7 +220,9 @@
"NEWSFEED",
"newsfeedfetcher",
"newsfetcher",
"newyear",
"newsitems",
"nextdaysrelative",
"nfogal",
"njwilliams",
"nonrepeating",
Expand All @@ -239,8 +249,10 @@
"pmin",
"Português",
"PRECIP",
"precips",
"Problema",
"psieg",
"ptype",
"pubdate",
"radokristof",
"rajniszp",
Expand All @@ -255,12 +267,14 @@
"Rosso",
"Rothfusz",
"rrule",
"sameorigin",
"savvadam",
"sdetweil",
"searchstr",
"sendheaders",
"serveronly",
"sexualized",
"showend",
"Sitecode",
"skpanagiotis",
"SMHI",
Expand Down Expand Up @@ -295,8 +309,11 @@
"timeformat",
"titlereplacestr",
"titlesearchstr",
"TOCTOU",
"todaytemp",
"tomzt",
"totalprecip",
"totalsnow",
"trunc",
"ttlms",
"ukmetoffice",
Expand All @@ -317,6 +334,7 @@
"Vorberechnung",
"vppencilsharpener",
"Wallys",
"weatherapi",
"Weatherbit",
"weathercode",
"WEATHERDATA",
Expand All @@ -336,6 +354,7 @@
"Woolridge",
"worktree",
"Wsymb",
"xhvw",
"xlarge",
"xmark",
"xrandr",
Expand Down
2 changes: 1 addition & 1 deletion defaultmodules/calendar/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ Module.register("calendar", {
this.selfUpdate();
},

notificationReceived (notification, payload, sender) {
notificationReceived (notification, payload) {
if (notification === "FETCH_CALENDAR") {
this.sendSocketNotification(notification, { url: payload.url, id: this.identifier });
}
Expand Down
1 change: 0 additions & 1 deletion defaultmodules/calendar/calendarfetcher.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const ical = require("node-ical");
const Log = require("logger");
const { Agent } = require("undici");
const CalendarFetcherUtils = require("./calendarfetcherutils");
const HTTPFetcher = require("#http_fetcher");

Expand Down
2 changes: 1 addition & 1 deletion defaultmodules/calendar/calendarfetcherutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const CalendarFetcherUtils = {
// Subtract 1 second so that events that start on the middle of the night will not repeat.
.subtract(1, "seconds");

Object.entries(data).forEach(([key, event]) => {
Object.values(data).forEach((event) => {
if (event.type !== "VEVENT") {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion defaultmodules/compliments/compliments.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ Module.register("compliments", {
},

// Override notification handler.
notificationReceived (notification, payload, sender) {
notificationReceived (notification, payload) {
if (notification === "CURRENTWEATHER_TYPE") {
this.currentWeatherType = payload.type;
}
Expand Down
2 changes: 1 addition & 1 deletion defaultmodules/newsfeed/newsfeed.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ Module.register("newsfeed", {
}
},

notificationReceived (notification, payload, sender) {
notificationReceived (notification) {
const before = this.activeItem;
if (notification === "MODULE_DOM_CREATED" && this.config.hideLoading) {
this.hide();
Expand Down
11 changes: 3 additions & 8 deletions defaultmodules/newsfeed/newsfeedfetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class NewsfeedFetcher {
});

// Wire up HTTPFetcher events
this.httpFetcher.on("response", (response) => this.#handleResponse(response));
this.httpFetcher.on("response", (response) => void this.#handleResponse(response));
this.httpFetcher.on("error", (errorInfo) => this.fetchFailedCallback(this, errorInfo));
}

Expand All @@ -67,7 +67,7 @@ class NewsfeedFetcher {
* Handles successful HTTP response
* @param {Response} response - The fetch Response object
*/
#handleResponse (response) {
async #handleResponse (response) {
this.items = [];
const parser = new FeedMe();

Expand Down Expand Up @@ -106,11 +106,6 @@ class NewsfeedFetcher {

parser.on("end", () => this.broadcastItems());

parser.on("error", (error) => {
Log.error(`${this.url} - Feed parsing failed: ${error.message}`);
this.fetchFailedCallback(this, this.#createParseError(`Feed parsing failed: ${error.message}`, error));
});

parser.on("ttl", (minutes) => {
const ttlms = Math.min(minutes * 60 * 1000, 86400000);
if (ttlms > this.httpFetcher.reloadInterval) {
Expand All @@ -123,7 +118,7 @@ class NewsfeedFetcher {
const nodeStream = response.body instanceof stream.Readable
? response.body
: stream.Readable.fromWeb(response.body);
nodeStream.pipe(iconv.decodeStream(this.encoding)).pipe(parser);
await stream.promises.pipeline(nodeStream, iconv.decodeStream(this.encoding), parser);
} catch (error) {
Log.error(`${this.url} - Stream processing failed: ${error.message}`);
this.fetchFailedCallback(this, this.#createParseError(`Stream processing failed: ${error.message}`, error));
Expand Down
42 changes: 19 additions & 23 deletions defaultmodules/updatenotification/git_helper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const util = require("node:util");
const exec = util.promisify(require("node:child_process").exec);
const execFile = util.promisify(require("node:child_process").execFile);
const fs = require("node:fs");
const path = require("node:path");
const Log = require("logger");
Expand All @@ -14,14 +14,14 @@ class GitHelper {
return new RegExp(`s*([a-z,0-9]+[.][.][a-z,0-9]+) ${branch}`, "g");
}

async execShell (command) {
const { stdout = "", stderr = "" } = await exec(command);
async execGit (moduleFolder, ...args) {
const { stdout = "", stderr = "" } = await execFile("git", args, { cwd: moduleFolder });

return { stdout, stderr };
}

async isGitRepo (moduleFolder) {
const { stderr } = await this.execShell(`cd ${moduleFolder} && git remote -v`);
const { stderr } = await this.execGit(moduleFolder, "remote", "-v");

if (stderr) {
Log.error(`Failed to fetch git data for ${moduleFolder}: ${stderr}`);
Expand Down Expand Up @@ -51,7 +51,7 @@ class GitHelper {
// Folder has .git and has at least one git remote, watch this folder
this.gitRepos.push({ module: moduleName, folder: moduleFolder });
}
} catch (err) {
} catch {
// Error when directory .git doesn't exist or doesn't have any remotes
// This module is not managed with git, skip
}
Expand All @@ -69,7 +69,7 @@ class GitHelper {

if (repo.module === "MagicMirror") {
// the hash is only needed for the mm repo
const { stderr, stdout } = await this.execShell(`cd ${repo.folder} && git rev-parse HEAD`);
const { stderr, stdout } = await this.execGit(repo.folder, "rev-parse", "HEAD");

if (stderr) {
Log.error(`Failed to get current commit hash for ${repo.module}: ${stderr}`);
Expand All @@ -78,7 +78,7 @@ class GitHelper {
gitInfo.hash = stdout;
}

const { stderr, stdout } = await this.execShell(`cd ${repo.folder} && git status -sb`);
const { stderr, stdout } = await this.execGit(repo.folder, "status", "-sb");

if (stderr) {
Log.error(`Failed to get git status for ${repo.module}: ${stderr}`);
Expand Down Expand Up @@ -123,7 +123,7 @@ class GitHelper {
return gitInfo;
}

const { stderr } = await this.execShell(`cd ${repo.folder} && git fetch -n --dry-run`);
const { stderr } = await this.execGit(repo.folder, "fetch", "-n", "--dry-run");

// example output:
// From https://github.com/MagicMirrorOrg/MagicMirror
Expand All @@ -140,22 +140,22 @@ class GitHelper {

// get behind with refs
try {
const { stdout } = await this.execShell(`cd ${repo.folder} && git rev-list --ancestry-path --count ${refDiff}`);
const { stdout } = await this.execGit(repo.folder, "rev-list", "--ancestry-path", "--count", refDiff);
gitInfo.behind = parseInt(stdout);

// for MagicMirror-Repo and "master" branch avoid getting notified when no tag is in refDiff
// so only releases are reported and we can change e.g. the README.md without sending notifications
if (gitInfo.behind > 0 && gitInfo.module === "MagicMirror" && gitInfo.current === "master") {
let tagList = "";
try {
const { stdout } = await this.execShell(`cd ${repo.folder} && git ls-remote -q --tags --refs`);
const { stdout } = await this.execGit(repo.folder, "ls-remote", "-q", "--tags", "--refs");
tagList = stdout.trim();
} catch (err) {
Log.error(`Failed to get tag list for ${repo.module}: ${err}`);
}
// check if tag is between commits and only report behind > 0 if so
try {
const { stdout } = await this.execShell(`cd ${repo.folder} && git rev-list --ancestry-path ${refDiff}`);
const { stdout } = await this.execGit(repo.folder, "rev-list", "--ancestry-path", refDiff);
let cnt = 0;
for (const ref of stdout.trim().split("\n")) {
if (tagList.includes(ref)) cnt++; // tag found
Expand Down Expand Up @@ -193,19 +193,15 @@ class GitHelper {
return this.gitResultList;
}

async checkUpdates () {
var updates = [];
checkUpdates () {
const updates = [];

const allRepos = await this.gitResultList.map((module) => {
return new Promise((resolve) => {
if (module.behind > 0 && module.module !== "MagicMirror") {
Log.info(`Update found for module: ${module.module}`);
updates.push(module);
}
resolve(module);
});
});
await Promise.all(allRepos);
for (const moduleInfo of this.gitResultList) {
if (moduleInfo.behind > 0 && moduleInfo.module !== "MagicMirror") {
Log.info(`Update found for module: ${moduleInfo.module}`);
updates.push(moduleInfo);
}
}

return updates;
}
Expand Down
4 changes: 2 additions & 2 deletions defaultmodules/updatenotification/update_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class Updater {
Log.info(`Updating ${module.name}...`);

return new Promise((resolve) => {
Exec(Command, { cwd: modulePath, timeout: this.timeout }, (error, stdout, stderr) => {
Exec(Command, { cwd: modulePath, timeout: this.timeout }, (error, stdout) => {
if (error) {
Log.error(`exec error: ${error}`);
Result.error = true;
Expand Down Expand Up @@ -143,7 +143,7 @@ class Updater {
pm2Restart () {
Log.info("[PM2] restarting MagicMirror...");
const pm2 = require("pm2");
pm2.restart(this.PM2Id, (err, proc) => {
pm2.restart(this.PM2Id, (err) => {
if (err) {
Log.error("[PM2] restart Error", err);
}
Expand Down
6 changes: 3 additions & 3 deletions defaultmodules/weather/current.njk
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
{% if config.showUVIndex %}
<td class="align-right bright uv-index">
<div class="wi dimmed wi-hot"></div>
{{ current.uv_index }}
{{ current.uvIndex }}
</td>
{% endif %}
</div>
Expand Down Expand Up @@ -78,11 +78,11 @@
</span>
<br />
{% endif %}
{% if config.showPrecipitationAmount and current.precipitationAmount %}
{% if config.showPrecipitationAmount and current.precipitationAmount is defined and current.precipitationAmount is not none %}
<span class="dimmed"> <span class="precipitationLeadText">{{ "PRECIP_AMOUNT" | translate }}</span> {{ current.precipitationAmount | unit("precip", current.precipitationUnits) }} </span>
<br />
{% endif %}
{% if config.showPrecipitationProbability and current.precipitationProbability %}
{% if config.showPrecipitationProbability and current.precipitationProbability is defined and current.precipitationProbability is not none %}
<span class="dimmed"> <span class="precipitationLeadText">{{ "PRECIP_POP" | translate }}</span> {{ current.precipitationProbability }}% </span>
{% endif %}
</div>
Expand Down
Loading
Loading