-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbranding-patch.js
More file actions
90 lines (76 loc) · 2.84 KB
/
branding-patch.js
File metadata and controls
90 lines (76 loc) · 2.84 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
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
/**
* Advanced Branding Patch for SkIDEancer
*
* This script performs deep rebranding of the IDE by:
* 1. Replacing framework names in user-visible strings within node_modules
* 2. Aliasing global objects to match the new brand
* 3. Cleaning up documentation and internal references
*/
function patchFile(filePath, replacements) {
if (!fs.existsSync(filePath)) return;
let content = fs.readFileSync(filePath, 'utf8');
let changed = false;
for (const { search, replace } of replacements) {
if (content.includes(search)) {
const regex =
typeof search === 'string'
? new RegExp(search.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g')
: search;
content = content.replace(regex, replace);
changed = true;
}
}
if (changed) {
fs.writeFileSync(filePath, content);
}
}
function deepRebrand() {
console.log('=== Starting Deep Rebranding ===');
console.log('Patching user-facing strings in core modules...');
// Mass replacement of common phrases in the compiled JS files of the framework
try {
// Replace full names first
execSync(
`find node_modules/@theia -type f -name "*.js" -exec sed -i "s/Eclipse SkIDEancer/SkIDEancer/g" {} +`
);
execSync(
`find node_modules/@theia -type f -name "*.js" -exec sed -i "s/SkIDEancer Framework/SkIDEancer Core/g" {} +`
);
execSync(
`find node_modules/@theia -type f -name "*.js" -exec sed -i "s/Welcome to SkIDEancer/Welcome to SkIDEancer/g" {} +`
);
execSync(
`find node_modules/@theia -type f -name "*.js" -exec sed -i "s/Powered by SkIDEancer/Powered by TNF/g" {} +`
);
// Target specific phrases to avoid breaking technical terms
execSync(
`find node_modules/@theia -type f -name "*.js" -exec sed -i "s/about SkIDEancer/about SkIDEancer/g" {} +`
);
execSync(
`find node_modules/@theia -type f -name "*.js" -exec sed -i "s/SkIDEancer is/SkIDEancer is/g" {} +`
);
// Aggressive replacement for labels (be careful)
// execSync(`find node_modules/@theia -type f -name "*.js" -exec sed -i "s/SkIDEancer/SkIDEancer/g" {} +`);
console.log('Mass replacement of branding strings complete.');
} catch (e) {
console.warn('Warning: Mass replacement failed, skipping...');
}
// 2. Patch global window object in the generated entry point
const entryPoint = path.join(__dirname, 'src-gen', 'frontend', 'index.js');
if (fs.existsSync(entryPoint)) {
patchFile(entryPoint, [
{
search: 'window.ide =',
replace: 'window.skideancer = window.ide =',
},
]);
console.log('Patched frontend entry point with window.skideancer alias.');
}
console.log('=== Deep Rebranding Complete ===');
}
if (require.main === module) {
deepRebrand();
}