import { readdir } from 'node:fs/promises'
import { pathToFileURL } from 'node:url'
import path from 'node:path'

const scriptsDir = path.resolve(process.cwd(), 'scripts')
const regressionScripts = (await readdir(scriptsDir))
  .filter((file) => file.startsWith('regression-') && file.endsWith('.mjs'))
  .sort()

for (const script of regressionScripts) {
  console.log(`\n▶ ${script}`)
  await import(pathToFileURL(path.join(scriptsDir, script)).href)
}

console.log(`\n✅ ${regressionScripts.length} 个前端回归脚本全部通过`)
