-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-changelog.js
More file actions
54 lines (43 loc) · 2.47 KB
/
fix-changelog.js
File metadata and controls
54 lines (43 loc) · 2.47 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
#!/usr/bin/env node
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
// Get current directory
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Path to the changelog
const changelogPath = path.join(__dirname, 'docs', 'pages', 'resources', 'changelog.md');
// Read the changelog
let content = fs.readFileSync(changelogPath, 'utf8');
// Define replacements for malformed tags
const replacements = [
// Fix malformed kit- tags
[/kit-([a-z-]+)>/g, '<kit-$1>'],
[/kit-it-([a-z-]+)>/g, '<kit-$1>'],
[/ankit-<kit-([a-z-]+)>/g, '<kit-$1>'],
[/kit-<kit-([a-z-]+)>/g, '<kit-$1>'],
[/<kit-([a-z-]+)>/g, '<kit-$1>'],
[/thekit-it-([a-z-]+)`/g, 'the `kit-$1`'],
[/kit-it-([a-z-]+)`/g, '`kit-$1`'],
[/kit-([a-z-]+)`/g, '`kit-$1`'],
[/kit-<code><kit-([a-z-]+)>/g, '<code><kit-$1>'],
[/<kit-rangkit-,/g, '<kit-range>'],
[/<\/kit-rangkit-,>/g, '</kit-range>'],
[/,kit-kit-([a-z-]+)>/g, '<kit-$1>'],
[/<kit-([a-z-]+)>/g, '<kit-$1>'],
// Handle specific problematic lines
[/Refactored <code><kit-breadcrumb-item><\/code>, <code>kit-button><\/code>, kit-it-card><code>,kit-kit-dialog><\/code>kit-<kit-drawer>kit-<code><kit-inputkit- <\/code><kit-rangkit-, <code=""><kit-select>kit-nd <code><kit-textarea><\/code>/g,
'Refactored <code><kit-breadcrumb-item></code>, <code><kit-button></code>, <code><kit-card></code>, <code><kit-dialog></code>, <code><kit-drawer></code>, <code><kit-input></code>, <code><kit-range></code>, <code><kit-select></code> and <code><kit-textarea></code>'],
[/Fixed a bug in <code><kit-alert><\/code>, <code>kit-dialog><\/code>, kit-it-drawer><code>,kit-kit-select><\/code>, ankit-<kit-tag>/g,
'Fixed a bug in <code><kit-alert></code>, <code><kit-dialog></code>, <code><kit-drawer></code>, <code><kit-select></code>, <code><kit-tag></code>'],
[/Added `kit-initial-focus` event to `kit-dialog>` and kit-it-drawer>`/g,
'Added `kit-initial-focus` event to `<kit-dialog>` and `<kit-drawer>`'],
];
// Apply all replacements
let updatedContent = content;
replacements.forEach(([pattern, replacement]) => {
updatedContent = updatedContent.replace(pattern, replacement);
});
// Write the updated content back to the file
fs.writeFileSync(changelogPath, updatedContent, 'utf8');
console.log('Changelog updated successfully!');