Check for existence of info.json files (warning only). (#3991)

Co-authored-by: Catenocrypt <catenocrypt@users.noreply.github.com>
This commit is contained in:
Adam R 2020-09-16 15:32:23 +02:00 committed by GitHub
parent 4b59de04e1
commit 92adaaf07e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 3 deletions

View File

@ -8,6 +8,8 @@ import {
getChainLogoPath,
getChainAssetsPath,
getChainAssetPath,
getChainAssetLogoPath,
getChainAssetInfoPath,
assetFolderAllowedFiles,
getChainFolderFilesList,
chainFolderAllowedFiles,
@ -71,6 +73,42 @@ export class FoldersFiles implements ActionInterface {
return [errors, []];
}
},
{
getName: () => { return "Asset folders contain logo"},
check: async () => {
var errors: string[] = [];
foundChains.forEach(chain => {
const assetsPath = getChainAssetsPath(chain);
if (isPathExistsSync(assetsPath)) {
readDirSync(assetsPath).forEach(address => {
const logoFullPath = getChainAssetLogoPath(chain, address);
if (!isPathExistsSync(logoFullPath)) {
errors.push(`Missing logo file for asset '${chain}/${address}' -- ${logoFullPath}`);
}
}) ;
}
});
return [errors, []];
}
},
{
getName: () => { return "Asset folders contain info.json"},
check: async () => {
var warnings: string[] = [];
foundChains.forEach(chain => {
const assetsPath = getChainAssetsPath(chain);
if (isPathExistsSync(assetsPath)) {
readDirSync(assetsPath).forEach(address => {
const infoFullPath = getChainAssetInfoPath(chain, address);
if (!isPathExistsSync(infoFullPath)) {
warnings.push(`Missing info file for asset '${chain}/${address}' -- ${infoFullPath}`);
}
}) ;
}
});
return [[], warnings];
}
},
{
getName: () => { return "Asset folders contain only predefined set of files"},
check: async () => {
@ -79,7 +117,7 @@ export class FoldersFiles implements ActionInterface {
const assetsPath = getChainAssetsPath(chain);
if (isPathExistsSync(assetsPath)) {
readDirSync(assetsPath).forEach(address => {
const assetFiles = getChainAssetPath(chain, address)
const assetFiles = getChainAssetPath(chain, address);
readDirSync(assetFiles).forEach(assetFolderFile => {
if (!(assetFolderAllowedFiles.indexOf(assetFolderFile) >= 0)) {
errors.push(`File '${assetFolderFile}' not allowed at this path: ${assetsPath}`);
@ -90,7 +128,7 @@ export class FoldersFiles implements ActionInterface {
});
return [errors, []];
}
},
}
];
}

View File

@ -62,7 +62,7 @@ async function checkStepList(steps: CheckStepInterface[]): Promise<[string[], st
console.log(` ${chalk.yellow('!')} '${warn}'`);
warningsAll.push(warn);
} else if (cnt == maxErrosFromOneCheck) {
console.log(` ${chalk.red('X')} ${warnings.length} warnings in total, omitting rest ...`);
console.log(` ${chalk.yellow('!')} ${warnings.length} warnings in total, omitting rest ...`);
}
cnt++;
});