Skip to content

Commit

Permalink
https://github.com/ioBroker/ioBroker.admin/issues/1424
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed May 26, 2022
1 parent b38b4f2 commit 6507c64
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/gulpfile.js
nbproject
/index.zip
/frontend/package-lock.json
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Branch (`master/main/dev`) is optional.
-->

## Changelog
### **WORK IN PROGRESS**
* (bluefox) Added support of jsonConfig.json5 and jsonCustom.json5

### 2.0.5 (2022-05-22)
* (bluefox) Made it possible to run with npx

Expand Down
26 changes: 14 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ const stream = require('stream');
const Writable = stream.Writable;
const sizeOf = require('image-size');
const axios = require('axios');
const JSON5 = require('json5');
const compareVersions = require('compare-versions');

const version = '1.4.0';
const version = require('./package.json').version;
const recommendedJsControllerVersion = '3.3.22';

const memStore = { };
Expand Down Expand Up @@ -1410,13 +1411,14 @@ function checkCode(context) {

if (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'json') {
readFiles.push('admin/jsonConfig.json');
allowedLanguages.forEach(lang => {
readFiles.push(`admin/i18n/${lang}/translations.json`);
});
readFiles.push('admin/jsonConfig.json5');
allowedLanguages.forEach(lang =>
readFiles.push(`admin/i18n/${lang}/translations.json`));
}

if (context.ioPackageJson.common.supportCustoms || context.ioPackageJson.common.jsonCustom || (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.custom === 'json')) {
readFiles.push('admin/jsonCustom.json');
readFiles.push('admin/jsonCustom.json5');
}
}

Expand Down Expand Up @@ -1504,14 +1506,14 @@ function checkCode(context) {
}

if (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.config === 'json') {
if (context['/admin/jsonConfig.json']) {
if (context['/admin/jsonConfig.json'] || context['/admin/jsonConfig.json5']) {
try {
JSON.parse(context['/admin/jsonConfig.json']);
context['/admin/jsonConfig.json'] ? JSON.parse(context['/admin/jsonConfig.json']) : JSON5.parse(context['/admin/jsonConfig.json5']);
} catch (e) {
context.errors.push('[E507] Cannot parse "admin/jsonConfig.json": ' + e);
context.errors.push(`[E507] Cannot parse "admin/jsonConfig.json${context['/admin/jsonConfig.json'] ? '' : '5'}": ${e}`);
}
} else {
context.errors.push(`[E508] "admin/jsonConfig.json" not found, but admin support is declared`);
context.errors.push(`[E508] "admin/jsonConfig.json${context['/admin/jsonConfig.json'] ? '' : '5'}" not found, but admin support is declared`);
}

allowedLanguages.forEach(lang => {
Expand All @@ -1528,14 +1530,14 @@ function checkCode(context) {
}

if (context.ioPackageJson.common.supportCustoms || context.ioPackageJson.common.jsonCustom || (context.ioPackageJson.common.adminUI && context.ioPackageJson.common.adminUI.custom === 'json')) {
if (context['/admin/jsonCustom.json']) {
if (context['/admin/jsonCustom.json'] || context['/admin/jsonCustom.json5']) {
try {
JSON.parse(context['/admin/jsonCustom.json']);
context['/admin/jsonCustom.json'] ? JSON.parse(context['/admin/jsonCustom.json']) : JSON5.parse(context['/admin/jsonCustom.json5']);
} catch (e) {
context.errors.push('[E511] Cannot parse "admin/jsonCustom.json": ' + e);
context.errors.push(`[E511] Cannot parse "admin/jsonCustom.json${context['/admin/jsonCustom.json'] ? '' : '5'}": ${e}`);
}
} else {
context.errors.push(`[E512] "admin/jsonCustom.json" not found, but custom support is declared`);
context.errors.push(`[E512] "admin/jsonCustom.json${context['/admin/jsonCustom.json'] ? '' : '5'}" not found, but custom support is declared`);
}
}

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"axios": "^0.27.2",
"compare-versions": "^4.1.3",
"image-size": "^1.0.1",
"unzipper": "^0.10.11"
"unzipper": "^0.10.11",
"json5": "^2.2.1"
},
"publishConfig": {
"access": "public"
Expand Down

0 comments on commit 6507c64

Please sign in to comment.