MCPcopy
hub / github.com/oslook/cursor-ai-downloads / updateReadmeFromHistory

Function updateReadmeFromHistory

src/update-readme-from-history.ts:44–122  ·  view source on GitHub ↗

* Update README.md file with linux-arm64 links from version history

()

Source from the content-addressed store, hash-verified

42 * Update README.md file with linux-arm64 links from version history
43 */
44function updateReadmeFromHistory(): void {
45 console.log('Starting README update process...');
46
47 // Read version history
48 const history = readVersionHistory();
49
50 if (!history.versions || history.versions.length === 0) {
51 console.log('No versions found in history file');
52 return;
53 }
54
55 // Read README.md
56 const readmePath = path.join(process.cwd(), 'README.md');
57 if (!fs.existsSync(readmePath)) {
58 console.error('README.md file not found');
59 return;
60 }
61
62 let readmeContent = fs.readFileSync(readmePath, 'utf8');
63
64 // Create a backup
65 fs.writeFileSync(`${readmePath}.backup`, readmeContent, 'utf8');
66 console.log(`Created backup at ${readmePath}.backup`);
67
68 let updatedCount = 0;
69
70 // Process each version in history
71 for (const entry of history.versions) {
72 const version = entry.version;
73
74 // Skip if no linux-arm64 URL
75 if (!entry.platforms['linux-arm64']) {
76 console.log(`Version ${version} has no linux-arm64 URL, skipping`);
77 continue;
78 }
79
80 // Check if this version has only linux-x64 in README
81 const linuxX64Only = new RegExp(
82 `\\| ${version} \\| [\\d-]+ \\| .*? \\| .*? \\| \\[linux-x64\\]\\([^)]+\\) \\|`
83 );
84
85 // Check if this version already has linux-arm64 in README
86 const linuxArm64Present = new RegExp(
87 `\\| ${version} \\| [\\d-]+ \\| .*? \\| .*? \\| .*?\\[linux-arm64\\]\\([^)]+\\).*? \\|`
88 );
89
90 if (linuxArm64Present.test(readmeContent)) {
91 console.log(`Version ${version} already has linux-arm64 in README, skipping`);
92 continue;
93 }
94
95 if (linuxX64Only.test(readmeContent)) {
96 // Replace the linux-x64 line with both linux-x64 and linux-arm64
97 const oldLinuxSection = `[linux-x64](${entry.platforms['linux-x64']}) |`;
98 const newLinuxSection = `[linux-x64](${entry.platforms['linux-x64']})<br>[linux-arm64](${entry.platforms['linux-arm64']}) |`;
99
100 // Use string replacement to update the line for this version
101 readmeContent = readmeContent.replace(

Callers 1

Calls 1

readVersionHistoryFunction · 0.70

Tested by

no test coverage detected