-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreplace_terms.js
More file actions
74 lines (63 loc) · 2.3 KB
/
replace_terms.js
File metadata and controls
74 lines (63 loc) · 2.3 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
const fs = require('fs');
const path = require('path');
const dir = path.resolve(__dirname, 'frontend/src/app');
// Re-ordered to prevent double replacing
const replacements = [
{ from: /CellularGraph/g, to: 'HierarchicalGraph' },
{ from: /cellularGraph/g, to: 'hierarchicalGraph' },
{ from: /Cellular/g, to: 'Hierarchical' },
{ from: /cellular/g, to: 'hierarchical' },
{ from: /AgentSwarm/g, to: 'AgentSystem' },
{ from: /agentSwarm/g, to: 'agentSystem' },
{ from: /agent_swarm/g, to: 'agent_system' },
{ from: /Swarm/g, to: 'System' },
{ from: /swarm/g, to: 'system' },
{ from: /ImmuneSwarm/g, to: 'SystemPatcher' },
{ from: /immuneSwarm/g, to: 'systemPatcher' },
{ from: /Immune/g, to: 'System' },
{ from: /immune/g, to: 'system' },
{ from: /Mutation/g, to: 'Patch' },
{ from: /mutation/g, to: 'patch' },
{ from: /Mutate/g, to: 'Patch' },
{ from: /mutate/g, to: 'patch' },
{ from: /Mutat/g, to: 'Patch' }, // catch 'Mutating'
{ from: /mutat/g, to: 'patch' },
{ from: /Organism/g, to: 'System' },
{ from: /organism/g, to: 'system' },
{ from: /Pathogen/g, to: 'Vulnerability' },
{ from: /pathogen/g, to: 'vulnerability' },
{ from: /tCell/g, to: 'patcher' },
{ from: /TCell/g, to: 'Patcher' },
{ from: /T-Cell/g, to: 'Patcher' },
{ from: /t_cell/g, to: 'patcher' },
{ from: /Metabolism/g, to: 'Performance' },
{ from: /metabolism/g, to: 'performance' },
];
function processDirectory(directory) {
const files = fs.readdirSync(directory);
for (const file of files) {
const fullPath = path.join(directory, file);
if (fs.statSync(fullPath).isDirectory()) {
if (file !== 'components') {
processDirectory(fullPath);
} else {
processDirectory(fullPath);
}
} else if (fullPath.endsWith('.js') || fullPath.endsWith('.css') || fullPath.endsWith('.jsx')) {
let content = fs.readFileSync(fullPath, 'utf8');
let modified = false;
for (const req of replacements) {
if (content.match(req.from)) {
content = content.replace(req.from, req.to);
modified = true;
}
}
if (modified) {
fs.writeFileSync(fullPath, content, 'utf8');
console.log('Updated', fullPath);
}
}
}
}
processDirectory(dir);
console.log('Replacements complete in frontend/src/app.');