Skip to content

Commit

Permalink
v1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
bugsounet authored Dec 24, 2024
2 parents b8f9604 + 5c93470 commit 0568140
Show file tree
Hide file tree
Showing 11 changed files with 779 additions and 210 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ jobs:
run: npm prune

- name: Run ESLint
run: npx eslint *.js installer/*.js --config eslint.config.js
run: npm run test
continue-on-error: false
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/node_modules/
/node_helper.js
/MMM-Glassy.js
80 changes: 56 additions & 24 deletions eslint.config.js → eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
const globals = require("globals");
const eslintPluginStylistic = require("@stylistic/eslint-plugin");
const eslintPluginImport = require("eslint-plugin-import");
const eslintPluginJs = require("@eslint/js");
import globals from "globals";
import eslintPluginStylistic from "@stylistic/eslint-plugin";
import eslintPluginImport from "eslint-plugin-import";
import eslintPluginJs from "@eslint/js";
import eslintPluginPackageJson from "eslint-plugin-package-json/configs/recommended";

const config = [
eslintPluginImport.flatConfigs.recommended,
eslintPluginJs.configs.recommended,
{
files: ["**/*.js"],
languageOptions: {
ecmaVersion: "latest",
globals: {
"files": ["**/*.js"],
"languageOptions": {
"ecmaVersion": "latest",
"globals": {
...globals.browser,
...globals.node,
config: true,
Log: true,
MM: true,
Module: true,
moment: true,
document: true,
windows: true,
configMerge: true
"config": true,
"Log": true,
"MM": true,
"Module": true,
"moment": true,
"document": true,
"windows": true,
"configMerge": true
}
},
plugins: {
"plugins": {
...eslintPluginStylistic.configs["all-flat"].plugins
},
rules: {
"rules": {
...eslintPluginStylistic.configs["all-flat"].rules,
"@stylistic/array-element-newline": ["error", "consistent"],
"@stylistic/arrow-parens": ["error", "always"],
Expand All @@ -37,28 +38,28 @@ const config = [
"@stylistic/function-paren-newline": ["error", "consistent"],
"@stylistic/implicit-arrow-linebreak": ["error", "beside"],
"@stylistic/indent": ["error", 2],
"@stylistic/max-statements-per-line": ["error", { max: 2 }],
"@stylistic/max-statements-per-line": ["error", {"max": 2}],
"@stylistic/multiline-comment-style": "off",
"@stylistic/multiline-ternary": ["error", "always-multiline"],
"@stylistic/newline-per-chained-call": ["error", { ignoreChainWithDepth: 4 }],
"@stylistic/newline-per-chained-call": ["error", {"ignoreChainWithDepth": 4}],
"@stylistic/no-extra-parens": "off",
"@stylistic/no-tabs": "off",
"@stylistic/object-curly-spacing": ["error", "always"],
"@stylistic/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
"@stylistic/object-property-newline": ["error", {"allowAllPropertiesOnSameLine": true}],
"@stylistic/operator-linebreak": ["error", "before"],
"@stylistic/padded-blocks": "off",
"@stylistic/quote-props": ["error", "as-needed"],
"@stylistic/quotes": ["error", "double"],
"@stylistic/semi": ["error", "always"],
"@stylistic/space-before-function-paren": ["error", "always"],
"@stylistic/spaced-comment": "off",
eqeqeq: "error",
"eqeqeq": "error",
"id-length": "off",
"import/order": "error",
"import/extensions": [
"error",
{
json: "always" // ignore json require (display EXT version and rev date)
"json": "always" // ignore json require (display EXT version and rev date)
}
],
"import/newline-after-import": "error",
Expand All @@ -84,7 +85,38 @@ const config = [
"prefer-template": "error",
"sort-keys": "off"
}
},
{
"files": ["eslint.config.mjs"],
"languageOptions": {
"ecmaVersion": "latest",
"globals": {
...globals.node
},
"sourceType": "module"
},
"plugins": {
...eslintPluginStylistic.configs["all-flat"].plugins
},
"rules": {
...eslintPluginStylistic.configs["all-flat"].rules,
"@stylistic/indent": ["error", 2],
"@stylistic/array-element-newline": "off",
"@stylistic/function-call-argument-newline": "off",
"import/no-unresolved": "off"
}
},
{
"files": ["package.json"],
...eslintPluginPackageJson,
"rules": {
...eslintPluginPackageJson.rules,
"package-json/valid-name": "off"
}
},
{
"ignores": ["MMM-*.js", "node_helper.js"]
}
];

module.exports = config;
export default config;
54 changes: 54 additions & 0 deletions 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");
27 changes: 13 additions & 14 deletions installer/minify.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
* @busgounet
*/

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

var files = [
`../${require("../package.json").main}`,
"../node_helper.js"
];
var files = [];

let project = require("../package.json").name;
let revision = require("../package.json").rev;
Expand All @@ -23,9 +20,9 @@ let commentOut = "**/";
* search all javascript files
*/
function searchFiles () {
let components = globSync("../components/*.js");
let components = globSync("../src/**/*.js");
files = files.concat(components);
console.log(`Found: ${files.length} files to minify\n`);
console.log(`Found: ${files.length} files to install and minify\n`);
}

/**
Expand All @@ -42,21 +39,23 @@ async function minifyFiles () {
* @returns {boolean} resolved with true
*/
function minify (file) {
let pathResolve = path.resolve(__dirname, file);
let FileName = path.parse(file).base;
console.log("Process File:", 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: [pathResolve],
entryPoints: [pathInResolve],
allowOverwrite: true,
minify: true,
outfile: pathResolve,
outfile: pathOutResolve,
banner: {
js: `${commentIn} ${project}\n * File: ${FileName}\n * Version: ${version}\n * Revision: ${revision}\n${commentOut}`
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 ${commentOut}`
js: `${commentIn} Coded With Heart by @bugsounet -- https://www.bugsounet.fr ${commentOut}`
}
});
resolve(true);
Expand Down
54 changes: 54 additions & 0 deletions installer/src.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Install new source code to src (develop)
* @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(pathOutResolve, pathInResolve);
resolve(true);
} catch {
reject();
}
});
}

console.log("⚠ This Tools is reserved for develop only ⚠\n");
installFiles();
console.log("\n✅ All new sources files are copied to the src folder\n");
3 changes: 1 addition & 2 deletions installer/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ if [ "$EUID" -eq 0 ]; then
fi

echo
rm -f package-lock.json

Installer_info "Updating..."
(git reset --hard && git pull) || {
(npm run reset && git pull) || {
Installer_error "Update Failed!"
exit 255
}
Expand Down
Loading

0 comments on commit 0568140

Please sign in to comment.