Skip to content

Commit

Permalink
New eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Nov 29, 2024
1 parent bf4385b commit 24e76de
Show file tree
Hide file tree
Showing 149 changed files with 20,537 additions and 15,137 deletions.
184 changes: 92 additions & 92 deletions packages/iobroker.vis-2/admin/jsonConfig.json
Original file line number Diff line number Diff line change
@@ -1,98 +1,98 @@
{
"type": "tabs",
"i18n": true,
"items": {
"license": {
"label": "License",
"type": "panel",
"items": {
"useLicenseManager": {
"type": "checkbox",
"label": "Use license manager",
"sm": 12
},
"type": "tabs",
"i18n": true,
"items": {
"license": {
"newLine": true,
"type": "text",
"minRows": 4,
"sm": 12,
"label": "License",
"hidden": "!!data.useLicenseManager"
},
"_uuid": {
"newLine": true,
"type": "uuid",
"sm": 12,
"md": 6,
"lg": 4
},
"_checkLicense": {
"newLine": true,
"type": "checkLicense",
"uuid": true,
"version": true
},
"_help": {
"newLine": true,
"type": "staticText",
"sm": 12,
"md": 6,
"lg": 4,
"text": "instruction"
},
"doNotShowProjectDialog": {
"newLine": true,
"type": "checkbox",
"label": "Do not show project dialog if URL is wrong",
"sm": 12
},
"forceBuild": {
"newLine": true,
"type": "checkbox",
"label": "Force pages rebuild",
"sm": 12
}
}
},
"loading": {
"label": "Loading background",
"type": "panel",
"items": {
"loadingBackgroundColor": {
"type": "color",
"sm": 12,
"md": 8,
"lg": 4,
"label": "Background color of the loading screen"
},
"loadingHideLogo": {
"newLine": true,
"sm": 12,
"md": 8,
"lg": 4,
"type": "checkbox",
"label": "Hide logo"
},
"loadingBackgroundImage": {
"newLine": true,
"sm": 12,
"md": 8,
"lg": 4,
"type": "checkbox",
"label": "Use background image"
"label": "License",
"type": "panel",
"items": {
"useLicenseManager": {
"type": "checkbox",
"label": "Use license manager",
"sm": 12
},
"license": {
"newLine": true,
"type": "text",
"minRows": 4,
"sm": 12,
"label": "License",
"hidden": "!!data.useLicenseManager"
},
"_uuid": {
"newLine": true,
"type": "uuid",
"sm": 12,
"md": 6,
"lg": 4
},
"_checkLicense": {
"newLine": true,
"type": "checkLicense",
"uuid": true,
"version": true
},
"_help": {
"newLine": true,
"type": "staticText",
"sm": 12,
"md": 6,
"lg": 4,
"text": "instruction"
},
"doNotShowProjectDialog": {
"newLine": true,
"type": "checkbox",
"label": "Do not show project dialog if URL is wrong",
"sm": 12
},
"forceBuild": {
"newLine": true,
"type": "checkbox",
"label": "Force pages rebuild",
"sm": 12
}
}
},
"loading-bg.png": {
"newLine": true,
"type": "image",
"hidden": "!data.loadingBackgroundImage",
"sm": 12,
"md": 8,
"lg": 4,
"accept": "image/png",
"label": "Upload image",
"crop": true
"loading": {
"label": "Loading background",
"type": "panel",
"items": {
"loadingBackgroundColor": {
"type": "color",
"sm": 12,
"md": 8,
"lg": 4,
"label": "Background color of the loading screen"
},
"loadingHideLogo": {
"newLine": true,
"sm": 12,
"md": 8,
"lg": 4,
"type": "checkbox",
"label": "Hide logo"
},
"loadingBackgroundImage": {
"newLine": true,
"sm": 12,
"md": 8,
"lg": 4,
"type": "checkbox",
"label": "Use background image"
},
"loading-bg.png": {
"newLine": true,
"type": "image",
"hidden": "!data.loadingBackgroundImage",
"sm": 12,
"md": 8,
"lg": 4,
"accept": "image/png",
"label": "Upload image",
"crop": true
}
}
}
}
}
}
}
29 changes: 16 additions & 13 deletions packages/iobroker.vis-2/lib/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ function stringify(name, data, isConvert, files) {
for (let mm = 0; mm < m.length; mm++) {
let fn = m[mm].substring(5); // remove ": "/
const originalFileName = fn.replace(/"/g, ''); // remove last "
const p = fn.split('/');
const p = fn.split('/');
const adapter = p.shift(); // remove vis.0 or whatever
const _project = p.length > 1 ? p.shift() : '';
fn = p.length ? p.shift() : ''; // keep only one subdirectory
fn += p.length ? `/${p.join('/')}` : '';// all other subdirectories combine again
fn = p.length ? p.shift() : ''; // keep only one subdirectory
fn += p.length ? `/${p.join('/')}` : ''; // all other subdirectories combine again

if (adapter !== 'vis-2.0' || _project !== project) {
// add to files
if (files.indexOf(originalFileName) === -1) { // if "vis.0/dir/otherProject.png"
if (files.indexOf(originalFileName) === -1) {
// if "vis.0/dir/otherProject.png"
files.push(originalFileName);
}
data = data.replace(m[mm], `": "/vis-2.0/${project}/${fn}`);
Expand All @@ -31,15 +32,16 @@ function stringify(name, data, isConvert, files) {
for (let mm = 0; mm < m.length; mm++) {
let fn = m[mm].substring(7); // remove src=\"/
const originalFileName = fn.replace(/\\"/g, ''); // remove last "
const p = fn.split('/');
const p = fn.split('/');
const adapter = p.shift(); // remove vis-2.0 or whatever
const _project = p.length > 1 ? p.shift() : '';
fn = p.length ? p.shift() : ''; // keep only one subdirectory
fn += p.length ? `/${p.join('/')}` : '';// all other subdirectories combine again
fn = p.length ? p.shift() : ''; // keep only one subdirectory
fn += p.length ? `/${p.join('/')}` : ''; // all other subdirectories combine again

if (adapter !== 'vis-2.0' || _project !== project) {
// add to files
if (files.indexOf(originalFileName) === -1) { // if "vis-2.0/dir/otherProject.png"
if (files.indexOf(originalFileName) === -1) {
// if "vis-2.0/dir/otherProject.png"
files.push(originalFileName);
}
data = data.replace(m[mm], `src=\\"/vis-2.0/${project}/${fn}`);
Expand All @@ -52,15 +54,16 @@ function stringify(name, data, isConvert, files) {
for (let mm = 0; mm < m.length; mm++) {
let fn = m[mm].substring(6); // remove src="/
const originalFileName = fn.replace(/'/g, ''); // remove last "
const p = fn.split('/');
const p = fn.split('/');
const adapter = p.shift(); // remove vis.0 or whatever
const _project = p.length > 1 ? p.shift() : '';
fn = p.length ? p.shift() : ''; // keep only one subdirectory
fn += p.length ? `/${p.join('/')}` : '';// all other subdirectories combine again
fn = p.length ? p.shift() : ''; // keep only one subdirectory
fn += p.length ? `/${p.join('/')}` : ''; // all other subdirectories combine again

if (adapter !== 'vis-2.0' || _project !== project) {
// add to files
if (files.indexOf(originalFileName) === -1) { // if "vis-2.0/dir/otherProject.png"
if (files.indexOf(originalFileName) === -1) {
// if "vis-2.0/dir/otherProject.png"
files.push(originalFileName);
}
data = data.replace(m[mm], `src='/vis-2.0/${project}/${fn}`);
Expand Down Expand Up @@ -99,4 +102,4 @@ function parse(projectName, fileName, data, settings) {
return data;
}
module.exports.stringify = stringify;
module.exports.parse = parse;
module.exports.parse = parse;
67 changes: 35 additions & 32 deletions packages/iobroker.vis-2/lib/install.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
const fs = require('node:fs');
const fs = require('node:fs');
const path = require('node:path');
let mime;
import('mime').then(m => mime = m.default);
import('mime').then(m => (mime = m.default));
const crypto = require('node:crypto');

const TEXT_TYPES = [
'application/json',
'application/javascript',
'image/svg+xml',
];
const TEXT_TYPES = ['application/json', 'application/javascript', 'image/svg+xml'];

function copyFileSync(source, target, forceBuild) {
let targetFile = target;
Expand Down Expand Up @@ -84,14 +80,13 @@ function copyFolderRecursiveSync(source, target, forceBuild) {

// Delete all old files
if (target !== path.normalize(`${__dirname}/../www/`)) {
oldFiles
.forEach(file => {
const pathName = path.join(targetFolder, file);
if (!files.includes(file) && !fs.lstatSync(pathName).isDirectory()) {
fs.unlinkSync(pathName);
changed = true;
}
});
oldFiles.forEach(file => {
const pathName = path.join(targetFolder, file);
if (!files.includes(file) && !fs.lstatSync(pathName).isDirectory()) {
fs.unlinkSync(pathName);
changed = true;
}
});
}
}

Expand All @@ -104,26 +99,22 @@ function deleteFolderRecursive(dirPath) {
files = fs.readdirSync(dirPath);
files.forEach((file, index) => {
const curPath = `${dirPath}/${file}`;
if (fs.lstatSync(curPath).isDirectory()) { // recurse
if (fs.lstatSync(curPath).isDirectory()) {
// recurse
deleteFolderRecursive(curPath);
} else { // delete file
} else {
// delete file
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(dirPath);
}
}

const generic = [
'basic',
'jqplot',
'jqui',
'swipe',
'tabs',
];
const generic = ['basic', 'jqplot', 'jqui', 'swipe', 'tabs'];

const widgetSetsDependencies = {
jqui: ['basic']
jqui: ['basic'],
};

function syncWidgetSets(enabledList, forceBuild) {
Expand All @@ -133,11 +124,16 @@ function syncWidgetSets(enabledList, forceBuild) {

// Now we have the list of widgets => copy them all to widgets directory
for (let d = 0; d < enabledList.length; d++) {
let _changed = copyFolderRecursiveSync(`${enabledList[d].path}/widgets/`, path.normalize(`${__dirname}/../www/`, forceBuild));
let _changed = copyFolderRecursiveSync(
`${enabledList[d].path}/widgets/`,
path.normalize(`${__dirname}/../www/`, forceBuild),
);
if (_changed) {
filesChanged = true;
}
console.log(`Check ${enabledList[d].path.replace(/\\/g, '/').split('/').pop()}... ${_changed ? 'COPIED.' : 'no changes.'}`);
console.log(
`Check ${enabledList[d].path.replace(/\\/g, '/').split('/').pop()}... ${_changed ? 'COPIED.' : 'no changes.'}`,
);
}

const widgetSets = [];
Expand All @@ -151,7 +147,9 @@ function syncWidgetSets(enabledList, forceBuild) {
found = isGeneric;

if (!found) {
found = enabledList.find(w => w.name.toLowerCase() === `iobroker.vis-${name}` || w.name.toLowerCase() === `iobroker.${name}`);
found = enabledList.find(
w => w.name.toLowerCase() === `iobroker.vis-${name}` || w.name.toLowerCase() === `iobroker.${name}`,
);
}

if (!found) {
Expand All @@ -164,15 +162,20 @@ function syncWidgetSets(enabledList, forceBuild) {
} else {
if (isGeneric) {
if (widgetSetsDependencies[name] && widgetSetsDependencies[name].length) {
widgetSets.push({name, depends: widgetSetsDependencies[name]});
widgetSets.push({ name, depends: widgetSetsDependencies[name] });
} else {
widgetSets.push(name);
}
} else {
if (found.pack && found.pack.native && found.pack.native.always) {
widgetSets.push({name, always: true});
} else if (found.pack && found.pack.native && found.pack.native.dependencies && found.pack.native.dependencies.length) {
widgetSets.push({name, depends: found.pack.native.dependencies});
widgetSets.push({ name, always: true });
} else if (
found.pack &&
found.pack.native &&
found.pack.native.dependencies &&
found.pack.native.dependencies.length
) {
widgetSets.push({ name, depends: found.pack.native.dependencies });
} else {
widgetSets.push(name);
}
Expand Down
Loading

0 comments on commit 24e76de

Please sign in to comment.