trustwallet-assets/script/action/update-all.ts

124 lines
4.0 KiB
TypeScript
Raw Normal View History

import { BinanceAction } from "./binance";
import { CosmosAction } from "./cosmos";
import { EthForks } from "./eth-forks";
import { FoldersFiles } from "./folders-and-files";
import { JsonAction } from "./json";
import { KavaAction } from "./kava";
import { LogoSize } from "./logo-size";
import { TerraAction } from "./terra";
import { TezosAction } from "./tezos";
import { TronAction } from "./tron";
import { Validators } from "./validators";
import { WavesAction } from "./waves";
import { Whitelist } from "./whitelists";
import { Coinmarketcap } from "../../pricing/coinmarketcap/cmc-action";
import { ActionInterface, CheckStepInterface } from "./interface";
import * as chalk from 'chalk';
import * as bluebird from "bluebird";
const actionList: ActionInterface[] = [
new FoldersFiles(),
new EthForks(),
new LogoSize(),
new Whitelist(),
new Validators(),
new JsonAction(),
// chains:
new BinanceAction(),
new CosmosAction(),
new KavaAction(),
new TerraAction(),
new TezosAction(),
new TronAction(),
new WavesAction(),
new Coinmarketcap()
];
async function checkStepList(steps: CheckStepInterface[]): Promise<number> {
var returnCode = 0;
await bluebird.each(steps, async (step) => {
try {
//console.log(` Running check step '${step.getName()}'...`);
const error = await step.check();
if (error && error.length > 0) {
console.log(`- ${chalk.red('X')} '${step.getName()}': '${error}'`);
returnCode = 1;
} else {
console.log(`- ${chalk.green('✓')} '${step.getName()}' OK`);
}
} catch (error) {
console.log(`- ${chalk.red('X')} '${step.getName()}': Caught error: ${error.message}`);
returnCode = 2;
}
});
return returnCode;
}
async function checkActionList(actions: ActionInterface[]): Promise<number> {
console.log("Running checks...");
var returnCode = 0;
await bluebird.each(actions, async (action) => {
try {
if (action.getChecks) {
const steps = action.getChecks();
if (steps && steps.length > 0) {
console.log(` Action '${action.getName()}' has ${steps.length} check steps`);
const ret1 = await checkStepList(steps);
if (ret1 != 0) {
returnCode = ret1;
} else {
console.log(`- ${chalk.green('✓')} Action '${action.getName()}' OK, all ${steps.length} steps`);
}
}
}
} catch (error) {
console.log(`- ${chalk.red('X')} '${action.getName()}' Caught error: ${error.message}`);
returnCode = 3;
}
});
console.log(`All checks done, returnCode ${returnCode}`);
return returnCode;
}
async function fixByList(actions: ActionInterface[]) {
[Internal] Refactored fix builds (#2920) * Empty infrastructure for new-housekeeping build. * Move updateBEP action to new new-housekeeping build infra. * Remove old updateBEP. * New-housekeeping-dryrun run. * Include new top-level folder name script-new. * Remove update:bep2 from old daily-run. * Use imports instead of require. * Small refactor for testability. * Organize scripts into subfolders. * iUpdateBEP2: refactor and add tests. * Move formatting validators to new-housekeeping,add new helpers. * Move info and black/whitelist fixing to new-housekeeping. * New fix command. * New 'fix' target; Move ETH checksum fix to new-housekeeping. * Move logo size check and resize to new-housekeeping. * Improved async error handling. * Build renames. * Move (old) BEP2 and CMC update to periodic update build. * Rename (add missing). * Rename builds. * Renames ('fix'). * rename * Invoke new scripts (as well) from period-update. * Move cmc update to new-periodic. * Move tezos validator update to new-periodic. * Missing file. * Leftover. * Cleanup * Rename of unused openseacontracts. * CMC should not be run always. * Break main/fixAndUpdate function into two. * Show diff in build after changes. * Cleanup * Rename, script-old. * Cleanup, remove old fix build definitions. * Renames, remove new- prefix. * CMC mapping update. * Config infrastructure; add binance URL to config. * Add image size parameters to config. * Rename. Co-authored-by: Catenocrypt <catenocrypt@users.noreply.github.com> Co-authored-by: Andrew M <35627271+zachzwei@users.noreply.github.com>
2020-07-29 13:42:51 +00:00
console.log("Running fixes...");
await bluebird.each(actions, async (action) => {
try {
if (action.fix) {
console.log(`Fix '${action.getName()}':`);
await action.fix();
}
} catch (error) {
console.log(`Caught error: ${error.message}`);
}
});
console.log("All fixes done.");
[Internal] Refactored fix builds (#2920) * Empty infrastructure for new-housekeeping build. * Move updateBEP action to new new-housekeeping build infra. * Remove old updateBEP. * New-housekeeping-dryrun run. * Include new top-level folder name script-new. * Remove update:bep2 from old daily-run. * Use imports instead of require. * Small refactor for testability. * Organize scripts into subfolders. * iUpdateBEP2: refactor and add tests. * Move formatting validators to new-housekeeping,add new helpers. * Move info and black/whitelist fixing to new-housekeeping. * New fix command. * New 'fix' target; Move ETH checksum fix to new-housekeeping. * Move logo size check and resize to new-housekeeping. * Improved async error handling. * Build renames. * Move (old) BEP2 and CMC update to periodic update build. * Rename (add missing). * Rename builds. * Renames ('fix'). * rename * Invoke new scripts (as well) from period-update. * Move cmc update to new-periodic. * Move tezos validator update to new-periodic. * Missing file. * Leftover. * Cleanup * Rename of unused openseacontracts. * CMC should not be run always. * Break main/fixAndUpdate function into two. * Show diff in build after changes. * Cleanup * Rename, script-old. * Cleanup, remove old fix build definitions. * Renames, remove new- prefix. * CMC mapping update. * Config infrastructure; add binance URL to config. * Add image size parameters to config. * Rename. Co-authored-by: Catenocrypt <catenocrypt@users.noreply.github.com> Co-authored-by: Andrew M <35627271+zachzwei@users.noreply.github.com>
2020-07-29 13:42:51 +00:00
}
async function updateByList(actions: ActionInterface[]) {
[Internal] Refactored fix builds (#2920) * Empty infrastructure for new-housekeeping build. * Move updateBEP action to new new-housekeeping build infra. * Remove old updateBEP. * New-housekeeping-dryrun run. * Include new top-level folder name script-new. * Remove update:bep2 from old daily-run. * Use imports instead of require. * Small refactor for testability. * Organize scripts into subfolders. * iUpdateBEP2: refactor and add tests. * Move formatting validators to new-housekeeping,add new helpers. * Move info and black/whitelist fixing to new-housekeeping. * New fix command. * New 'fix' target; Move ETH checksum fix to new-housekeeping. * Move logo size check and resize to new-housekeeping. * Improved async error handling. * Build renames. * Move (old) BEP2 and CMC update to periodic update build. * Rename (add missing). * Rename builds. * Renames ('fix'). * rename * Invoke new scripts (as well) from period-update. * Move cmc update to new-periodic. * Move tezos validator update to new-periodic. * Missing file. * Leftover. * Cleanup * Rename of unused openseacontracts. * CMC should not be run always. * Break main/fixAndUpdate function into two. * Show diff in build after changes. * Cleanup * Rename, script-old. * Cleanup, remove old fix build definitions. * Renames, remove new- prefix. * CMC mapping update. * Config infrastructure; add binance URL to config. * Add image size parameters to config. * Rename. Co-authored-by: Catenocrypt <catenocrypt@users.noreply.github.com> Co-authored-by: Andrew M <35627271+zachzwei@users.noreply.github.com>
2020-07-29 13:42:51 +00:00
console.log("Running updates (using external data sources) ...");
await bluebird.each(actions, async (action) => {
try {
if (action.update) {
console.log(`Update '${action.getName()}':`);
await action.update();
}
} catch (error) {
console.log(`Caught error: ${error.message}`);
}
});
console.log("All updates done.");
}
export async function checkAll(): Promise<number> {
return await checkActionList(actionList);
}
export async function fixAll() {
await fixByList(actionList);
}
export async function updateAll() {
await updateByList(actionList);
[Internal] Refactored fix builds (#2920) * Empty infrastructure for new-housekeeping build. * Move updateBEP action to new new-housekeeping build infra. * Remove old updateBEP. * New-housekeeping-dryrun run. * Include new top-level folder name script-new. * Remove update:bep2 from old daily-run. * Use imports instead of require. * Small refactor for testability. * Organize scripts into subfolders. * iUpdateBEP2: refactor and add tests. * Move formatting validators to new-housekeeping,add new helpers. * Move info and black/whitelist fixing to new-housekeeping. * New fix command. * New 'fix' target; Move ETH checksum fix to new-housekeeping. * Move logo size check and resize to new-housekeeping. * Improved async error handling. * Build renames. * Move (old) BEP2 and CMC update to periodic update build. * Rename (add missing). * Rename builds. * Renames ('fix'). * rename * Invoke new scripts (as well) from period-update. * Move cmc update to new-periodic. * Move tezos validator update to new-periodic. * Missing file. * Leftover. * Cleanup * Rename of unused openseacontracts. * CMC should not be run always. * Break main/fixAndUpdate function into two. * Show diff in build after changes. * Cleanup * Rename, script-old. * Cleanup, remove old fix build definitions. * Renames, remove new- prefix. * CMC mapping update. * Config infrastructure; add binance URL to config. * Add image size parameters to config. * Rename. Co-authored-by: Catenocrypt <catenocrypt@users.noreply.github.com> Co-authored-by: Andrew M <35627271+zachzwei@users.noreply.github.com>
2020-07-29 13:42:51 +00:00
}