2026-05-15 16:36:50 +08:00
|
|
|
/* 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))
|
2026-05-18 08:46:42 +08:00
|
|
|
const pageFile = path.join(currentDir, '..', 'index.vue')
|
|
|
|
|
const componentDir = path.join(currentDir, '..', 'components')
|
|
|
|
|
const apiFile = path.resolve(currentDir, '../../../../api/steady/steadyDataView/index.ts')
|
|
|
|
|
const interfaceFile = path.resolve(currentDir, '../../../../api/steady/steadyDataView/interface/index.ts')
|
2026-05-15 16:36:50 +08:00
|
|
|
|
|
|
|
|
const source = fs.readFileSync(pageFile, 'utf8')
|
2026-05-18 08:46:42 +08:00
|
|
|
const componentSource = fs.existsSync(componentDir)
|
|
|
|
|
? fs
|
|
|
|
|
.readdirSync(componentDir)
|
|
|
|
|
.filter(file => file.endsWith('.vue'))
|
|
|
|
|
.map(file => fs.readFileSync(path.join(componentDir, file), 'utf8'))
|
|
|
|
|
.join('\n')
|
|
|
|
|
: ''
|
2026-05-20 08:32:24 +08:00
|
|
|
const readComponent = file => fs.readFileSync(path.join(componentDir, file), 'utf8')
|
|
|
|
|
const toolbarSource = readComponent('SteadyTrendToolbar.vue')
|
|
|
|
|
const chartPanelSource = readComponent('SteadyTrendChartPanel.vue')
|
|
|
|
|
const floatingPanelSource = readComponent('SteadyIndicatorFloatingPanel.vue')
|
|
|
|
|
const indicatorTreeSource = readComponent('SteadyIndicatorTree.vue')
|
2026-05-18 08:46:42 +08:00
|
|
|
const viewSource = `${source}\n${componentSource}`
|
2026-05-15 16:36:50 +08:00
|
|
|
const apiSource = fs.readFileSync(apiFile, 'utf8')
|
|
|
|
|
const interfaceSource = fs.readFileSync(interfaceFile, 'utf8')
|
|
|
|
|
|
|
|
|
|
const forbiddenPatterns = [
|
|
|
|
|
['data detail tab is removed', /数据明细|name="detail"|SteadyDataTablePanel/, source],
|
|
|
|
|
['detail ProTable is removed', /buildSteadyDataQueryParams|SteadyDataSearchParams/, source],
|
|
|
|
|
['trend summary panel is removed', /SteadyTrendSummaryPanel|trendSummary|loading\.summary/, source],
|
|
|
|
|
[
|
|
|
|
|
'page detail API is removed',
|
|
|
|
|
/getSteadyDataPage|getSteadyDataDetail|getSteadyDataTemplates|\/steady\/data-view\/page|\/steady\/data-view\/detail|\/steady\/data-view\/templates/,
|
|
|
|
|
apiSource
|
|
|
|
|
],
|
|
|
|
|
['trend summary API is removed', /getSteadyTrendSummary|\/steady\/data-view\/trend\/summary/, apiSource],
|
|
|
|
|
[
|
|
|
|
|
'page detail types are removed',
|
|
|
|
|
/PageResult|SteadyDataPageParams|SteadyDataDetailParams|SteadyDataTemplate|SteadyDataRecord/,
|
|
|
|
|
interfaceSource
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'trend summary types are removed',
|
|
|
|
|
/SteadyTrendSummary|SteadyTrendSummaryItem/,
|
|
|
|
|
interfaceSource
|
2026-05-20 08:32:24 +08:00
|
|
|
],
|
|
|
|
|
['chart panel title text is removed', /panel-title/, chartPanelSource],
|
|
|
|
|
['collapsed indicator vertical trigger is removed', /indicator-collapsed-trigger/, floatingPanelSource],
|
|
|
|
|
['collapsed indicator label is removed', /collapsedLabel/, floatingPanelSource]
|
2026-05-15 16:36:50 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
const requiredPatterns = [
|
|
|
|
|
['page defines SteadyDataView component name', /name:\s*'SteadyDataView'/, source],
|
2026-05-18 08:46:42 +08:00
|
|
|
['page renders extracted trend workbench', /<SteadyTrendWorkbench/, source],
|
|
|
|
|
['trend workbench component exists', /SteadyTrendWorkbench/, viewSource],
|
|
|
|
|
['floating indicator panel component exists', /SteadyIndicatorFloatingPanel/, viewSource],
|
|
|
|
|
['components keep trend chart panel', /SteadyTrendChartPanel/, viewSource],
|
|
|
|
|
['components keep right floating indicator panel', /indicator-floating-panel/, viewSource],
|
2026-05-15 16:36:50 +08:00
|
|
|
['indicator panel defaults expanded', /indicatorPanelCollapsed\s*=\s*ref\(false\)/, source],
|
2026-05-18 08:46:42 +08:00
|
|
|
['indicator panel supports collapsed state', /is-collapsed/, viewSource],
|
2026-05-20 08:32:24 +08:00
|
|
|
['API keeps trend query endpoint', /\/steady\/data-view\/trend\/query/, apiSource],
|
|
|
|
|
[
|
|
|
|
|
'trend toolbar reserves four evenly distributed search columns',
|
|
|
|
|
/grid-template-columns:\s*repeat\(4,\s*minmax\(0,\s*1fr\)\)\s*auto/,
|
|
|
|
|
toolbarSource
|
|
|
|
|
],
|
|
|
|
|
['trend toolbar keeps actions after four search columns', /grid-column:\s*5/, toolbarSource],
|
|
|
|
|
['floating indicator panel expanded width is reduced', /width:\s*300px/, floatingPanelSource],
|
|
|
|
|
['floating indicator collapsed state keeps icon only', /width:\s*0/, floatingPanelSource],
|
|
|
|
|
['floating indicator body is hidden when collapsed', /\.indicator-floating-panel\.is-collapsed\s+\.indicator-panel-body/, floatingPanelSource],
|
|
|
|
|
['indicator tree header separates title and refresh icon', /justify-content:\s*flex-start/, indicatorTreeSource]
|
2026-05-15 16:36:50 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
const failures = [
|
|
|
|
|
...forbiddenPatterns.filter(([, pattern, target]) => pattern.test(target)),
|
|
|
|
|
...requiredPatterns.filter(([, pattern, target]) => !pattern.test(target))
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
if (failures.length) {
|
|
|
|
|
console.error('steadyDataView visible contract failed:')
|
|
|
|
|
for (const [name] of failures) {
|
|
|
|
|
console.error(`- ${name}`)
|
|
|
|
|
}
|
|
|
|
|
process.exit(1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log('steadyDataView visible contract passed')
|