From 50dbc8b542f4fb5d7f00bdb7335e2a9e90735d81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Wed, 27 Jan 2021 08:24:43 +0100 Subject: [PATCH 01/10] run superlinter --- .github/workflows/superlinter.yaml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/superlinter.yaml diff --git a/.github/workflows/superlinter.yaml b/.github/workflows/superlinter.yaml new file mode 100644 index 0000000..96ce0cd --- /dev/null +++ b/.github/workflows/superlinter.yaml @@ -0,0 +1,25 @@ +name: Super-Linter + +# Run this workflow every time a new commit pushed to your repository +on: push + +jobs: + # Set the job key. The key is displayed as the job name + # when a job name is not provided + super-lint: + # Name the Job + name: Lint code base + # Set the type of machine to run on + runs-on: ubuntu-latest + + steps: + # Checks out a copy of your repository on the ubuntu-latest machine + - name: Checkout code + uses: actions/checkout@v2 + + # Runs the Super-Linter action + - name: Run Super-Linter + uses: github/super-linter@v3 + env: + DEFAULT_BRANCH: main + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 2a2b67fda0cfaa8a3932a99244448c1873d34f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Wed, 27 Jan 2021 08:30:02 +0100 Subject: [PATCH 02/10] make docker-entrypoint.sh executable This way the chmod +x in the Dockerfile is not needed anymore. --- Dockerfile | 1 - docker-entrypoint.sh | 0 2 files changed, 1 deletion(-) mode change 100644 => 100755 docker-entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 1aecfce..114f569 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,6 @@ RUN cp -R config /opt/default_config RUN npm install --unsafe-perm --silent COPY mm-docker-config.js docker-entrypoint.sh ./ -RUN chmod +x ./docker-entrypoint.sh EXPOSE 8080 ENTRYPOINT ["./docker-entrypoint.sh"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh old mode 100644 new mode 100755 From 6d83054e472c1edb02e297a56c4f00ccc5edcbce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Wed, 27 Jan 2021 08:35:25 +0100 Subject: [PATCH 03/10] hadolint suggests to use apt-get instead of the higher-level apt --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 114f569..898c36b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ FROM node:12-buster RUN set -e; \ - apt update; \ - apt install -y gettext; \ + apt-get update; \ + apt-get install -y gettext; \ rm -rf /var/lib/apt/lists/* ARG branch=master From c03ff0f3d2c9c3ba93776afa15d4a52dc83024c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Wed, 27 Jan 2021 08:38:15 +0100 Subject: [PATCH 04/10] reformat CODE_OF_CONDUCT.md to fit 80char wide --- .github/CODE_OF_CONDUCT.md | 39 +++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md index e7bd077..4c9ef5f 100644 --- a/.github/CODE_OF_CONDUCT.md +++ b/.github/CODE_OF_CONDUCT.md @@ -2,7 +2,12 @@ ## Our Pledge -In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, +body size, disability, ethnicity, gender identity and expression, level of +experience, nationality, personal appearance, race, religion, or sexual +identity and orientation. ## Our Standards @@ -24,23 +29,43 @@ Examples of unacceptable behavior by participants include: ## Our Responsibilities -Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. ## Scope -This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an +appointed representative at an online or offline event. Representation of a +project may be further defined and clarified by project maintainers. ## Enforcement -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at bastilimbach@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at bastilimbach@gmail.com. The project +team will review and investigate all complaints, and will respond in a way that +it deems appropriate to the circumstances. The project team is obligated to +maintain confidentiality with regard to the reporter of an incident. Further +details of specific enforcement policies may be posted separately. -Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 1.4, available at +[http://contributor-covenant.org/version/1/4][version] [homepage]: http://contributor-covenant.org [version]: http://contributor-covenant.org/version/1/4/ From a76e40b024f0d523f7a16a5279a5c15df83cd8ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Wed, 27 Jan 2021 08:41:25 +0100 Subject: [PATCH 05/10] markdownlint The first line isn't a real heading, but making it requires then changing all subsequent headings to a lever deeper. I opted to deactivate the rule. Also remove the space from the link, it isn't needed. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d40cf26..8517ded 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -[![MagicMirror²: The open source modular smart mirror platform. ](https://github.com/MichMich/MagicMirror/raw/master/.github/header.png)](https://github.com/MichMich/MagicMirror) + +[![MagicMirror²: The open source modular smart mirror platform.](https://github.com/MichMich/MagicMirror/raw/master/.github/header.png)](https://github.com/MichMich/MagicMirror) **MagicMirror²** is an open source modular smart mirror platform. With a growing list of installable modules, the **MagicMirror²** allows you to convert your hallway or bathroom mirror into your personal assistant. From ea7ee3e26feb868df1db871ebc99d6656ac3f95a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Wed, 27 Jan 2021 09:13:44 +0100 Subject: [PATCH 06/10] standard lint suggests single quotes this one might be an overreach, hence the separate commit --- mm-docker-config.js | 72 ++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/mm-docker-config.js b/mm-docker-config.js index 7ae119c..bdd0553 100644 --- a/mm-docker-config.js +++ b/mm-docker-config.js @@ -9,78 +9,78 @@ */ var config = { - address: "0.0.0.0", // Address to listen on, can be: - // - "localhost", "127.0.0.1", "::1" to listen on loopback interface + address: '0.0.0.0', // Address to listen on, can be: + // - 'localhost', '127.0.0.1', '::1' to listen on loopback interface // - another specific IPv4/6 to listen on a specific interface - // - "0.0.0.0" to listen on any interface - // Default, when address config is left out, is "localhost" + // - '0.0.0.0' to listen on any interface + // Default, when address config is left out, is 'localhost' port: 8080, ipWhitelist: [], // Set [] to allow all IP addresses // or add a specific IPv4 of 192.168.1.5 : - // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.1.5"], + // ['127.0.0.1', '::ffff:127.0.0.1', '::1', '::ffff:192.168.1.5'], // or IPv4 range of 192.168.3.0 --> 192.168.3.15 use CIDR format : - // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.3.0/28"], + // ['127.0.0.1', '::ffff:127.0.0.1', '::1', '::ffff:192.168.3.0/28'], - language: "en", + language: 'en', timeFormat: 24, - units: "metric", + units: 'metric', modules: [ { - module: "alert", + module: 'alert', }, { - module: "updatenotification", - position: "top_bar" + module: 'updatenotification', + position: 'top_bar' }, { - module: "clock", - position: "top_left" + module: 'clock', + position: 'top_left' }, { - module: "calendar", - header: "US Holidays", - position: "top_left", + module: 'calendar', + header: 'US Holidays', + position: 'top_left', config: { calendars: [ { - symbol: "calendar-check", - url: "webcal://www.calendarlabs.com/ical-calendar/ics/76/US_Holidays.ics" + symbol: 'calendar-check', + url: 'webcal://www.calendarlabs.com/ical-calendar/ics/76/US_Holidays.ics' } ] } }, { - module: "compliments", - position: "lower_third" + module: 'compliments', + position: 'lower_third' }, { - module: "currentweather", - position: "top_right", + module: 'currentweather', + position: 'top_right', config: { - location: "New York", - locationID: "", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city - appid: "YOUR_OPENWEATHER_API_KEY" + location: 'New York', + locationID: '', //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city + appid: 'YOUR_OPENWEATHER_API_KEY' } }, { - module: "weatherforecast", - position: "top_right", - header: "Weather Forecast", + module: 'weatherforecast', + position: 'top_right', + header: 'Weather Forecast', config: { - location: "New York", - locationID: "5128581", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city - appid: "YOUR_OPENWEATHER_API_KEY" + location: 'New York', + locationID: '5128581', //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city + appid: 'YOUR_OPENWEATHER_API_KEY' } }, { - module: "newsfeed", - position: "bottom_bar", + module: 'newsfeed', + position: 'bottom_bar', config: { feeds: [ { - title: "New York Times", - url: "http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml" + title: 'New York Times', + url: 'http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml' } ], showSourceTitle: true, @@ -94,4 +94,4 @@ var config = { }; /*************** DO NOT EDIT THE LINE BELOW ***************/ -if (typeof module !== "undefined") { module.exports = config; } +if (typeof module !== 'undefined') { module.exports = config; } From 4233dca74ecd67f0701c8807d6ebe609b3b3c0a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Wed, 27 Jan 2021 20:09:01 +0100 Subject: [PATCH 07/10] do not use standard to list javascript standard's settings conflict with what the upstream config.js is, so it's not worth to run it. --- .github/workflows/superlinter.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/superlinter.yaml b/.github/workflows/superlinter.yaml index 96ce0cd..0e6ee78 100644 --- a/.github/workflows/superlinter.yaml +++ b/.github/workflows/superlinter.yaml @@ -23,3 +23,6 @@ jobs: env: DEFAULT_BRANCH: main GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # the standard config conflicts heavily with the upstream config.js + # hence I opted to disable it + VALIDATE_JAVASCRIPT_STANDARD: false From cfcd24318c10feb2031588f2c83ae0286d7d1353 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Wed, 27 Jan 2021 20:22:42 +0100 Subject: [PATCH 08/10] hadolint recommends --no-recommends --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 898c36b..d454023 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM node:12-buster RUN set -e; \ apt-get update; \ - apt-get install -y gettext; \ + apt-get install -y --no-install-recommends gettext; \ rm -rf /var/lib/apt/lists/* ARG branch=master From a30eedc020057d1967d6f6a09926d37f26e8a115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Wed, 27 Jan 2021 20:23:27 +0100 Subject: [PATCH 09/10] hadolint would like use to pin gettext to a version but it doesn't make sense, as sooner or later the base image will change to someting newer, and gettext will have a newer version available. --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index d454023..ed8b839 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ FROM node:12-buster +# hadolint ignore=DL3008 RUN set -e; \ apt-get update; \ apt-get install -y --no-install-recommends gettext; \ From ecb0b9988ea1dbe2fc6cac1063e97ce01d38b08c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=20Kl=C3=A4rner?= Date: Wed, 27 Jan 2021 20:26:12 +0100 Subject: [PATCH 10/10] follow shellchecks recommendations to quote everything and also add a shebang where previously was none. --- build.sh | 4 ++-- test-build.sh | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index 1ff6a00..5ad9d31 100755 --- a/build.sh +++ b/build.sh @@ -4,7 +4,7 @@ set -e # https://stackoverflow.com/a/51761312/4934537 latest_release=$(git ls-remote --tags --refs --sort="v:refname" https://github.com/MichMich/MagicMirror.git | tail -n1 | sed 's/.*\///') if [ "$(docker manifest inspect bastilimbach/docker-magicmirror:"${latest_release}" > /dev/null; echo $?)" != 0 ]; then - docker buildx build --progress plain --platform=linux/amd64,linux/arm64,linux/arm/v7 ${1} --build-arg branch="${latest_release}" -t bastilimbach/docker-magicmirror:"${latest_release}" -t bastilimbach/docker-magicmirror:latest . + docker buildx build --progress plain --platform=linux/amd64,linux/arm64,linux/arm/v7 "${1}" --build-arg branch="${latest_release}" -t bastilimbach/docker-magicmirror:"${latest_release}" -t bastilimbach/docker-magicmirror:latest . fi -docker buildx build --progress plain --platform=linux/amd64,linux/arm64,linux/arm/v7 ${1} --build-arg branch=develop -t bastilimbach/docker-magicmirror:develop . +docker buildx build --progress plain --platform=linux/amd64,linux/arm64,linux/arm/v7 "${1}" --build-arg branch=develop -t bastilimbach/docker-magicmirror:develop . diff --git a/test-build.sh b/test-build.sh index a8b7b48..e11f207 100755 --- a/test-build.sh +++ b/test-build.sh @@ -1,3 +1,5 @@ +#!/bin/bash + rm -rf ./config rm -rf ./modules mkdir config @@ -8,7 +10,7 @@ docker build -t mm:latest . docker run -d \ --publish 80:8080 \ --restart always \ - --volume $PWD/config:/opt/magic_mirror/config \ - --volume $PWD/modules:/opt/magic_mirror/modules \ + --volume "$PWD"/config:/opt/magic_mirror/config \ + --volume "$PWD"/modules:/opt/magic_mirror/modules \ --name magic_mirror \ mm:latest