Skip to content

Commit

Permalink
add EXT-Screen
Browse files Browse the repository at this point in the history
  • Loading branch information
bugsounet committed Dec 15, 2024
1 parent e1e3137 commit 3c023d3
Show file tree
Hide file tree
Showing 30 changed files with 1,269 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/esbuild - EXT-Screen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "ESBuild Testing: EXT-Screen"

on: [pull_request]

jobs:
eslint:
name: Run esbuild
runs-on: ubuntu-latest
steps:
- name: "Use Node.js v20.x (latest)"
uses: actions/setup-node@v4
with:
node-version: "20.x"
check-latest: true

- name: Checkout code
uses: actions/checkout@v4

- name: Install Dependencies
run: npm prune

- name: Run ESBuild
run: cd EXTs/EXT-Screen && npm run test:minify
continue-on-error: false
2 changes: 2 additions & 0 deletions EXTs/EXT-Screen/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
engine-strict=true
audit=false
21 changes: 21 additions & 0 deletions EXTs/EXT-Screen/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Bugsounet - Cédric

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
18 changes: 18 additions & 0 deletions EXTs/EXT-Screen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# EXT-Screen - Extented for `MMM-GoogleAssistant`

After a configurated time without any user interaction the display will turn off and hide all modules for economy mode.

This plugin need [MMM-Pir](https://github.com/bugsounet/MMM-Pir) for working with MMM-GoogleAssistant rules

## Screenshot
![](https://raw.githubusercontent.com/bugsounet/EXT-Screen/dev/screenshot/screenshot.png)

![](https://raw.githubusercontent.com/bugsounet/EXT-Screen/dev/screenshot/screenshot2.png)

## Installation / update / configuration

Read the docs in [wiki](https://wiki.bugsounet.fr/EXT-Screen)

## Donate
[Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=TTHRH94Y4KL36&source=url), if you love this module !

54 changes: 54 additions & 0 deletions EXTs/EXT-Screen/installer/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Install src code without minify
* @busgounet
*/

const path = require("node:path");
const { copyFileSync } = require("node:fs");
const { globSync } = require("glob");

var files = [];

let project = require("../package.json").name;

/**
* search all javascript files
*/
function searchFiles () {
let components = globSync("../src/**/*.js");
files = files.concat(components);
console.log(`Found: ${files.length} files to install\n`);
}

/**
* Install all files in array with Promise
*/
async function installFiles () {
searchFiles();
await Promise.all(files.map((file) => { return install(file); })).catch(() => process.exit(255));
}

/**
* Install filename with copyFileSync
* @param {string} file to install
* @returns {boolean} resolved with true
*/
function install (file) {
let FileName = file.replace("../src/", "../");
let GAFileName = `${project}/${FileName.replace("../", "")}`;
let pathInResolve = path.resolve(__dirname, file);
let pathOutResolve = path.resolve(__dirname, FileName);
console.log("Process File:", GAFileName);
return new Promise((resolve, reject) => {
try {
copyFileSync(pathInResolve, pathOutResolve);
resolve(true);
} catch {
reject();
}
});
}

console.log("⚠ This Tools is reserved for develop only ⚠\n");
installFiles();
console.log("\n✅ All sources files are installed and ready for developing\n");
68 changes: 68 additions & 0 deletions EXTs/EXT-Screen/installer/minify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Code minifier
* @busgounet
*/

const path = require("node:path");
const { globSync } = require("glob");
const esbuild = require("esbuild");

var files = [];

let project = require("../package.json").name;
let revision = require("../package.json").rev;
let version = require("../package.json").version;

let commentIn = "/**";
let commentOut = "**/";

/**
* search all javascript files
*/
function searchFiles () {
let components = globSync("../src/**/*.js");
files = files.concat(components);
console.log(`Found: ${files.length} files to install and minify\n`);
}

/**
* Minify all files in array with Promise
*/
async function minifyFiles () {
searchFiles();
await Promise.all(files.map((file) => { return minify(file); })).catch(() => process.exit(255));
}

/**
* Minify filename with esbuild
* @param {string} file to minify
* @returns {boolean} resolved with true
*/
function minify (file) {
let FileName = file.replace("../src/", "../");
let GAFileName = `${project}/${FileName.replace("../", "")}`;
let pathInResolve = path.resolve(__dirname, file);
let pathOutResolve = path.resolve(__dirname, FileName);
console.log("Process File:", GAFileName);
return new Promise((resolve, reject) => {
try {
esbuild.buildSync({
entryPoints: [pathInResolve],
allowOverwrite: true,
minify: true,
outfile: pathOutResolve,
banner: {
js: `${commentIn} ${project}\n * File: ${GAFileName}\n * Version: ${version}\n * Revision: ${revision}\n * ⚠ This file must not be modified ⚠\n${commentOut}`
},
footer: {
js: `${commentIn} ❤ Coded With Heart by @bugsounet -- https://www.bugsounet.fr ${commentOut}`
}
});
resolve(true);
} catch {
reject();
}
});
}

minifyFiles();
Loading

0 comments on commit 3c023d3

Please sign in to comment.