trustwallet-assets/script-old/gen_info.ts
Adam R 102f2b88d4
[Internal] New infra for runnig checks (not as jest tests) (#2938)
* CMC mapping update.

* New check infrastructure, move root folder test to new infra.

* Move list of allowed files to config.

* Include new check in other tests.

* More generic way to call checks.

* Organize fix and update actions behind interfaces.

* Organize checks into steps, multiple steps per action.

* Simplify checkStep class/instance creation.

* Migrate chain logo checks.

* Migrate asset folder check.

* Migrate further chain checks.

* Migrate eth fork folder checks.

* Migrate binance chain check.

* Extra output.

* Output improvements.

* Async fix.

* Migrate Tron check.

* Add Tron check.

* Remove Tron check from old.

* White/blacklist check in new intra, combined with fix.

* Refine ETH checks.

* Remove from old infra.

* Migrate CMC check to new infra.

* Migrate validator tests to new check infra.

* Migrate Json files validity check to new check infra.

* Whitelist check fix.

* Cleanup helpers.ts.

* Move helpers.ts.

* Cleanup of models.ts.

* Move models.ts.

* Move index.test.ts.

* Update with BEP8 support.

* Descriptive names for jobs within the builds.

Co-authored-by: Catenocrypt <catenocrypt@users.noreply.github.com>
2020-08-06 21:17:38 +02:00

79 lines
2.4 KiB
TypeScript

const bluebird = require("bluebird")
import { writeFileSync, readDirSync } from "../script/common/filesystem";
import {
chainsFolderPath,
getChainInfoPath,
isChainInfoExistSync,
} from "./helpers"
import { CoinInfoList } from "./models";
const dafaultInfoTemplate: CoinInfoList =
{
"name": "",
"website": "",
"source_code": "",
"whitepaper": "",
"short_description": "",
"explorer": "",
"socials": [
{
"name": "Twitter",
"url": "",
"handle": ""
},
{
"name": "Reddit",
"url": "",
"handle": ""
}
],
"details": [
{
"language": "en",
"description": ""
}
]
}
bluebird.mapSeries(readDirSync(chainsFolderPath), (chain: string) => {
const chainInfoPath = getChainInfoPath(chain)
// Create intial info.json file base off template if doesn't exist
if (!isChainInfoExistSync(chain)) {
writeToInfo(chainInfoPath, dafaultInfoTemplate)
}
// const infoList: InfoList = JSON.parse(readFileSync(chainInfoPath))
// delete infoList["data_source"]
// const newExplorer = nestedProperty.get(infoList, "explorers")
// console.log({newExplorer}, chain)
// nestedProperty.set(infoList, "explorer", newExplorer)
// delete infoList["explorers"]
// writeToInfo(chainInfoPath, infoList)
// if (isPathExistsSync(getChainAssetsPath(chain))) {
// readDirSync(getChainAssetsPath(chain)).forEach(asset => {
// const assetInfoPath = getChainAssetInfoPath(chain, asset)
// if (isPathExistsSync(assetInfoPath)) {
// const assetInfoList = JSON.parse(readFileSync(assetInfoPath))
// delete assetInfoList["data_source"]
// const newExplorers = nestedProperty.get(assetInfoList, "explorers.0.url")
// delete assetInfoList["explorers"]
// nestedProperty.set(assetInfoList, "explorer", newExplorers)
// writeToInfo(assetInfoPath, assetInfoList)
// }
// })
// }
})
// Get handle from Twitter and Reddit url
export function getHandle(url: string): string {
if (!url) return ""
return url.slice(url.lastIndexOf("/") + 1, url.length)
}
function writeToInfo(path: string, info: CoinInfoList) {
writeFileSync(path, JSON.stringify(info, null, 4))
}