mirror of
https://github.com/Instadapp/trustwallet-assets.git
synced 2024-07-29 22:37:31 +00:00
[Internal] Remove obsolete history information, and infrastructure (#13879)
* Remove history infrastructure. * Remove history information * Revert "Remove history information" This reverts commit e490134192e3c99b0815cf5a87a574916f038ba7.
This commit is contained in:
parent
596120739a
commit
abb55dbfbf
11
.github/workflows/fix.yml
vendored
11
.github/workflows/fix.yml
vendored
|
@ -1,6 +1,6 @@
|
|||
name: Fixes and History
|
||||
name: Fixes
|
||||
# Runs on:
|
||||
# - on master branch of trustwallet repo: fix, history update, checkin
|
||||
# - on master branch of trustwallet repo: fix, checkin
|
||||
# - on other branch of trustwallet repo: fix, checkin
|
||||
# - on fork repos: fix-sanity only
|
||||
on:
|
||||
|
@ -19,8 +19,6 @@ jobs:
|
|||
with:
|
||||
token: ${{ secrets.COMMIT_TOKEN }}
|
||||
ref: ${{ github.ref }}
|
||||
# this is needed for history, needs to access prev commits
|
||||
fetch-depth: 0
|
||||
- name: Checkout (fork repo, default token)
|
||||
if: github.repository_owner != 'trustwallet'
|
||||
uses: actions/checkout@v2
|
||||
|
@ -40,9 +38,6 @@ jobs:
|
|||
run: npm run fix-sanity
|
||||
- name: Debug
|
||||
run: echo "GITHUB_REF " $GITHUB_REF " GITHUB_BASE_REF " $GITHUB_BASE_REF
|
||||
- name: Run history
|
||||
if: github.repository_owner == 'trustwallet' && (github.base_ref == 'master' || github.ref == 'refs/heads/master')
|
||||
run: npm run history
|
||||
- name: Show result (diff) (run 'npm run fix' locally)
|
||||
run: |
|
||||
git status
|
||||
|
@ -57,4 +52,4 @@ jobs:
|
|||
with:
|
||||
commit_user_name: trust-wallet-merge-bot
|
||||
commit_user_email: mergebot@trustwallet.com
|
||||
commit_message: Fixes (sanity and consistency, auto), history
|
||||
commit_message: Fixes (sanity and consistency, auto)
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
"fix-sanity": "ts-node ./script/entrypoint/fix-sanity",
|
||||
"updateAuto": "ts-node ./script/entrypoint/updateAuto",
|
||||
"update": "ts-node ./script/entrypoint/updateManual",
|
||||
"history": "ts-node ./script/entrypoint/history",
|
||||
"lint": "npx eslint . --ext .js,.jsx,.ts,.tsx",
|
||||
"lint:fix": "npx eslint . --ext .js,.jsx,.ts,.tsx --fix"
|
||||
},
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
import { processChanges } from "../generic/history";
|
||||
|
||||
export async function main(): Promise<void> {
|
||||
try {
|
||||
const ret = await processChanges();
|
||||
if (ret != 0) {
|
||||
process.exit(ret);
|
||||
}
|
||||
} catch(err) {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
|
@ -1,174 +0,0 @@
|
|||
import * as util from "util";
|
||||
import {
|
||||
isPathExistsSync,
|
||||
readFileSync,
|
||||
writeFileSync,
|
||||
} from "./filesystem";
|
||||
import * as child_process from "child_process";
|
||||
|
||||
class VersionInfo {
|
||||
versionNum: number;
|
||||
commit: string;
|
||||
date: string;
|
||||
}
|
||||
|
||||
const FilenameLatest = "history/LATEST.json";
|
||||
const FilenameChangeTemplate = "history/versions/";
|
||||
const IncludeHistoryPrefix1 = "blockchains/";
|
||||
const IncludeHistoryPrefix2 = "dapps/";
|
||||
//const TooManyChangesLimit = 40;
|
||||
|
||||
//const util = require('util');
|
||||
const exec = util.promisify(child_process.exec);
|
||||
|
||||
async function execGit(options: string): Promise<string> {
|
||||
try {
|
||||
const cmd = `git ${options}`;
|
||||
console.log(`executing cmd: ${cmd}`);
|
||||
const { stdout, stderr } = await exec(cmd);
|
||||
if (stdout) {
|
||||
console.log('stdout:');
|
||||
console.log(stdout);
|
||||
}
|
||||
if (stderr) {
|
||||
console.log('stderr:', stderr);
|
||||
}
|
||||
return stdout;
|
||||
} catch (err) {
|
||||
console.log('exception:', err);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
function readLatestVersion(): VersionInfo {
|
||||
const zeroVer: VersionInfo = {versionNum: 0, commit: "", date: (new Date()).toISOString()};
|
||||
try {
|
||||
const rawdata = readFileSync(FilenameLatest);
|
||||
const ver: VersionInfo = JSON.parse(rawdata) as VersionInfo;
|
||||
if (!ver.versionNum && !ver.commit) {
|
||||
return zeroVer;
|
||||
}
|
||||
return ver;
|
||||
} catch (err) {
|
||||
console.log('Exception:', err);
|
||||
return zeroVer;
|
||||
}
|
||||
}
|
||||
|
||||
function writeLatestVersion(version: VersionInfo): void {
|
||||
try {
|
||||
const content: string = JSON.stringify(version, null, 4);
|
||||
writeFileSync(FilenameLatest, content);
|
||||
} catch (err) {
|
||||
console.log('Exception:', err);
|
||||
}
|
||||
}
|
||||
|
||||
async function getCurrentCommit(): Promise<string> {
|
||||
const raw = await execGit("rev-parse master");
|
||||
if (!raw) {
|
||||
return raw;
|
||||
}
|
||||
return raw.split("\n").filter(l => l)[0];
|
||||
}
|
||||
|
||||
async function getChangedFiles(commitStart: string, commitEnd: string): Promise<string[]>{
|
||||
const bulk: string = await execGit(`diff --name-only ${commitStart} ${commitEnd}`);
|
||||
if (!bulk) {
|
||||
return [];
|
||||
}
|
||||
const list: string[] = bulk.split("\n").map(l => l.trim()).filter(l => l);
|
||||
return list;
|
||||
}
|
||||
|
||||
function filterChangedFiles(files: string[]): string[] {
|
||||
return files.filter(l => {
|
||||
return (l.startsWith(IncludeHistoryPrefix1) || l.startsWith(IncludeHistoryPrefix2));
|
||||
});
|
||||
}
|
||||
|
||||
function changeListToJson(versionStart: VersionInfo, versionEnd: VersionInfo, changes: string[]): unknown {
|
||||
//let fullChanges = false;
|
||||
//if (changes.length > TooManyChangesLimit) {
|
||||
// fullChanges = true;
|
||||
//}
|
||||
const obj: unknown = {
|
||||
"versionEnd": versionEnd,
|
||||
"versionStart": versionStart,
|
||||
//"fullChange": fullChanges,
|
||||
//"changeCount": changes.length,
|
||||
};
|
||||
//if (!fullChanges) {
|
||||
obj["changes"] = changes;
|
||||
//}
|
||||
return obj;
|
||||
}
|
||||
|
||||
// return filename
|
||||
function writeChangeList(version: VersionInfo, changeList: unknown): string {
|
||||
try {
|
||||
const filename: string = FilenameChangeTemplate + version.versionNum.toString() + ".json";
|
||||
if (isPathExistsSync(filename)) {
|
||||
throw `Error: file already exists: ${filename}`;
|
||||
}
|
||||
const content = JSON.stringify(changeList, null, 4);
|
||||
writeFileSync(filename, content);
|
||||
return filename;
|
||||
} catch (err) {
|
||||
console.log('exception:', err);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export async function processChanges(): Promise<number> {
|
||||
console.log("Compiling changes since last commit ...");
|
||||
const ver = readLatestVersion();
|
||||
if (ver.versionNum == 0 || !ver.versionNum || !ver.commit) {
|
||||
console.log("Error: Could not obtain latest version");
|
||||
return 1;
|
||||
}
|
||||
console.log(`Latest version: ${JSON.stringify(ver, null, 4)}`);
|
||||
|
||||
const currCommit = await getCurrentCommit();
|
||||
console.log(`Current commit: ${currCommit}`);
|
||||
if (!currCommit) {
|
||||
console.log("Error: Could not obtain current commit");
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (currCommit == ver.commit) {
|
||||
console.log(`Warning: no new commit since ${ver.commit}`);
|
||||
return 3;
|
||||
}
|
||||
|
||||
const newVer: VersionInfo = {
|
||||
versionNum: ver.versionNum + 1,
|
||||
commit: currCommit,
|
||||
date: (new Date()).toISOString(),
|
||||
};
|
||||
console.log(`New version: ${JSON.stringify(newVer, null, 4)}`);
|
||||
|
||||
const filesRaw: string[] = await getChangedFiles(ver.commit, currCommit);
|
||||
console.log(`${filesRaw.length} changed files found`);
|
||||
if (!filesRaw || filesRaw.length == 0) {
|
||||
console.log(`Error: Could not obtain list of changed files between commits ${ver.commit} and ${currCommit}`);
|
||||
return 4;
|
||||
}
|
||||
const files: string[] = filterChangedFiles(filesRaw);
|
||||
console.log(`${files.length} changed files found (excluding history files)`);
|
||||
if (!files || files.length == 0) {
|
||||
console.log(`Warning: No changed files (excluding history files) between commits ${ver.commit} and ${currCommit}`);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const changeList: unknown = changeListToJson(ver, newVer, files);
|
||||
const newChangeFile = writeChangeList(newVer, changeList);
|
||||
if (!newChangeFile) {
|
||||
console.log(`Error: could not write out new change file`);
|
||||
return 6;
|
||||
}
|
||||
writeLatestVersion(newVer);
|
||||
console.log(`Changes written to ${FilenameLatest} and ${newChangeFile}`);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user