-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathundo_colors.js
More file actions
50 lines (41 loc) · 2.08 KB
/
Copy pathundo_colors.js
File metadata and controls
50 lines (41 loc) · 2.08 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
const fs = require('fs');
const path = require('path');
const srcDir = path.join(__dirname, 'src');
function getAllFiles(dirPath, arrayOfFiles) {
const files = fs.readdirSync(dirPath);
arrayOfFiles = arrayOfFiles || [];
files.forEach(function(file) {
const fullPath = path.join(dirPath, file);
if (fs.statSync(fullPath).isDirectory()) {
arrayOfFiles = getAllFiles(fullPath, arrayOfFiles);
} else {
if (fullPath.endsWith('.tsx') || fullPath.endsWith('.ts')) {
arrayOfFiles.push(fullPath);
}
}
});
return arrayOfFiles;
}
const files = getAllFiles(srcDir);
let changedCount = 0;
files.forEach(file => {
let content = fs.readFileSync(file, 'utf8');
const originalContent = content;
// Restore components explicit props
content = content.replace(/placeholderTextColor="#FFFFFF"/g, 'placeholderTextColor={colors.textDim}');
content = content.replace(/(?<![a-zA-Z])color="#FFFFFF"/g, 'color={colors.text}');
// Restore Stylesheet / inline keys
content = content.replace(/(?<![a-zA-Z])color:\s*'#FFFFFF'/g, "color: colors.text");
// Reconstruct common textDim occurrences heuristically based on usual layout patterns:
// Subtitles, metadata, timestamps and small text used textDim primarily
content = content.replace(/color:\s*colors\.text,\s*fontSize:\s*(10|11|12)/g, "color: colors.textDim, fontSize: $1");
content = content.replace(/color:\s*colors\.text,\s*marginBottom:\s*(4|8|16),\s*fontSize:\s*10/g, "color: colors.textDim, marginBottom: $1, fontSize: 10");
content = content.replace(/color:\s*colors\.text,\s*marginTop:\s*4/g, "color: colors.textDim, marginTop: 4");
content = content.replace(/color:\s*colors\.text,\s*textAlign:\s*'center'/g, "color: colors.textDim, textAlign: 'center'");
if (content !== originalContent) {
fs.writeFileSync(file, content, 'utf8');
changedCount++;
console.log('Restored:', file);
}
});
console.log(`\nText color undo complete! Restored dynamic colors via heuristics in ${changedCount} files.`);