我叫洪圣文
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/* eslint-env node */
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const currentDir = path.dirname(fileURLToPath(import.meta.url))
|
||||
const srcRoot = path.resolve(currentDir, '../../..')
|
||||
const staticRouter = fs.readFileSync(path.join(srcRoot, 'routers/modules/staticRouter.ts'), 'utf8')
|
||||
const dynamicRouter = fs.readFileSync(path.join(srcRoot, 'routers/modules/dynamicRouter.ts'), 'utf8')
|
||||
const authStore = fs.readFileSync(path.join(srcRoot, 'stores/modules/auth.ts'), 'utf8')
|
||||
|
||||
const expectations = [
|
||||
['static router registers /steadyDataView/index', /path:\s*'\/steadyDataView\/index'/],
|
||||
['static route name is steadyDataView', /name:\s*'steadyDataView'/],
|
||||
['static router imports steadyDataView page', /@\/views\/steady\/steadyDataView\/index\.vue/],
|
||||
['dynamic router aliases steady-data-view to steadyDataView', /\/steady\/steady-data-view[\s\S]*\/steady\/steadyDataView/],
|
||||
['dynamic router keeps steadyDataView static route from being overwritten', /STATIC_ROUTE_NAMES[\s\S]*'steadyDataView'/],
|
||||
['auth normalizes backend steady menu to static steadyDataView entry', /isSteadyDataViewMenu[\s\S]*menu\.path\s*=\s*'\/steadyDataView\/index'/],
|
||||
['business menu path resolver handles steadyDataView', /isSteadyDataViewMenu\(menu\)\s*\?\s*'\/steadyDataView\/index'/]
|
||||
]
|
||||
|
||||
const sourceByExpectation = [staticRouter, staticRouter, staticRouter, dynamicRouter, dynamicRouter, authStore, authStore]
|
||||
|
||||
const failures = expectations.filter(([, pattern], index) => !pattern.test(sourceByExpectation[index]))
|
||||
|
||||
if (failures.length) {
|
||||
console.error('steadyDataView route contract failed:')
|
||||
for (const [name] of failures) {
|
||||
console.error(`- ${name}`)
|
||||
}
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
console.log('steadyDataView route contract passed')
|
||||
Reference in New Issue
Block a user