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