|
| 1 | +constfs=require('fs') |
| 2 | + |
1 | 3 | module.exports=(api)=>{
|
2 | 4 | api.extendPackage({
|
3 | 5 | dependencies:{
|
@@ -93,5 +95,29 @@ module.exports = (api) => {
|
93 | 95 | // * Partial support of per-component navigation guards. No `beforeRouteEnter`
|
94 | 96 | }
|
95 | 97 |
|
96 |
| -api.transformScript(api.entryFile,require('./codemods/global-api')) |
| 98 | +constglobalApiTransform=require('./codemods/global-api') |
| 99 | +api.transformScript(api.entryFile,globalApiTransform) |
| 100 | + |
| 101 | +constresolveFile=(file)=>{ |
| 102 | +letfilePath=api.resolve(file) |
| 103 | +if(fs.existsSync(filePath))returnfilePath |
| 104 | +filePath=api.resolve(file.replace('.js','.ts')) |
| 105 | +if(fs.existsSync(filePath))returnfilePath |
| 106 | +filePath=api.resolve(path.join(file.replace('.js',''),'index.js')) |
| 107 | +if(fs.existsSync(filePath))returnfilePath |
| 108 | +filePath=api.resolve(path.join(file.replace('.js',''),'index.ts')) |
| 109 | +if(fs.existsSync(filePath))returnfilePath |
| 110 | +} |
| 111 | + |
| 112 | +constrouterPath=resolveFile('router') |
| 113 | +if(routerPath){ |
| 114 | +api.transformScript(routerPath,globalApiTransform) |
| 115 | +api.transformScript(routerPath,require('./codemods/router')) |
| 116 | +} |
| 117 | + |
| 118 | +conststorePath=resolveFile('store') |
| 119 | +if(storePath){ |
| 120 | +api.transformScript(storePath,globalApiTransform) |
| 121 | +api.transformScript(storePath,require('./codemods/vuex')) |
| 122 | +} |
97 | 123 | }
|