Skip to content

Commit

Permalink
added build-alive script for v1
Browse files Browse the repository at this point in the history
  • Loading branch information
hu-ke committed Nov 6, 2024
1 parent e5ce6cd commit 5f1f13f
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions v1/packages/chain-registry/scripts/build-alive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,34 +80,45 @@ function updateCategoryFiles(categoryPath: string): void {
fs.writeFileSync(chainsFilePath, content, 'utf-8');
}

// Update the contents of asset-list.ts
const assetListFilePath = path.join(categoryPath, 'asset-lists.ts');
if (fs.existsSync(assetListFilePath)) {
let content = fs.readFileSync(assetListFilePath, 'utf-8');
// Update the contents of assets.ts
const assetsFilePath = path.join(categoryPath, 'assets.ts');
if (fs.existsSync(assetsFilePath)) {
let content = fs.readFileSync(assetsFilePath, 'utf-8');
killedModules.forEach(module => {
// Remove imports for modules that do not meet the conditions
const regex = new RegExp(`import \\* as _${module} from '\\.${path.sep}${module}';[\\s\\S]*?\\n`);
content = content.replace(regex, ''); // Remove import statement
// content = content.replace(new RegExp(`_\\${module}\\.assetList(\\s*,?\\s*)`, 'g'), ''); // Remove assetList array reference
const regex2 = new RegExp(`\\s*_(${module}).assetList,?\\s*`, 'g');
const regex2 = new RegExp(`\\s*_(${module}).assets,?\\s*`, 'g');
content = content.replace(regex2, '');
});
fs.writeFileSync(assetListFilePath, content, 'utf-8');
fs.writeFileSync(assetsFilePath, content, 'utf-8');
}

// Update the contents of ibc-data.ts
const ibcDataFilePath = path.join(categoryPath, 'ibc-data.ts');
if (fs.existsSync(ibcDataFilePath)) {
let content = fs.readFileSync(ibcDataFilePath, 'utf-8');
// Update the contents of ibc.ts
const ibcFilePath = path.join(categoryPath, 'ibc.ts');
if (fs.existsSync(ibcFilePath)) {
let content = fs.readFileSync(ibcFilePath, 'utf-8');
killedModules.forEach(module => {
// Remove imports for modules that do not meet the conditions
const regex = new RegExp(`import \\* as _${module} from '\\.${path.sep}${module}';[\\s\\S]*?\\n`);
content = content.replace(regex, ''); // Remove import statement
// content = content.replace(new RegExp(`\\.{3}_\\${module}\\.ibcData(\\s*,?\\s*)`, 'g'), ''); // Remove ibcData array reference
const regex2 = new RegExp(`\\s*..._(${module}).ibcData,?\\s*`, 'g');
const regex2 = new RegExp(`\\s*..._(${module}).ibc,?\\s*`, 'g');
content = content.replace(regex2, '');
});
fs.writeFileSync(ibcDataFilePath, content, 'utf-8');
fs.writeFileSync(ibcFilePath, content, 'utf-8');
}

// Update the contents of named.ts
const namedFilePath = path.join(categoryPath, 'named.ts');
if (fs.existsSync(namedFilePath)) {
let content = fs.readFileSync(namedFilePath, 'utf-8');
killedModules.forEach(module => {
// Remove imports for modules that do not meet the conditions
const regex = new RegExp(`export \\* as _?${module} from '\\.${path.sep}${module}';[\\s\\S]*?\\n`);
content = content.replace(regex, ''); // Remove import statement
});
fs.writeFileSync(namedFilePath, content, 'utf-8');
}
}

Expand Down

0 comments on commit 5f1f13f

Please sign in to comment.