in scripts/codemod.js [41:66]
function modREADME() {
let bareCompName = comp.replace(/^\.\//, '')
bareCompName = bareCompName.replace(/^rc-/, '')
const READMEPath = path.resolve(compDir, 'README.md')
const consoleOSId = `console-components-${bareCompName}-docs`
let md = fs.readFileSync(READMEPath, 'utf-8')
md = md.replaceAll(
/\[MDXInstruction:importDemo:(.*?)\]\((.*?)\)/g,
(match, _, demoPath) => {
const match1 = demoPath.match(/\.\/stories\/(.*?)\.tsx?/)
if (!match1) throw new Error(`unexpected, ${match}`)
return `[$XView](https://xconsole.aliyun-inc.com/demo-playground?consoleOSId=${consoleOSId}&entryKey=${match1[1]})`
}
)
md = md.replaceAll(
/\[MDXInstruction:renderInterface:(.*?)\]\((.*?)\)/g,
(match, interfaceName, _) => {
return `[$XView](https://xconsole.aliyun-inc.com/demo-playground?consoleOSId=${consoleOSId}&entryKey=types/${interfaceName})`
}
)
fs.writeFileSync(READMEPath, md)
}