cmvr-wms/ruoyi-ui-vue3/tests/build-reactivity-audit.mjs

11 lines
2.1 KiB
JavaScript
Raw Normal View History

import { build, preview } from 'vite'
import path from 'node:path'
const outDir=path.resolve('../.codex-tmp/reactivity-audit-production')
const apiNames=['getAssistantSession','newAssistantSession','getAssistantActions','sendAssistantMessage','previewAssistantDraft','executeAssistantDraft','cancelAssistantDraft','resumeAssistantDraft','uploadAssistantAttachment','getAssistantAttachmentImage']
const network=`import {shallowReactive} from 'vue';export const lookups=shallowReactive([]);export function lookupAssistantOptions(action,key,query){return new Promise(resolve=>lookups.push({action,key,query,resolve}))}export function finishLookup(){const next=lookups.shift();if(next)next.resolve({data:[{value:1,label:'返回候选:'+next.query}]})};${apiNames.map(name=>`export function ${name}(){throw Error('Business endpoints are disabled in this fixture')}`).join(';')}`
const routes=`import {createRouter,createMemoryHistory} from 'vue-router';export default createRouter({history:createMemoryHistory(),routes:[{path:'/warehouse/stock',component:{render:()=>null}},{path:'/redirect/:path(.*)',component:()=>import('/src/views/redirect/index.vue')}]})`
const tags=`const store={delCachedView:async()=>{},addCachedView:()=>{}};export default()=>store`
const plugin={name:'isolated-audit-boundaries',enforce:'pre',resolveId(id){const normalized=id.replaceAll('\\','/');if(id==='@/api/warehouse/assistant'||id==='virtual:audit-network'||/\/src\/api\/warehouse\/assistant(?:\.js)?$/.test(normalized))return '\0audit-network';if(id==='@/router'||id==='virtual:audit-router'||/\/src\/router(?:\/index(?:\.js)?)?$/.test(normalized))return '\0audit-router';if(id==='@/store/modules/tagsView'||/\/src\/store\/modules\/tagsView(?:\.js)?$/.test(normalized))return '\0audit-tags'},load(id){if(id==='\0audit-network')return network;if(id==='\0audit-router')return routes;if(id==='\0audit-tags')return tags}}
if(process.argv.includes('--serve')){const server=await preview({build:{outDir},preview:{host:'127.0.0.1',port:8099,strictPort:true}});server.printUrls()}
else await build({plugins:[plugin],build:{outDir,emptyOutDir:true,rollupOptions:{input:path.resolve('tests/fixtures/reactivity-audit.html')}}})