|
| 1 | +#!/usr/bin/env node |
| 2 | +import { readFile, writeFile } from 'fs/promises'; |
| 3 | +import { parse, stringify } from 'yaml'; |
| 4 | +import { join } from 'path'; |
| 5 | + |
| 6 | +const projects = [ |
| 7 | + 'fileverse', 'mysterium-network', 'elusiv', 'zkvote', 'starkex', 'hopr', |
| 8 | + 'deeper-network', 'firo', 'oasis-network', 'zcash', 'privatepool', |
| 9 | + 'tornado-cash', 'iden3', 'circom', 'zksync', 'darkfi', 'sentinel', |
| 10 | + 'snarkjs', 'findora', 'cake-wallet', 'typhoon-network', 'iron-fish', |
| 11 | + 'concordium', 'zk-money', 'suterusu', 'oxen', 'orchid', 'rotki', |
| 12 | + 'mobilecoin', 'sienna-network', 'monero', 'zano', 'zeal', 'xx-network', |
| 13 | + 'mask-network', 'fluidkey', 'webb-protocol', 'wasabi-wallet', 'semaphore', |
| 14 | + 'incognito', 'umbra-wallet' // added umbra-wallet |
| 15 | +]; |
| 16 | + |
| 17 | +const validUsecases = [ |
| 18 | + 'wallets', 'defi', 'currency', 'infrastructure', 'computing', 'eth-layer-2', |
| 19 | + 'hardware', 'vpn', 'did', 'dao', 'bridge', 'messaging', 'browser', |
| 20 | + 'kyc-solution', 'rpc-provider', 'storage', 'dapps', 'operating-systems', |
| 21 | + 'nft-community', 'alliances', 'mixing-management', 'data-management', |
| 22 | + 'donate-charity', 'research-and-development', 'mixing-service', 'node', |
| 23 | + 'events', 'ai', 'tee', 'mpc', 'fhe', 'sunset', 'other' |
| 24 | +]; |
| 25 | + |
| 26 | +const validCategories = [ |
| 27 | + 'infrastructure', 'social-and-communications', 'hardware', |
| 28 | + 'applications', 'defi', 'archived-projects' |
| 29 | +]; |
| 30 | + |
| 31 | +const validEcosystems = [ |
| 32 | + 'ethereum', 'bitcoin', 'solana', 'cosmos', 'monero', 'other', 'multichain' |
| 33 | +]; |
| 34 | + |
| 35 | +const validAssets = [ |
| 36 | + 'eth', 'btc', 'usdc', 'usdt', 'dai', 'atom', 'scrt', 'dot', |
| 37 | + 'sol', 'zcash', 'xmr', 'aleph', 'nam', 'other' |
| 38 | +]; |
| 39 | + |
| 40 | +async function migrateProject(projectName) { |
| 41 | + const filePath = join('src/projects', projectName, 'index.yaml'); |
| 42 | + try { |
| 43 | + const content = await readFile(filePath, 'utf8'); |
| 44 | + const data = parse(content); |
| 45 | + |
| 46 | + // Fix project_status |
| 47 | + if (!data.project_status || data.project_status.live_status === undefined) { |
| 48 | + const version = data.project_status?.version || ''; |
| 49 | + let mainnet = false, testnet = false, live_status = false; |
| 50 | + |
| 51 | + if (version.toLowerCase().includes('mainnet')) { |
| 52 | + mainnet = true; |
| 53 | + live_status = true; |
| 54 | + } else if (version.toLowerCase().includes('testnet')) { |
| 55 | + testnet = true; |
| 56 | + live_status = true; |
| 57 | + } |
| 58 | + |
| 59 | + data.project_status = { |
| 60 | + live_status, |
| 61 | + version: data.project_status?.version || '', |
| 62 | + testnet, |
| 63 | + mainnet, |
| 64 | + ...data.project_status |
| 65 | + }; |
| 66 | + } |
| 67 | + |
| 68 | + // Fix categories |
| 69 | + if (data.categories && Array.isArray(data.categories)) { |
| 70 | + data.categories = data.categories |
| 71 | + .map(c => c.toLowerCase()) |
| 72 | + .map(c => { |
| 73 | + if (c === 'wallets') return 'applications'; // wallets -> applications |
| 74 | + return validCategories.includes(c) ? c : 'applications'; |
| 75 | + }); |
| 76 | + } |
| 77 | + |
| 78 | + // Fix ecosystem |
| 79 | + if (data.ecosystem && Array.isArray(data.ecosystem)) { |
| 80 | + data.ecosystem = data.ecosystem |
| 81 | + .map(e => e.toLowerCase()) |
| 82 | + .map(e => validEcosystems.includes(e) ? e : 'other'); |
| 83 | + } |
| 84 | + |
| 85 | + // Fix assets_used |
| 86 | + if (data.assets_used && Array.isArray(data.assets_used)) { |
| 87 | + data.assets_used = data.assets_used |
| 88 | + .map(a => a.toLowerCase()) |
| 89 | + .map(a => validAssets.includes(a) ? a : 'other'); |
| 90 | + } |
| 91 | + |
| 92 | + // Fix usecases |
| 93 | + if (data.usecases && Array.isArray(data.usecases)) { |
| 94 | + data.usecases = data.usecases |
| 95 | + .map(u => u.toLowerCase().replace(/\s+/g, '-')) // "mixing service" -> "mixing-service" |
| 96 | + .map(u => validUsecases.includes(u) ? u : 'other') |
| 97 | + .filter((v, i, arr) => arr.indexOf(v) === i); // dedupe |
| 98 | + } |
| 99 | + |
| 100 | + // Remove invalid top-level properties |
| 101 | + delete data.privacy; |
| 102 | + delete data.security; |
| 103 | + |
| 104 | + await writeFile(filePath, stringify(data, { lineWidth: 0, indent: 2 }), 'utf8'); |
| 105 | + console.log(`✓ ${projectName}`); |
| 106 | + return { status: 'success' }; |
| 107 | + } catch (error) { |
| 108 | + console.error(`✗ ${projectName}: ${error.message}`); |
| 109 | + return { status: 'error' }; |
| 110 | + } |
| 111 | +} |
| 112 | + |
| 113 | +const results = await Promise.all(projects.map(migrateProject)); |
| 114 | +console.log(`\nDone: ${results.filter(r => r.status === 'success').length}/${projects.length}`); |
0 commit comments