Files
venue-miniapp/miniprogram/scripts/verify-venue-tabbar.mjs
T
2026-06-08 21:42:32 +08:00

63 lines
2.3 KiB
JavaScript

import { existsSync, readFileSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { dirname, resolve } from 'node:path'
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..')
const srcRoot = resolve(root, 'src')
const tabPages = [
{ file: 'pages/ice/home/index.vue', venue: 'ice', active: 'home' },
{ file: 'pages/ice/courses/index.vue', venue: 'ice', active: 'courses' },
{ file: 'pages/ice/bookings/index.vue', venue: 'ice', active: 'bookings' },
{ file: 'pages/ice/profile/index.vue', venue: 'ice', active: 'profile' },
{ file: 'pages/comprehensive/home/index.vue', venue: 'comprehensive', active: 'home' },
{ file: 'pages/comprehensive/courses/index.vue', venue: 'comprehensive', active: 'courses' },
{ file: 'pages/comprehensive/bookings/index.vue', venue: 'comprehensive', active: 'bookings' },
{ file: 'pages/comprehensive/profile/index.vue', venue: 'comprehensive', active: 'profile' }
]
const icons = ['home', 'course', 'booking', 'mine']
const venues = ['ice', 'comprehensive']
const failures = []
const assertFile = (path) => {
if (!existsSync(path)) failures.push(`Missing file: ${path}`)
}
assertFile(resolve(srcRoot, 'components/VenueTabBar.vue'))
for (const { file, venue, active } of tabPages) {
const path = resolve(srcRoot, file)
assertFile(path)
if (!existsSync(path)) continue
const content = readFileSync(path, 'utf8')
if (!content.includes('<VenueTabBar')) {
failures.push(`${file} does not render <VenueTabBar>`)
}
if (!content.includes(`venue="${venue}"`)) {
failures.push(`${file} does not pass venue="${venue}"`)
}
if (!content.includes(`active="${active}"`)) {
failures.push(`${file} does not pass active="${active}"`)
}
if (!content.includes("import VenueTabBar from '@/components/VenueTabBar.vue'")) {
failures.push(`${file} does not import VenueTabBar`)
}
}
for (const venue of venues) {
for (const icon of icons) {
assertFile(resolve(srcRoot, `static/${venue}/tab/${icon}.png`))
assertFile(resolve(srcRoot, `static/${venue}/tab/${icon}-active.png`))
}
}
if (failures.length) {
console.error(`Venue tabbar verification failed with ${failures.length} issue(s):`)
for (const failure of failures) console.error(`- ${failure}`)
process.exit(1)
}
console.log('Venue tabbar verification passed.')