You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.6 KiB
JavaScript
42 lines
1.6 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
const d = 'E:/opencode/haoliang/frontend/src/views';
|
|
|
|
const fixes = [
|
|
['(rows: any[])', '(rows: Record<string,unknown>[])'],
|
|
['(record: any)', '(record: Record<string,unknown>)'],
|
|
['const params: any =', 'const params: Record<string,unknown> ='],
|
|
['(r: any) => r.id', '(r: {id:number}) => r.id'],
|
|
['function onFileChange(file: any)', 'function onFileChange(file: Record<string,unknown>)'],
|
|
['params: { row: any; rowIndex', 'params: { row: Record<string,unknown>; rowIndex'],
|
|
['const payload: any =', 'const payload: Record<string,unknown> ='],
|
|
['(c: any) => c.configKey.toLowerCase().includes(kw) || c.description.t',
|
|
'(c: {configKey:string;description:string}) => c.configKey.toLowerCase().includes(kw) || c.description.t'],
|
|
['_rule: any, value: string, callback: any', '_rule: unknown, value: string, callback: (err?:Error)=>void'],
|
|
['rule: any, value: any, callback: any', 'rule: unknown, value: string, callback: (err?:Error)=>void'],
|
|
];
|
|
|
|
let total = 0;
|
|
fs.readdirSync(d).forEach(sub => {
|
|
const subDir = path.join(d, sub);
|
|
if (!fs.statSync(subDir).isDirectory()) return;
|
|
fs.readdirSync(subDir).forEach(f => {
|
|
if (!f.endsWith('.vue')) return;
|
|
const fp = path.join(subDir, f);
|
|
let c = fs.readFileSync(fp, 'utf8');
|
|
let n = 0;
|
|
fixes.forEach(([from, to]) => {
|
|
if (c.includes(from)) {
|
|
c = c.split(from).join(to);
|
|
n++;
|
|
}
|
|
});
|
|
if (n > 0) {
|
|
fs.writeFileSync(fp, c, 'utf8');
|
|
console.log(f + ': ' + n);
|
|
total += n;
|
|
}
|
|
});
|
|
});
|
|
console.log('Total fixed: ' + total);
|