Archived
forked from admin/userbase
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
const fs = require('fs');
|
||||
const base = 'D:/SoftProject/yunhai/UserBase/front/src/api/';
|
||||
const files = ['apiDefinitions.ts', 'globals.d.ts'];
|
||||
// 仅匹配单引号包裹的 api-path key:'xxxController.method'
|
||||
const re = /'([a-zA-Z]+?)Controller\./g;
|
||||
for (const f of files) {
|
||||
const p = base + f;
|
||||
let s = fs.readFileSync(p, 'utf8');
|
||||
const before = (s.match(re) || []).length;
|
||||
s = s.replace(re, (m, ns) => "'" + ns.charAt(0).toUpperCase() + ns.slice(1) + ".");
|
||||
fs.writeFileSync(p, s, 'utf8');
|
||||
const after = (s.match(re) || []).length;
|
||||
console.log(f + ': replaced ' + before + ' -> remaining ' + after);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
const fs = require('fs');
|
||||
const p = 'D:/SoftProject/yunhai/UserBase/front/src/api/globals.d.ts';
|
||||
let s = fs.readFileSync(p, 'utf8');
|
||||
// 匹配类型侧命名空间属性声明: baseController: { 或 baseController?: {
|
||||
const re = /([ \t])([a-zA-Z]+?)Controller(\s*\??):/g;
|
||||
const before = (s.match(re) || []).length;
|
||||
s = s.replace(re, (m, sp, ns, q) => sp + (ns.charAt(0).toUpperCase() + ns.slice(1)) + (q || '') + ':');
|
||||
fs.writeFileSync(p, s, 'utf8');
|
||||
console.log('globals prop decl converted: ' + before + ' -> ' + (s.match(re) || []).length + ' remaining');
|
||||
Reference in New Issue
Block a user